Nik*_*hil 5 wordpress woocommerce
在这个woocommerce设置中,我有2种付款方式,Paypal和货到付款.
现在,如何仅为某些邮政编码隐藏/禁用货到付款.
这是我在Gist上找到的代码
// Disable gateway based on country
function payment_gateway_disable_country( $available_gateways ) {
global $woocommerce;
if ( isset( $available_gateways['ccavenue'] ) && $woocommerce->customer->get_country() <> 'IN' ) {
unset( $available_gateways['ccavenue'] );
} else if ( isset( $available_gateways['paypal'] ) && $woocommerce->customer->get_country() == 'IN' ) {
unset( $available_gateways['paypal'] );
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_country' );
Run Code Online (Sandbox Code Playgroud)
要禁用/隐藏"货到付款",请将此代码放在主题的function.php中.
有关更多详细信息:woocommerce-hide-payment-gatway-based-on-visitor-country
// Disable gateway based on country
function payment_gateway_disable_country( $available_gateways ) {
global $woocommerce;
if ( isset( $available_gateways['cod'] ) && $woocommerce->customer->get_country() <> 'IN' ) {
unset( $available_gateways['cod'] );
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_country' );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14427 次 |
| 最近记录: |