我尝试向 2000 年(不含增值税)以下的所有订单添加 105 美元(不含增值税)的费用。但是我的代码总是加费用,即使超过 2000。
/**
* Add custom fee to checkout section
*/
function woo_add_cart_fee() {
global $woocommerce;
if ( $woocommerce->cart->total <= 2000 ) {
$woocommerce->cart->add_fee( __( 'Administrative Fee' ), 105 , true, 'standard'); //Add tax on 105
}
}
add_action( 'woocommerce_cart_calculate_fees', 'woo_add_cart_fee' );
答案 0 :(得分:2)
使用 from PyQt4 import QtGui
from PyQt4 import QtCore
class MyAppGraphicView(QtGui.QGraphicsView):
def wheelEvent(self, event):
delta = 0.99 if event.delta() < 0 else 1.01
self.scale(delta, delta)
动作挂钩,您将获得 woocommerce_cart_calculate_fees
对象作为参数,因此您可以根据此检查购物车总数并使用该 $cart
对象,您可以使用 {{ 1}} 函数。
$cart
经过测试并有效。