Skip to content

Instantly share code, notes, and snippets.

@ibndawood
Created August 30, 2017 10:40
Show Gist options
  • Save ibndawood/77eb8aa019b5a0ca49f72e796f89ec2c to your computer and use it in GitHub Desktop.
Save ibndawood/77eb8aa019b5a0ca49f72e796f89ec2c to your computer and use it in GitHub Desktop.
Electro - Catalog mode show variation in single product page
function electro_template_single_add_to_cart() {
global $product;
$product_type = electro_wc_get_product_type( $product );
if( electro_get_shop_catalog_mode() == false ) {
do_action( 'woocommerce_' . $product_type . '_add_to_cart' );
} elseif( electro_get_shop_catalog_mode() == true && $product->is_type( 'external' ) ) {
do_action( 'woocommerce_' . $product_type . '_add_to_cart' );
} elseif( electro_get_shop_catalog_mode() == true && $product->is_type( 'variable' ) ) {
remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );
do_action( 'woocommerce_' . $product_type . '_add_to_cart' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment