Change shipping based on payment
-
Hello, for most customers, going through the shipping step first, makes sense. However, we need to force customers who choose cheque as the payment method to only be able to choose local pickup as their shipping method. With the regular checkout, we used this code:
add_action('woocommerce_review_order_before_shipping', 'show_check_for_local_pickup_only', 100, 2); function show_check_for_local_pickup_only() { add_filter( 'woocommerce_available_payment_gateways', 'dwd_enable_checks_local_pickup' ); function dwd_enable_checks_local_pickup( $available_gateways ) { if ( ! is_admin() ) { $chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); $chosen_shipping = $chosen_methods[0]; if ( isset( $available_gateways['cheque'] ) && 0 === strpos( $chosen_shipping, 'local_pickup' ) ) { isset( $available_gateways['cheque'] ); } else { unset( $available_gateways['cheque'] ); } } return $available_gateways; } }
However, that no longer works when it is in steps. Is there a way to force them to choose the shipping method again if they choose cheque as the payment method?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Change shipping based on payment’ is closed to new replies.