fix: loyalty storefront and store card detail — enrollment, context, and Alpine.js
Some checks failed
Some checks failed
- Fix storefront enabled_modules always empty (page_context overwrote computed
set with empty default via extra_context)
- Fix storefront loyalty JS using store's data() instead of shopLayoutData()
- Remove defer from storefront loyalty scripts to prevent Alpine race condition
- Fix enrollment field name mismatch (customer_email → email) in both store
and storefront JS
- Add self-enrollment customer creation (resolve_customer_id with
create_if_missing) including hashed_password and customer_number
- Fix card list showing "Unknown" — add customer_name/email to CardResponse
- Add GET /cards/{card_id} detail endpoint for store card detail page
- Fix enroll-success.html using data() instead of shopLayoutData()
- Fix enrollment redirect reading response.card_number instead of
response.card.card_number
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
function customerLoyaltyEnroll() {
|
||||
return {
|
||||
...data(),
|
||||
...shopLayoutData(),
|
||||
|
||||
// Program info
|
||||
program: null,
|
||||
@@ -62,7 +62,7 @@ function customerLoyaltyEnroll() {
|
||||
|
||||
try {
|
||||
const response = await apiClient.post('/storefront/loyalty/enroll', {
|
||||
customer_email: this.form.email,
|
||||
email: this.form.email,
|
||||
customer_name: [this.form.first_name, this.form.last_name].filter(Boolean).join(' '),
|
||||
customer_phone: this.form.phone || null,
|
||||
customer_birthday: this.form.birthday || null,
|
||||
@@ -71,12 +71,13 @@ function customerLoyaltyEnroll() {
|
||||
});
|
||||
|
||||
if (response) {
|
||||
console.log('Enrollment successful:', response.card_number);
|
||||
const cardNumber = response.card?.card_number || response.card_number;
|
||||
console.log('Enrollment successful:', cardNumber);
|
||||
// Redirect to success page - extract base path from current URL
|
||||
// Current page is at /storefront/loyalty/join, redirect to /storefront/loyalty/join/success
|
||||
const currentPath = window.location.pathname;
|
||||
const successUrl = currentPath.replace(/\/join\/?$/, '/join/success') +
|
||||
'?card=' + encodeURIComponent(response.card_number);
|
||||
'?card=' + encodeURIComponent(cardNumber);
|
||||
window.location.href = successUrl;
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user