Show prices in the shop currency (STRIPE_CURRENCY), not hard-coded EUR
formatPrice always formatted EUR, so the public shop, checkout, basket and order confirmation showed € even when Stripe charged another currency. It now takes a currency; both apps pass STRIPE_CURRENCY to the blocks as layout data `currency` (like `timezone`), so one setting drives what Stripe charges and every price shown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qq6FzyGitv5gDZEcCHDGoo
This commit is contained in:
parent
de8d29beb4
commit
e29eaaa8e8
9 changed files with 93 additions and 65 deletions
|
|
@ -2,7 +2,7 @@ import { defaultColors, defaultFooter, defaultHeader } from '$lib/types';
|
|||
import type { ItemRecord, SlotRecord } from '$lib/types';
|
||||
import { BASKET_COOKIE, getBasket } from '$lib/server/shop';
|
||||
import { loadShopData } from '$shared/server/shop';
|
||||
import { DEFAULT_TIMEZONE } from '$shared/calendar';
|
||||
import { DEFAULT_TIMEZONE, shopCurrency } from '$shared/calendar';
|
||||
import { env } from '$env/dynamic/private';
|
||||
import type { LayoutServerLoad } from './$types';
|
||||
|
||||
|
|
@ -44,6 +44,8 @@ export const load: LayoutServerLoad = async ({ locals, cookies, url }) => {
|
|||
|
||||
// Booking times are shown in the studio's timezone, wherever the visitor is.
|
||||
const timezone = env.SITE_TIMEZONE || DEFAULT_TIMEZONE;
|
||||
// Prices are shown in the currency Stripe charges in.
|
||||
const currency = shopCurrency(env.STRIPE_CURRENCY);
|
||||
|
||||
return { header, footer, colors, user: locals.user, basket, items, slots, timezone };
|
||||
return { header, footer, colors, user: locals.user, basket, items, slots, timezone, currency };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,12 +33,12 @@
|
|||
<div class="text-sm text-charcoal/60">{formatSlotDate(line.start)}</div>
|
||||
{/if}
|
||||
</div>
|
||||
<span>{formatPrice(line.price * line.quantity)}</span>
|
||||
<span>{formatPrice(line.price * line.quantity, data.currency)}</span>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
<div class="mt-4 flex justify-between border-t border-charcoal/10 pt-4 font-bold">
|
||||
<span>Total</span><span>{formatPrice(data.order.total)}</span>
|
||||
<span>Total</span><span>{formatPrice(data.order.total, data.currency)}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue