Call calculate_shipping before validation

This commit is contained in:
Alex P 2023-02-03 10:35:38 +02:00
parent fddd6c35e9
commit d6bd403b5a
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -35,6 +35,9 @@ class CheckoutFormValidator extends WC_Checkout {
// And we must call get_posted_data because it handles the shipping address.
$data = $this->get_posted_data();
// Looks like without this WC()->shipping->get_packages() is empty which is used by some plugins.
WC()->cart->calculate_shipping();
// It throws some notices when checking fields etc., also from other plugins via hooks.
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
@$this->validate_checkout( $data, $errors );