Skip to content

Instantly share code, notes, and snippets.

@GarySwift
Last active May 8, 2019 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GarySwift/4d997a57dd2142576aaf30195638baa7 to your computer and use it in GitHub Desktop.
Save GarySwift/4d997a57dd2142576aaf30195638baa7 to your computer and use it in GitHub Desktop.
Various WooCommerce helper functions.
<?php
/**
* WooCommerce compatibility
*
* Add this if you want to use the 'woocommerce.php' file.
*
* @link: https://github.com/olefredrik/FoundationPress/issues/982
*/
add_action( 'after_setup_theme', function() {
add_theme_support( 'woocommerce' );
} );
/**
* Changing Woocommerce CSS Structure
*
* Tell WooCommerce to not use the default woocommerce.css
* @link: https://docs.woocommerce.com/document/css-structure/
*/
// Remove each style one by one
add_filter( 'woocommerce_enqueue_styles', 'jk_dequeue_styles' );
function jk_dequeue_styles( $enqueue_styles ) {
unset( $enqueue_styles['woocommerce-general'] ); // Remove the gloss
unset( $enqueue_styles['woocommerce-layout'] ); // Remove the layout
unset( $enqueue_styles['woocommerce-smallscreen'] ); // Remove the smallscreen optimisation
return $enqueue_styles;
}
// Or just remove them all in one line
// add_filter( 'woocommerce_enqueue_styles', '__return_false' );
/**
* Hide the WooCommerce 'Add to Cart' button
*/
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment