No longer able to get selected Shipping Method since 2.1 Update
-
The following code used to ensure the collection date field was completed if collection was selected as the shipping method.
add_action('woocommerce_after_checkout_validation', 'check_date_field', 20, 1); function check_date_field() { global $woocommerce; if ($posted['shipping_method'] == "local_pickup_plus") { if (!$_POST['collection_date']) $woocommerce->add_error( __('<strong>Collection Date</strong> is a required field.') ); return; $date = date_parse($_POST['collection_date']); if (!checkdate($date["month"], $date["day"], $date["year"])) $woocommerce->add_error('Please enter a valid date in the future for collection'); return; } }
Since updating to 2.1, it no longer works.
I’ve tried adding…$test = $posted['shipping_method']; $woocommerce->add_error( __('Selected shipping method is' . $test) );
The only text that is printed is “Selected shipping method is”.
This suggests the point in which I’m adding the action, the shipping method hasn’t yet been posted.Any assistance would be greatly appreciated.
- The topic ‘No longer able to get selected Shipping Method since 2.1 Update’ is closed to new replies.