Skip to content

Instantly share code, notes, and snippets.

@Bobz-zg
Created October 12, 2018 09:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Bobz-zg/5d1e6a6cfa4d465ed5f6f8ca09adc88f to your computer and use it in GitHub Desktop.
Save Bobz-zg/5d1e6a6cfa4d465ed5f6f8ca09adc88f to your computer and use it in GitHub Desktop.
Quickly unhook WooCommerce template parts
<?php
/**
* Remove variouse template parts in WooCommerce
*/
add_filter( 'wc_get_template', function( $located, $template_name, $args, $template_path, $default_path ) {
$remove = [
'sale-flash.php',
'meta.php',
'share.php',
'up-sells.php',
'quantity-input.php',
'simple.php',
'tabs.php',
'related.php',
'variable.php',
'variation-add-to-cart-button.php',
'add-to-cart.php',
'rating.php'
];
/**
* Add any additional condition here
* eg: in_array( basename($located), $remove ) || ! current_user_can('manage_options')
*/
if ( in_array( basename($located), $remove ) )
$located = false;
return $located;
}, 10, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment