id = 'per_product_type';
$this->desc = __( 'Per Product Type & Condition', 'add-to-cart-button-labels-for-woocommerce' );
parent::__construct();
}
/**
* get_desc_tip.
*
* @version 1.2.0
* @since 1.2.0
*/
function get_desc_tip( $single_or_archives, $product_type, $condition ) {
return __( 'Ignored if blank.', 'add-to-cart-button-labels-for-woocommerce' ) . '
' .
sprintf( __( 'Default: %s', 'add-to-cart-button-labels-for-woocommerce' ),
'' . $this->get_default_label_value( $single_or_archives, $product_type, $condition ) . '' );
}
/**
* get_default_label_value.
*
* @version 1.2.0
* @since 1.2.0
*/
function get_default_label_value( $single_or_archives, $product_type, $condition ) {
return ( isset( $this->default_values[ $product_type ][ $condition ][ $single_or_archives ] ) ?
$this->default_values[ $product_type ][ $condition ][ $single_or_archives ] : '' );
}
/**
* get_settings.
*
* @version 1.2.0
* @since 1.0.0
*/
function get_settings() {
$this->default_values = array(
'simple' => array(
'' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_on_sale' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_zero_price' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_no_price' => array(
'archives' => __( 'Read more', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_in_cart' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
),
),
'variable' => array(
'' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Select options', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_on_sale' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Select options', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_zero_price' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Select options', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_in_cart' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Select options', 'add-to-cart-button-labels-for-woocommerce' ),
),
),
'external' => array(
'' => array(
'single' => __( 'Buy product', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Buy product', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_on_sale' => array(
'single' => __( 'Buy product', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Buy product', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_zero_price' => array(
'single' => __( 'Buy product', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Buy product', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_no_price' => array(
'single' => __( 'Buy product', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Buy product', 'add-to-cart-button-labels-for-woocommerce' ),
),
),
'grouped' => array(
'' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'View products', 'add-to-cart-button-labels-for-woocommerce' ),
),
),
'other' => array(
'' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_on_sale' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_zero_price' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_no_price' => array(
'archives' => __( 'Read more', 'add-to-cart-button-labels-for-woocommerce' ),
),
'_in_cart' => array(
'single' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Add to cart', 'add-to-cart-button-labels-for-woocommerce' ),
),
),
);
$product_types = array(
'simple' => __( 'Simple Products', 'add-to-cart-button-labels-for-woocommerce' ),
'variable' => __( 'Variable Products', 'add-to-cart-button-labels-for-woocommerce' ),
'external' => __( 'External Products', 'add-to-cart-button-labels-for-woocommerce' ),
'grouped' => __( 'Grouped Products', 'add-to-cart-button-labels-for-woocommerce' ),
'other' => __( 'Other Products', 'add-to-cart-button-labels-for-woocommerce' ),
);
$views = array(
'single' => __( 'Single product view', 'add-to-cart-button-labels-for-woocommerce' ),
'archives' => __( 'Archives view', 'add-to-cart-button-labels-for-woocommerce' ),
);
$conditions = array(
'' => '',
'_on_sale' => __( 'On sale', 'add-to-cart-button-labels-for-woocommerce' ),
'_zero_price' => __( 'Free product', 'add-to-cart-button-labels-for-woocommerce' ),
'_no_price' => __( 'Empty price', 'add-to-cart-button-labels-for-woocommerce' ),
'_in_cart' => __( 'Already in cart', 'add-to-cart-button-labels-for-woocommerce' ),
);
$settings = array(
array(
'title' => __( 'Per Product Type Options', 'add-to-cart-button-labels-for-woocommerce' ),
'type' => 'title',
'desc' => __( 'This sections lets you set text for add to cart button for various products types and various conditions.', 'add-to-cart-button-labels-for-woocommerce' ),
'id' => 'alg_wc_add_to_cart_button_labels_per_product_options',
),
array(
'title' => __( 'Per Product Type & Condition Labels', 'add-to-cart-button-labels-for-woocommerce' ),
'desc' => '' . __( 'Enable section', 'add-to-cart-button-labels-for-woocommerce' ) . '',
'id' => 'alg_wc_add_to_cart_button_labels_per_product_type_enabled',
'default' => 'no',
'type' => 'checkbox',
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_add_to_cart_button_labels_per_product_options',
),
);
foreach ( $product_types as $product_type_id => $product_type_title ) {
$settings[] = array(
'title' => $product_type_title,
'type' => 'title',
'id' => 'alg_wc_add_to_cart_button_labels_per_product_' . $product_type_id . '_options',
);
foreach ( $conditions as $condition_id => $condition_desc ) {
foreach ( $views as $view_id => $view_desc ) {
if ( '' !== $this->get_default_label_value( $view_id, $product_type_id, $condition_id ) ) {
$settings[] = array(
'title' => $view_desc . ( '' != $condition_desc ? ': ' . $condition_desc : '' ),
'id' => 'alg_wc_add_to_cart_p_prod_type_on_' . $view_id . $condition_id . '_' . $product_type_id,
'desc_tip' => $this->get_desc_tip( $view_id, $product_type_id, $condition_id ),
'default' => '',
'type' => 'text',
'css' => 'width:100%;',
'desc' => ( '_on_sale' === $condition_id ? apply_filters( 'alg_wc_add_to_cart_button_labels', sprintf(
'You will need Add to Cart Button Labels for WooCommerce Pro plugin to set separate label for "On sale" condition.',
'https://wpfactory.com/item/add-to-cart-button-labels-woocommerce/' ), 'settings' ) : '' ),
'custom_attributes' => ( '_on_sale' === $condition_id ? apply_filters( 'alg_wc_add_to_cart_button_labels',
array( 'readonly' => 'readonly' ), 'settings' ) : '' ),
'alg_wc_atcbl_raw' => true,
);
}
}
}
$settings = array_merge( $settings, array(
array(
'type' => 'sectionend',
'id' => 'alg_wc_add_to_cart_button_labels_per_product_' . $product_type_id . '_options',
),
) );
}
return $settings;
}
}
endif;
return new Alg_WC_Add_To_Cart_Button_Labels_Settings_Per_Product_Type();