Last active
November 22, 2021 02:34
-
-
Save NickGreen/ac11782aefdfbcb58cf48e87c9aace33 to your computer and use it in GitHub Desktop.
WooCommerce Subscriptions Gifting - turn off for specific products or tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wcsg_is_giftable_product', 'disable_gifting_by_product', 12, 2 ); | |
function disable_gifting_by_product( $is_sub, $product ) { | |
$not_giftable_products = array( 906, 964 ); // add or remove product IDs here | |
if ( in_array( $product->get_id(), $not_giftable_products ) ) { | |
return false; | |
} else { | |
return $is_sub; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wcsg_is_giftable_product', 'disable_gifting_by_tag', 12, 2 ); | |
function disable_gifting_by_tag( $is_sub, $product ) { | |
if ( has_term( 'abc', 'product_tag', $product ) ) { | |
return false; | |
} else { | |
return $is_sub; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment