id = 'per_category';
$this->desc = __( 'Per Category', 'add-to-cart-button-labels-for-woocommerce' );
parent::__construct();
}
/**
* get_settings.
*
* @version 1.2.0
* @since 1.0.0
*/
function get_settings() {
$product_categories_options = array();
$product_categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );
if ( ! empty( $product_categories ) && ! is_wp_error( $product_categories ) ) {
foreach ( $product_categories as $product_category ) {
$product_categories_options[ $product_category->term_id ] = $product_category->name;
}
}
$settings = array(
array(
'title' => __( 'Per Category Options', 'add-to-cart-button-labels-for-woocommerce' ),
'type' => 'title',
'desc' => __( 'This sections lets you set Add to Cart button text on per category basis.', 'add-to-cart-button-labels-for-woocommerce' ),
'id' => 'alg_wc_add_to_cart_button_labels_per_category_options',
),
array(
'title' => __( 'Per Category Labels', 'add-to-cart-button-labels-for-woocommerce' ),
'desc' => '' . __( 'Enable section', 'add-to-cart-button-labels-for-woocommerce' ) . '',
'desc_tip' => '',
'id' => 'alg_wc_add_to_cart_button_labels_per_category_enabled',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Category groups number', 'add-to-cart-button-labels-for-woocommerce' ),
'desc_tip' => __( 'Click "Save changes" after you change this number.', 'add-to-cart-button-labels-for-woocommerce' ),
'id' => 'alg_wc_add_to_cart_button_labels_per_category_total_number',
'default' => 1,
'type' => 'number',
'desc' => '' . apply_filters( 'alg_wc_add_to_cart_button_labels', sprintf(
'
You will need Add to Cart Button Labels for WooCommerce Pro plugin to add more than one category group.',
'https://wpfactory.com/item/add-to-cart-button-labels-woocommerce/' ), 'settings' ),
'custom_attributes' => apply_filters( 'alg_wc_add_to_cart_button_labels', array( 'step' => '1', 'min' => '1', 'max' => '1' ), 'settings_array' ),
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_add_to_cart_button_labels_per_category_options',
),
);
for ( $i = 1; $i <= apply_filters( 'alg_wc_add_to_cart_button_labels', 1, 'value_per_category' ); $i++ ) {
$settings = array_merge( $settings, array(
array(
'title' => __( 'Group', 'add-to-cart-button-labels-for-woocommerce' ) . ' #' . $i,
'type' => 'title',
'id' => 'alg_wc_add_to_cart_per_category_options_group_' . $i,
),
array(
'title' => __( 'Enable Group', 'add-to-cart-button-labels-for-woocommerce' ) . ' #' . $i,
'desc' => __( 'Enable', 'add-to-cart-button-labels-for-woocommerce' ),
'id' => 'alg_wc_add_to_cart_per_category_enabled_group_' . $i,
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Categories', 'add-to-cart-button-labels-for-woocommerce' ),
'id' => 'alg_wc_add_to_cart_per_category_ids_group_' . $i,
'default' => '',
'type' => 'multiselect',
'class' => 'chosen_select',
'options' => $product_categories_options,
),
array(
'title' => __( 'Button text - single product view', 'add-to-cart-button-labels-for-woocommerce' ),
'id' => 'alg_wc_add_to_cart_per_category_text_single_group_' . $i,
'default' => '',
'type' => 'text',
'css' => 'width:100%;',
'alg_wc_atcbl_raw' => true,
),
array(
'title' => __( 'Button text - product archive (category) view', 'add-to-cart-button-labels-for-woocommerce' ),
'id' => 'alg_wc_add_to_cart_per_category_text_archive_group_' . $i,
'default' => '',
'type' => 'text',
'css' => 'width:100%;',
'alg_wc_atcbl_raw' => true,
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_add_to_cart_per_category_options_group_' . $i,
),
) );
}
return $settings;
}
}
endif;
return new Alg_WC_Add_To_Cart_Button_Labels_Settings_Per_Category();