Skip to content

Instantly share code, notes, and snippets.

@radist2s
Created May 23, 2019 08:54
Show Gist options
  • Save radist2s/5dfa0bb59fe24975dc2d055c1de71cd4 to your computer and use it in GitHub Desktop.
Save radist2s/5dfa0bb59fe24975dc2d055c1de71cd4 to your computer and use it in GitHub Desktop.
Fix WooCommerce chosen Shipping Method during Address/ZIP code change on Form Totals update
<?php
add_filter('woocommerce_shipping_chosen_method', function ($default, $rates = [], $chosen_method = null) {
$rates = $rates ? (array)$rates : [];
if ($chosen_method and isset($rates[(string)$chosen_method])) {
return $chosen_method;
}
return $default;
}, 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment