我想限制买家只能通过BAC支付高价值的商品,例如超过99件.我想出了以下代码,但它并没有隐藏信用卡支付.对于WooPayments-信用卡/借记卡方法,我不确定$available_gateways['card']
中的card
值是否正确?
如何纠正?
functions.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;
}