Created
May 4, 2018 02:51
-
-
Save james-allan/72ead768db9233f8313150a5a998bc3c to your computer and use it in GitHub Desktop.
Restrict the option to gift to specific products
This file contains 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
/** | |
* 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi James,
this code is not in my case. Has this been tested with the latest version of woocommerce & subscription plugins?