removed resetShippingManifest() workaround from CheckoutController

This commit is contained in:
elvira
2026-09-14 16:30:45 +03:00
parent 2cac70c53a
commit 97c12efdb1
2 changed files with 26 additions and 53 deletions
@@ -13,7 +13,6 @@
use Lunar\Exceptions\Carts\CartException;
use Lunar\Exceptions\FingerprintMismatchException;
use Lunar\Facades\CartSession;
use Lunar\Facades\ShippingManifest;
use Lunar\Models\Cart;
use Lunar\Models\Country;
use Lunar\Models\Order;
@@ -62,7 +61,6 @@ public function show(string $locale): View
$shippingOptions = collect();
if ($cart?->shippingAddress) {
$this->resetShippingManifest($cart);
$shippingOptions = $this->syncShipping($cart);
$cart->refresh();
}
@@ -181,15 +179,6 @@ public function saveAddress(string $locale, Request $request): JsonResponse
// Deliberately its own scope, not merged with any future newsletter opt-in.
$this->checkout->setRecoveryConsent($request->boolean('recovery_consent'));
// ShippingManifest is a request-lifetime singleton whose getOptions()
// appends without ever clearing, and addOption() keeps the FIRST entry
// per identifier. The setBillingAddress() recalc above ran ApplyShipping
// against the still-stale shipping address, so an option resolved for
// the old region can shadow the correct one for the new region (a
// carrier priced differently across two matching zones). Reset it and
// recompute totals from a clean slate before we read anything back.
$this->resetShippingManifest($cart);
$rateKeyAfter = $cart->shippingAddress?->only(['postcode', 'state', 'country_id']);
// Nothing rate-relevant moved — persist and acknowledge, no re-render.
@@ -204,10 +193,6 @@ public function selectShippingOption(string $locale, Request $request): JsonResp
{
$identifier = (string) $request->input('shipping_option');
if ($cart = $this->cart->current()) {
$this->resetShippingManifest($cart);
}
try {
$this->checkout->selectShippingOption($identifier);
} catch (InvalidShippingOptionException) {
@@ -414,18 +399,6 @@ private function fragments(?Cart $cart, ?Collection $options, array $errors = []
]);
}
/**
* Wipe the request-lifetime ShippingManifest singleton and recompute the
* cart's totals, so both the options list and the cart's shippingTotal are
* resolved against the current address rather than an accumulation of
* every resolution that ran earlier in the request. See saveAddress().
*/
private function resetShippingManifest(Cart $cart): void
{
ShippingManifest::clearOptions();
$cart->calculate();
}
private function storeCountry(): ?Country
{
if (self::STORE_COUNTRY_ISO3 === null) {
Generated
+26 -26
View File
@@ -8,16 +8,16 @@
"packages": [
{
"name": "anourvalar/eloquent-serialize",
"version": "1.3.11",
"version": "1.3.12",
"source": {
"type": "git",
"url": "https://github.com/AnourValar/eloquent-serialize.git",
"reference": "abd890c4d1ad8e90dd454d01283fbf342f80f1e5"
"reference": "eb46e698efe7e20c311f1f93830111fcdcdabd96"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/AnourValar/eloquent-serialize/zipball/abd890c4d1ad8e90dd454d01283fbf342f80f1e5",
"reference": "abd890c4d1ad8e90dd454d01283fbf342f80f1e5",
"url": "https://api.github.com/repos/AnourValar/eloquent-serialize/zipball/eb46e698efe7e20c311f1f93830111fcdcdabd96",
"reference": "eb46e698efe7e20c311f1f93830111fcdcdabd96",
"shasum": ""
},
"require": {
@@ -67,9 +67,9 @@
],
"support": {
"issues": "https://github.com/AnourValar/eloquent-serialize/issues",
"source": "https://github.com/AnourValar/eloquent-serialize/tree/1.3.11"
"source": "https://github.com/AnourValar/eloquent-serialize/tree/1.3.12"
},
"time": "2026-08-07T06:14:19+00:00"
"time": "2026-09-13T06:25:37+00:00"
},
{
"name": "artesaos/seotools",
@@ -515,11 +515,11 @@
},
{
"name": "boboko/core",
"version": "0.16.0",
"version": "0.16.3",
"source": {
"type": "git",
"url": "https://code.radical-elements.com/boboko/core.git",
"reference": "359e1e262e6ab38fed99f25a0271c2d3b15ab999"
"reference": "8f4c1a22eace56f0e184b8a1e946252302d9baad"
},
"require": {
"laravel/framework": "^12.0",
@@ -568,7 +568,7 @@
}
},
"description": "Core module — authentication and shared panel behaviour",
"time": "2026-09-08T22:19:31+00:00"
"time": "2026-09-09T21:14:57+00:00"
},
{
"name": "brick/math",
@@ -5213,16 +5213,16 @@
},
{
"name": "nesbot/carbon",
"version": "3.13.2",
"version": "3.14.0",
"source": {
"type": "git",
"url": "https://github.com/CarbonPHP/carbon.git",
"reference": "a1c54919f5fff9800cd03c32bd01defd5a4061cb"
"reference": "0023eaa2c9110e47446dd512a263c69c40cd41f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/CarbonPHP/carbon/zipball/a1c54919f5fff9800cd03c32bd01defd5a4061cb",
"reference": "a1c54919f5fff9800cd03c32bd01defd5a4061cb",
"url": "https://api.github.com/repos/CarbonPHP/carbon/zipball/0023eaa2c9110e47446dd512a263c69c40cd41f2",
"reference": "0023eaa2c9110e47446dd512a263c69c40cd41f2",
"shasum": ""
},
"require": {
@@ -5314,7 +5314,7 @@
"type": "tidelift"
}
],
"time": "2026-08-08T11:40:35+00:00"
"time": "2026-09-12T20:45:19+00:00"
},
{
"name": "nette/php-generator",
@@ -5550,16 +5550,16 @@
},
{
"name": "nikic/php-parser",
"version": "v5.8.0",
"version": "v5.9.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "044a6a392ff8ad0d61f14370a5fbbd0a0107152f"
"reference": "9e33da9553fe7786f0962b35f4e4ecf01be89def"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/044a6a392ff8ad0d61f14370a5fbbd0a0107152f",
"reference": "044a6a392ff8ad0d61f14370a5fbbd0a0107152f",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/9e33da9553fe7786f0962b35f4e4ecf01be89def",
"reference": "9e33da9553fe7786f0962b35f4e4ecf01be89def",
"shasum": ""
},
"require": {
@@ -5601,9 +5601,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v5.8.0"
"source": "https://github.com/nikic/PHP-Parser/tree/v5.9.0"
},
"time": "2026-07-04T14:30:18+00:00"
"time": "2026-09-13T18:51:52+00:00"
},
{
"name": "nunomaduro/termwind",
@@ -12665,16 +12665,16 @@
},
{
"name": "technikermathe/blade-lucide-icons",
"version": "v3.177.0",
"version": "v3.179.0",
"source": {
"type": "git",
"url": "https://github.com/PascaleBeier/blade-lucide-icons.git",
"reference": "22f4340ac4798ac5fdbcbce96270669b6169fe23"
"reference": "bfae6d39e35bd78f72b7372a26a30b500687c923"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PascaleBeier/blade-lucide-icons/zipball/22f4340ac4798ac5fdbcbce96270669b6169fe23",
"reference": "22f4340ac4798ac5fdbcbce96270669b6169fe23",
"url": "https://api.github.com/repos/PascaleBeier/blade-lucide-icons/zipball/bfae6d39e35bd78f72b7372a26a30b500687c923",
"reference": "bfae6d39e35bd78f72b7372a26a30b500687c923",
"shasum": ""
},
"require": {
@@ -12724,9 +12724,9 @@
],
"support": {
"issues": "https://github.com/PascaleBeier/blade-lucide-icons/issues",
"source": "https://github.com/PascaleBeier/blade-lucide-icons/tree/v3.177.0"
"source": "https://github.com/PascaleBeier/blade-lucide-icons/tree/v3.179.0"
},
"time": "2026-09-09T02:07:13+00:00"
"time": "2026-09-12T02:06:59+00:00"
},
{
"name": "thecodingmachine/safe",