如何基于购物车总额在WooCommerce中应用自动折扣? [英] How to apply an automatic discount in WooCommerce based on cart total?
本文介绍了如何基于购物车总额在WooCommerce中应用自动折扣?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
参考此问题如何在Woocommerce中以编程方式应用优惠券?
我正在寻找与第一篇文章中的最终解决方案非常相似的东西,但是如果小计> 99欧元,我希望可以使用优惠券.
I'm looking for something very similar to the final solution in the first post, but I'd like the coupon to be applied if the subtotal is > 99 euros.
您认为我如何修改代码?而且由于我是新手,我必须在哪里粘贴整个代码?
How do you think I can modify the code? And since I'm a newbie... where do I have to paste the whole code?
非常感谢
推荐答案
可以执行以下操作:
add_action('woocommerce_before_checkout_process','add_discount_at_checkout');
function add_discount_at_checkout(){
global $woocommerce;
$minorder = 99;
if( $woocommerce->cart->get_cart()->cart_contents_total>$minorder){
//APPLY COUPON HERE
}
}
因此,基本上,如果您的购物车总数大于99,则可以执行一些操作,例如添加优惠券.
So basically, if your cart total is greater than 99, you can do something, like add a coupon.
这篇关于如何基于购物车总额在WooCommerce中应用自动折扣?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文