Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Created August 23, 2022 11:27
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 Pebblo/724f8d94b1019b8209ad62a70eb728b8 to your computer and use it in GitHub Desktop.
Save Pebblo/724f8d94b1019b8209ad62a70eb728b8 to your computer and use it in GitHub Desktop.
Example of how to force promotions to only apply to a single event within the cart
<?php //Please do not include the opening PHP tag if you alreayd have one.
add_filter('FHEE__EED_Promotions__get_applicable_items__applicable_items', 'tw_ee_promotions_only_single_applicable_item', 10, 5);
function tw_ee_promotions_only_single_applicable_item(
$applicable_items,
$promotion,
$redeemable_scope_promos,
$events,
$cart
) {
if(stripos($promotion->code(), 'CART') !== false) {
$first_applicable_item[] = reset($applicable_items);
return $first_applicable_item;
}
return $applicable_items;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment