Skip to content

Instantly share code, notes, and snippets.

@goranefbl
Created June 3, 2024 18:39
Show Gist options
  • Select an option

  • Save goranefbl/f4c21f796b37c40d110c9752a17a1195 to your computer and use it in GitHub Desktop.

Select an option

Save goranefbl/f4c21f796b37c40d110c9752a17a1195 to your computer and use it in GitHub Desktop.
Referral working with restricted coupons
<?php
add_filter('woocommerce_apply_with_individual_use_coupon', 'filter_apply_with_individual_use_coupon', 10, 4);
function filter_apply_with_individual_use_coupon($apply, $the_coupon, $applied_coupon, $applied_coupons) {
// Check if the coupon code starts with 'ref'
if (strpos($the_coupon->get_code(), 'ref') === 0) {
$apply = true;
}
return $apply;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment