在WooCommerce中,我需要为特定支付网关应用自定义处理费 . 我从这里得到这段代码:How to Add Handling Fee to WooCommerce Checkout .
这是我的代码:
add_action( 'woocommerce_cart_calculate_fees','endo_handling_fee' );
function endo_handling_fee() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$fee = 5.00;
$woocommerce->cart->add_fee( 'Handling', $fee, true, 'standard' );
}
此功能为所有交易添加费用
是否可以调整此功能并使其仅适用于货到付款?
另一个问题是我希望这笔费用适用于购物车 . 可能吗?
我也欢迎任何替代方法 . 我知道类似的“支付网关费用”woo插件,但我负担不起 .
3 回答
您需要以下内容来刷新付款方式更改的结帐,以使其工作:
代码位于活动子主题(或活动主题)的function.php文件中 . 测试和工作 .
类似的答案:
Add a custom fee for a specific payment gateway in Woocommerce
Add a fee based on shipping method and payment method in Woocommerce
Percentage discount based on user role and payment method in Woocommerce
对于其他任何想要这样做的人,我想为银行转账(BACS)增加一笔费用,这是我使用的方法: