Skip to content

Instantly share code, notes, and snippets.

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 james-allan/72ead768db9233f8313150a5a998bc3c to your computer and use it in GitHub Desktop.
Save james-allan/72ead768db9233f8313150a5a998bc3c to your computer and use it in GitHub Desktop.
Restrict the option to gift to specific products
/**
* Plugin Name: WooCommerce Subscriptions Restrict Gifting to Products
* Description: Restrict the option to gift to specific products.
* Author: James Allan
* Version: 1.0
* License: GPL v2
*/
function wcsrgp_is_giftable_product( $is_giftable, $product ) {
$giftable_product_ids = array( 24, 12859, 11418 );
return in_array( $product->get_id() , $giftable_product_ids );
}
add_filter( 'wcsg_is_giftable_product', 'wcsrgp_is_giftable_product', 10, 2 );
@gagankhatri
Copy link

Hi James,
this code is not in my case. Has this been tested with the latest version of woocommerce & subscription plugins?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment