Chore: Moving Recovery Consent to Core

This commit is contained in:
2026-09-25 14:13:15 +03:00
parent 5bbf0aabcd
commit 7f6c1e6307
2 changed files with 8 additions and 39 deletions
@@ -75,7 +75,7 @@ public function update(string $locale, Request $request): RedirectResponse
$invoice = $request->boolean('invoice');
$customer = $this->account->updateProfile($user, [
$this->account->updateProfile($user, [
'first_name' => $data['first_name'] ?? null,
'last_name' => $data['last_name'] ?? null,
'company_name' => $invoice ? $data['company_name'] : null,
@@ -100,28 +100,20 @@ public function update(string $locale, Request $request): RedirectResponse
: $this->account->createAddress($user, $addressData);
}
$this->updateRecoveryConsent($customer, $request->boolean('recovery_consent'));
$this->updateRecoveryConsent($user, $request->boolean('recovery_consent'));
return redirect()->route('account')->with('status', __('storefront.account.saved'));
}
/**
* "Email me a reminder if I don't finish my order", as a standing choice.
* Stored on the customer in the same meta shape the checkout writes (see
* CheckoutController::rememberRecoveryConsent()), and applied to the
* "Email me a reminder if I don't finish my order", as a standing
* choice — stored on the customer via boboko-core's
* CustomerAccountService::setRecoveryConsent(), and applied to the
* current cart too, so opting out stops reminders for it right away.
*/
private function updateRecoveryConsent($customer, bool $consent): void
private function updateRecoveryConsent($user, bool $consent): void
{
if ((bool) data_get($customer, 'meta.recovery_consent') !== $consent) {
$customer->meta = [
...($customer->meta?->toArray() ?? []),
'recovery_consent' => $consent,
'recovery_consent_at' => $consent ? now()->toIso8601String() : null,
'recovery_consent_policy_version' => $consent ? config('legal.privacy_policy_version') : null,
];
$customer->save();
}
$this->account->setRecoveryConsent($user, $consent);
// Only an existing cart; never create one just to record this.
$cart = app(CartService::class)->current();