payment fix

This commit is contained in:
elvira
2026-09-15 15:04:40 +03:00
parent 279339a095
commit 1598f053ee
6 changed files with 48 additions and 13 deletions
@@ -62,7 +62,13 @@ public function show(string $locale): View
if ($cart?->shippingAddress) { if ($cart?->shippingAddress) {
$shippingOptions = $this->syncShipping($cart); $shippingOptions = $this->syncShipping($cart);
$cart->refresh();
// Cart's CachesProperties::refresh() explicitly nulls total/
// subTotal/shippingTotal/etc. back to their defaults — every
// Lunar call site pairs it with recalculate() for exactly that
// reason. Bare refresh() here was leaving $cart->total null on
// reload, which fed a 0 amount straight into the Stripe Element.
$cart->refresh()->recalculate();
} }
return view('checkout::page', [ return view('checkout::page', [
@@ -180,13 +186,22 @@ public function saveAddress(string $locale, Request $request): JsonResponse
$this->checkout->setRecoveryConsent($request->boolean('recovery_consent')); $this->checkout->setRecoveryConsent($request->boolean('recovery_consent'));
$rateKeyAfter = $cart->shippingAddress?->only(['postcode', 'state', 'country_id']); $rateKeyAfter = $cart->shippingAddress?->only(['postcode', 'state', 'country_id']);
$rateChanged = $rateKeyAfter != $rateKeyBefore;
// Nothing rate-relevant moved — persist and acknowledge, no re-render. // setShippingAddress() above always deletes and recreates the
if ($rateKeyAfter == $rateKeyBefore) { // CartAddress row (Lunar's AddAddress action), which drops whatever
// shipping_option was previously selected — regardless of whether the
// rate-determining fields actually changed. So this always has to run
// to restore/re-validate it, even on a save that only touched e.g. the
// phone number. Only the fragment RE-RENDER is skippable when nothing
// rate-relevant moved — the re-select itself is not optional.
$options = $this->syncShipping($cart);
if (! $rateChanged) {
return $this->fragments($cart, null, $errors); return $this->fragments($cart, null, $errors);
} }
return $this->fragments($cart, $this->syncShipping($cart), $errors); return $this->fragments($cart, $options, $errors);
} }
public function selectShippingOption(string $locale, Request $request): JsonResponse public function selectShippingOption(string $locale, Request $request): JsonResponse
Generated
+9 -9
View File
@@ -515,11 +515,11 @@
}, },
{ {
"name": "boboko/core", "name": "boboko/core",
"version": "0.16.3", "version": "0.17.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://code.radical-elements.com/boboko/core.git", "url": "https://code.radical-elements.com/boboko/core.git",
"reference": "8f4c1a22eace56f0e184b8a1e946252302d9baad" "reference": "57fc28ca0680841fddc222be4a5a936b43247883"
}, },
"require": { "require": {
"laravel/framework": "^12.0", "laravel/framework": "^12.0",
@@ -568,7 +568,7 @@
} }
}, },
"description": "Core module — authentication and shared panel behaviour", "description": "Core module — authentication and shared panel behaviour",
"time": "2026-09-09T21:14:57+00:00" "time": "2026-09-14T17:18:26+00:00"
}, },
{ {
"name": "brick/math", "name": "brick/math",
@@ -8802,16 +8802,16 @@
}, },
{ {
"name": "spatie/laravel-medialibrary", "name": "spatie/laravel-medialibrary",
"version": "11.23.7", "version": "11.23.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/spatie/laravel-medialibrary.git", "url": "https://github.com/spatie/laravel-medialibrary.git",
"reference": "94b11766ea5e10b1e2a88159b24937eae89a5d5f" "reference": "32bd3926b1065c4dc154789b9c6b17567acaaa15"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/94b11766ea5e10b1e2a88159b24937eae89a5d5f", "url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/32bd3926b1065c4dc154789b9c6b17567acaaa15",
"reference": "94b11766ea5e10b1e2a88159b24937eae89a5d5f", "reference": "32bd3926b1065c4dc154789b9c6b17567acaaa15",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -8896,7 +8896,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/spatie/laravel-medialibrary/issues", "issues": "https://github.com/spatie/laravel-medialibrary/issues",
"source": "https://github.com/spatie/laravel-medialibrary/tree/11.23.7" "source": "https://github.com/spatie/laravel-medialibrary/tree/11.23.8"
}, },
"funding": [ "funding": [
{ {
@@ -8908,7 +8908,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2026-09-03T13:52:57+00:00" "time": "2026-09-14T11:54:24+00:00"
}, },
{ {
"name": "spatie/laravel-package-tools", "name": "spatie/laravel-package-tools",
@@ -0,0 +1,3 @@
<p>Hi,</p>
<p>Your order <strong>{{ $reference }}</strong> is complete. Thanks for shopping with us!</p>
@@ -0,0 +1,3 @@
<p>Hi,</p>
<p>Your order <strong>{{ $reference }}</strong> is on its way.</p>
@@ -0,0 +1,3 @@
<p>Hi,</p>
<p>Your order <strong>{{ $reference }}</strong> is ready for pickup in store.</p>
@@ -0,0 +1,11 @@
<p>Hi,</p>
<p>Thanks for your order! Your order <strong>{{ $reference }}</strong> is confirmed.</p>
<ul>
@foreach ($lines as $line)
<li>{{ $line->quantity }} &times; {{ $line->description }} — {{ $line->total?->formatted }}</li>
@endforeach
</ul>
<p>Total: <strong>{{ $total }}</strong></p>