检查是否有应用了优惠券的WooCommerce

时间:2019-09-10 12:25:53

标签: woocommerce apply access coupon

我正在根据以下主题通过AJAX提交优惠券代码:

Apply WooCommerce Coupon code to checkout

提交coupon后,我将重定向到另一个页面,并想echo是否应用了代码,因此我可以检查一切是否按计划进行。

基本上,我将此代码添加到了functions.php

if( WC()->cart->get_coupons() ) { 
    echo "There is an active coupon submitted";
}                   
else {
    echo "There isn't any active coupon submitted";
}

但是,如果输入错误的优惠券代码或没有输入优惠券代码,则无法导航至下一页。没错,但是在下一页上填写正确的优惠券代码后,它会打印"There isn't any active coupon submitted"。有人有这种可能性吗?

如果能回显在session中提交的代码,那将是最好的。

0 个答案:

没有答案