generated from boboko/starter
removed resetShippingManifest() workaround from CheckoutController
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user