Skip to content

Instantly share code, notes, and snippets.

@nickstewart95
Last active July 15, 2022 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickstewart95/fed8c6bb011e7ccc34084f0270cb889e to your computer and use it in GitHub Desktop.
Save nickstewart95/fed8c6bb011e7ccc34084f0270cb889e to your computer and use it in GitHub Desktop.
add_filter(
'woocommerce_package_rates',
function ($rates) {
$customer = WC()->session->get('customer');
$address = !empty($customer['shipping_address_1'])
? urlencode($customer['shipping_address_1'])
: false;
$city = !empty($customer['shipping_city'])
? urlencode($customer['shipping_city'])
: false;
$state = !empty($customer['shipping_state'])
? urlencode($customer['shipping_state'])
: false;
if (!$address || !$city || !$state) {
return $rates;
}
return $rates;
},
10,
2,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment