php – 折扣后的Woocommerce价格
发布时间:2020-12-13 21:51:20 所属栏目:PHP教程 来源:网络整理
导读:我不是WooCommerce的专家,我无法找到如何显示从优惠券计算折扣的价格. 此代码,优惠券后显示价格,但也与运费价格 – 我不想要的,我想在折扣后,运输和税前显示价格: $woocommerce-cart-get_cart_total(); 此代码显示最终价格,没有折扣,也没有发货: $woocomme
我不是WooCommerce的专家,我无法找到如何显示从优惠券计算折扣的价格.
此代码,优惠券后显示价格,但也与运费价格 – 我不想要的,我想在折扣后,运输和税前显示价格: $woocommerce->cart->get_cart_total(); 此代码显示最终价格,没有折扣,也没有发货: $woocommerce->cart->get_cart_subtotal(); 所以我尝试了类似的东西来获得折扣后的价格: <?php $totalp = $woocommerce->cart->get_cart_subtotal(); $totaldisc = $woocommerce->cart->get_total_discount(); $resultp = $totalp - $totaldisc; echo ($resultp); ?> 但它显示“0”数字. 所以,我想有什么我想要的简单功能(我想在折扣后,在发货前得到总购物车价格),但我无法找到这个功能. 解决方法
答:我需要使用没有符号的int或浮点数,最好的方法是在这里查看WooCommerce文档:
Woo – Docs,并搜索此变量并使用它而不用()(不是函数).现在它工作:) <?php $first_number = $woocommerce->cart->subtotal; $second_number = $woocommerce->cart->discount_total; $sum_total = $first_number - $second_number; print ($sum_total); ?> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |