Skip to content

Instantly share code, notes, and snippets.

@deivamagalhaes
Last active April 15, 2020 21:59
Show Gist options
  • Save deivamagalhaes/1d7a0652cd72ec4f1026d53f1c24e0ba to your computer and use it in GitHub Desktop.
Save deivamagalhaes/1d7a0652cd72ec4f1026d53f1c24e0ba to your computer and use it in GitHub Desktop.
Allows to sort the packing list excluding a given category tree
<?php
add_filter( 'woocommerce_get_product_terms', function ( $terms, $product_id, $taxonomy, $args ) {
if ( isset( $_GET['wc_pip_action'] ) && ! empty( $_GET['wc_pip_document'] ) && 'packing-list' == $_GET['wc_pip_document'] ) {
$terms = wp_get_post_terms( $product_id, $taxonomy, array(
'orderby' => 'parent',
'order' => 'DESC',
'exclude_tree' => '33',
) );
}
return $terms;
}, 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment