Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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 );

This comment has been minimized.

Copy link

@gagankhatri gagankhatri commented Jul 1, 2020

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