Created
July 16, 2020 11:40
-
-
Save jessepearson/bc07df936e4c2e1516a44ffdda0d4bf7 to your computer and use it in GitHub Desktop.
Allows for modifying the coupon that is created when AutomateWoo Refer A Friend is used.
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
<?php // do not copy this line | |
/** | |
* Allows for modifying the coupon that is created when AutomateWoo Refer A Friend is used. | |
* | |
* It works by modifying the coupon data that is used when creating the new coupon in the cart. The data that is | |
* able to be applied can be found here: https://github.com/woocommerce/woocommerce/blob/4.3.0/includes/class-wc-coupon.php#L26-L50 | |
* Any edits will make the automatically generated coupon behave like a coupon created under WooCommerce > Coupons. | |
* | |
* This example make it so that if either categories 24 or 25 are in the cart, the referral is then applied. | |
* | |
*/ | |
add_filter( 'automatewoo/referrals/store_credit/coupon_data', 'update_aw_referral_coupon_20200716' ); | |
function update_aw_referral_coupon_20200716( $data ) { | |
// Uncomment anything you'd like to use. | |
// $data['product_ids'] = []; | |
// $data['excluded_product_ids'] = []; | |
// $data['limit_usage_to_x_items'] = null; | |
$data['product_categories'] = [ 24, 25 ]; | |
// $data['excluded_product_categories'] = []; | |
// $data['exclude_sale_items'] = false; | |
// $data['maximum_amount'] = ''; | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can i extend the plugin to not use any prefix?