From d6bd403b5ad5c62c3c0bdaaad3bb9e310c076f87 Mon Sep 17 00:00:00 2001 From: Alex P Date: Fri, 3 Feb 2023 10:35:38 +0200 Subject: [PATCH] Call calculate_shipping before validation --- modules/ppcp-button/src/Validation/CheckoutFormValidator.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/ppcp-button/src/Validation/CheckoutFormValidator.php b/modules/ppcp-button/src/Validation/CheckoutFormValidator.php index fd686b953..a620a3010 100644 --- a/modules/ppcp-button/src/Validation/CheckoutFormValidator.php +++ b/modules/ppcp-button/src/Validation/CheckoutFormValidator.php @@ -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 );