change_add_to_cart_button_text( $add_to_cart_text, 'single' ); } /** * change_add_to_cart_button_text_archive. * * @version 1.0.0 * @since 1.0.0 */ function change_add_to_cart_button_text_archive( $add_to_cart_text ) { return $this->change_add_to_cart_button_text( $add_to_cart_text, 'archive' ); } /** * change_add_to_cart_button_text. * * @version 1.0.0 * @since 1.0.0 */ function change_add_to_cart_button_text( $add_to_cart_text, $single_or_archive ) { $product_categories = get_the_terms( get_the_ID(), 'product_cat' ); if ( empty( $product_categories ) ) { return $add_to_cart_text; } for ( $i = 1; $i <= apply_filters( 'alg_wc_add_to_cart_button_labels', 1, 'value_per_category' ); $i++ ) { if ( 'yes' !== get_option( 'alg_wc_add_to_cart_per_category_enabled_group_' . $i, 'yes' ) ) { continue; } $categories = get_option( 'alg_wc_add_to_cart_per_category_ids_group_' . $i, '' ); if ( empty( $categories ) ) { continue; } foreach ( $product_categories as $product_category ) { foreach ( $categories as $category ) { if ( $product_category->term_id == $category ) { return get_option( 'alg_wc_add_to_cart_per_category_text_' . $single_or_archive . '_group_' . $i, '' ); } } } } return $add_to_cart_text; } } endif; return new Alg_WC_Add_To_Cart_Button_Labels_Per_Category();