WordPress: Cash on Delivery restrict to one country only
-
I am selling products to 4 countries; US, Canada, UK and France. I have enabled 2 checkout methods; Cash on Delivery (cod) and Paypal. I want to restrict cod to Canada only and hide from other countries. I have tried the below code but it makes cod disappear from all countries (including Canada).I know i am doing something wrong here, i am not an expert so need ur help. Thanks
/** * @snippet WooCommerce Disable Payment Gateway for a Specific Country */ function payment_gateway_disable_country( $available_gateways ) { global $woocommerce; if ( isset( $available_gateways['cod'] ) && $woocommerce->customer->get_country() <> 'France' ) { unset( $available_gateways['cod'] ); } else if ( isset( $available_gateways['cod'] ) && $woocommerce->customer->get_country() == 'France' ) { unset( $available_gateways['cod'] ); } return $available_gateways; } add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_country' );
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘WordPress: Cash on Delivery restrict to one country only’ is closed to new replies.