Skip to content

Instantly share code, notes, and snippets.

@iamsathyaseelan
Last active December 10, 2019 13:31
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 iamsathyaseelan/68fa9175d9b3cf19a2c44c70c03727dd to your computer and use it in GitHub Desktop.
Save iamsathyaseelan/68fa9175d9b3cf19a2c44c70c03727dd to your computer and use it in GitHub Desktop.
<?php
//Example:https://nimb.ws/PumFqI
if(!function_exists("rnoc_exit_intent_popup_condition_coupons")){
function rnoc_exit_intent_popup_condition_coupons($to_replace){
$cart_total = 0;
if(function_exists("WC")){
$cart_total = WC()->cart->total;
}
$coupon_code = "";
if($cart_total >100){
$coupon_code = "test1";
}elseif($cart_total >50){
$coupon_code = "test2";
}
if (!empty($coupon_code)) {
$coupon_data = '?rnoc_on_exit_coupon_code=' . $coupon_code;
$to_replace['coupon_code'] = $coupon_code;
$to_replace['checkout_url'] = wc_get_checkout_url().$coupon_data;
$to_replace['cart_url'] = wc_get_cart_url().$coupon_data;
}
return $to_replace;
}
}
add_filter("rnoc_exit_intent_popup_short_codes","rnoc_exit_intent_popup_condition_coupons");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment