我想限制买家通过BACS支付只有高价值的项目,例如超过99.我想出了以下代码,但它不隐藏卡支付.我不知道如果card
是正确的值在$available_gateways['card']
的WooPayments -信用卡/借记卡方法?
如何纠正?
函数.php
//////////// Restrict payment option to be BACS for high value items
add_filter('woocommerce_available_payment_gateways', 'restrict_bacs_for_high_value_items', 99, 1);
function restrict_bacs_for_high_value_items( $available_gateways ) {
global $product;
if ( is_admin() ) return $available_gateways; // Only on frontend
$product_price = round($product->price);
if ( isset($available_gateways['card']) && ($product_price > 99) ) {
unset($available_gateways['card']);
}
return $available_gateways;
}
字符串
1条答案
按热度按时间k5hmc34c1#
以下代码将仅在购物车中有高价值物品 (价格高达100的产品) 时将付款方式限制为BACS (银行电汇):
字符串
代码放在你的子主题的functions.php文件中(或插件中)。测试和工作。