• Resolved Fernando Lopes

    (@fernandolopes)


    How can I leave the option of Product Variations and hide the Cart Button? I need variations because I’m using the plugin “YITH WooCommerce Request A Quote”.
    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Anthony Hortin

    (@ahortin)

    Hi Fernando,

    This should do the trick for you…

    
    function mytheme_show_product_variations(){
    	global $product;
    
    	if( is_user_logged_in() ) {
    		return;
    	}
    	else {
    		if( $product->is_type('variable') ) {
    			// Add the hook back in that was removed, when looking at Variations
    			add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
    
    			// Remove price on Variation
    			remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10);
    
    			// Remove Add to Cart on Variation
    			remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );
    		}
    	}
    
    }
    add_action( 'woocommerce_single_product_summary', 'mytheme_show_product_variations', 11 );
    

    This will remove the Price and the Add to Cart button, but leave the Variations dropdown

    Plugin Author Anthony Hortin

    (@ahortin)

    Just to let you know, I’ve updated the plugin so that the Variation dropdowns will now display for Variable products so you wont need the above code any longer.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Product Variations’ is closed to new replies.