• Resolved redlaw03

    (@aetas03)


    Hi

    I created a code that adds a button below product short description. I added the code in functions.php. But I don’t want to include two of my products with this code. Is there a way to exclude products via product id/sku or something. Please see code:

    add_action( 'woocommerce_single_product_summary', 'return_policy', 20 );
     
    function return_policy() {
    	echo do_shortcode('[wcm_nonmember][maxbutton id="5"][/wcm_nonmember]');
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    
    add_action( 'woocommerce_single_product_summary', 'custom_return_policy_button', 20 );
     
    function custom_return_policy_button() {
    	global $product;
    
    	if ( ! in_array( $product->get_id(), array( 29, 35, 73 ) ) ) {
    		echo do_shortcode('[wcm_nonmember][maxbutton id="5"][/wcm_nonmember]');
    	}
    }
    

    Add your special product IDs to the array list of numbers.

    Thread Starter redlaw03

    (@aetas03)

    Sorry for the late reply. Thanks Caleb

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to exclude products from code added to functions.php’ is closed to new replies.