@eldrajs/theme-cli 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/package.json +3 -3
  3. package/template/.eldra/block-types.d.ts +1 -1
  4. package/template/.eldra/manifest.json +32 -2
  5. package/template/.eldra/previews.json +35 -35
  6. package/template/app/app.vue +15 -0
  7. package/template/app/composables/useStorefront.ts +7 -2
  8. package/template/app/plugins/eldra-storefront.ts +9 -0
  9. package/template/app/storefront/analytics.ts +15 -7
  10. package/template/app/storefront/cart.ts +228 -51
  11. package/template/app/storefront/commerce.ts +12 -2
  12. package/template/app/storefront/currency.ts +272 -0
  13. package/template/app/storefront/demo.ts +10 -2
  14. package/template/app/storefront/feedback.ts +3 -0
  15. package/template/app/storefront/gateway.ts +153 -35
  16. package/template/app/storefront/money.ts +6 -18
  17. package/template/app/storefront/structuredData.ts +16 -5
  18. package/template/app/storefront/toProductCard.ts +14 -14
  19. package/template/app/storefront/types.ts +13 -0
  20. package/template/app/storefront/volatile.ts +4 -0
  21. package/template/app/utils/seoInput.ts +4 -3
  22. package/template/blocks/announcement-bar/preview.png +0 -0
  23. package/template/blocks/article/preview.png +0 -0
  24. package/template/blocks/article-list/preview.png +0 -0
  25. package/template/blocks/breadcrumbs/preview.png +0 -0
  26. package/template/blocks/cart/Block.vue +41 -22
  27. package/template/blocks/cart/__tests__/Block.spec.ts +2 -3
  28. package/template/blocks/cart/__tests__/loadFailed.spec.ts +135 -0
  29. package/template/blocks/cart/__tests__/notSold.spec.ts +150 -0
  30. package/template/blocks/cart/parts/CartLines.vue +14 -2
  31. package/template/blocks/cart/parts/CheckoutButton.vue +45 -0
  32. package/template/blocks/cart/parts/LoadFailed.vue +37 -0
  33. package/template/blocks/cart/parts/NotSoldNotice.vue +74 -0
  34. package/template/blocks/cart/parts/Summary.vue +9 -21
  35. package/template/blocks/cart/parts/notSold.ts +19 -0
  36. package/template/blocks/cart/preview.png +0 -0
  37. package/template/blocks/collection-grid/Block.vue +15 -2
  38. package/template/blocks/collection-grid/__tests__/Block.spec.ts +14 -0
  39. package/template/blocks/collection-grid/preview.png +0 -0
  40. package/template/blocks/collection-header/preview.png +0 -0
  41. package/template/blocks/contact/preview.png +0 -0
  42. package/template/blocks/cta/preview.png +0 -0
  43. package/template/blocks/faq/preview.png +0 -0
  44. package/template/blocks/feature-grid/preview.png +0 -0
  45. package/template/blocks/footer/Block.vue +20 -45
  46. package/template/blocks/footer/preview.png +0 -0
  47. package/template/blocks/form/preview.png +0 -0
  48. package/template/blocks/gallery/preview.png +0 -0
  49. package/template/blocks/hero/preview.png +0 -0
  50. package/template/blocks/image/preview.png +0 -0
  51. package/template/blocks/logo-cloud/preview.png +0 -0
  52. package/template/blocks/navigation/Block.vue +39 -3
  53. package/template/blocks/navigation/preview.png +0 -0
  54. package/template/blocks/newsletter/preview.png +0 -0
  55. package/template/blocks/order-status/Block.vue +15 -6
  56. package/template/blocks/order-status/preview.png +0 -0
  57. package/template/blocks/pricing-table/preview.png +0 -0
  58. package/template/blocks/product-carousel/Block.vue +5 -2
  59. package/template/blocks/product-carousel/preview.png +0 -0
  60. package/template/blocks/product-detail/Block.vue +68 -10
  61. package/template/blocks/product-detail/__tests__/Block.spec.ts +190 -2
  62. package/template/blocks/product-detail/preview.png +0 -0
  63. package/template/blocks/quote/preview.png +0 -0
  64. package/template/blocks/rich-text/preview.png +0 -0
  65. package/template/blocks/search/Block.vue +8 -2
  66. package/template/blocks/search/TypeSection.vue +8 -2
  67. package/template/blocks/search/preview.png +0 -0
  68. package/template/blocks/search/results.ts +5 -2
  69. package/template/blocks/split-content/preview.png +0 -0
  70. package/template/blocks/stats/preview.png +0 -0
  71. package/template/blocks/tabs/preview.png +0 -0
  72. package/template/blocks/team/preview.png +0 -0
  73. package/template/blocks/testimonials/preview.png +0 -0
  74. package/template/blocks/timeline/preview.png +0 -0
  75. package/template/blocks/trust-strip/preview.png +0 -0
  76. package/template/blocks/video-embed/preview.png +0 -0
  77. package/template/blocks/wishlist/Block.vue +5 -1
  78. package/template/blocks/wishlist/preview.png +0 -0
  79. package/template/i18n/en-US.json +20 -3
  80. package/template/i18n/is-IS.json +20 -3
  81. package/template/test/currencyPicker.spec.ts +66 -0
  82. package/template/test/seoInput.spec.ts +22 -0
  83. package/template/test/storefront/analytics.spec.ts +15 -0
  84. package/template/test/storefront/cart.spec.ts +4 -4
  85. package/template/test/storefront/currency.spec.ts +549 -0
  86. package/template/test/storefront/currencyDefault.spec.ts +475 -0
  87. package/template/test/storefront/currencyStore.spec.ts +845 -0
  88. package/template/test/storefront/gateway.spec.ts +22 -0
  89. package/template/test/storefront/money.spec.ts +2 -8
  90. package/template/test/storefront/structuredData.spec.ts +45 -0
  91. package/template/test/storefront/toProductCard.spec.ts +1 -1
  92. package/template/test/storefront/volatile.spec.ts +11 -0
@@ -163,7 +163,8 @@ const {
163
163
  refreshing,
164
164
  } = useRevalidating({
165
165
  keys: () => productResult.revalidating.value,
166
- refreshing: () => productResult.loading.value && product.value !== null,
166
+ refreshing: () =>
167
+ (productResult.loading.value && product.value !== null) || storefront.currency.pending.value,
167
168
  });
168
169
 
169
170
  /**
@@ -257,7 +258,34 @@ const showRating = computed(
257
258
  const money = useMoney();
258
259
 
259
260
  const formattedPrice = computed(() =>
260
- product.value === null ? '' : money.format(product.value.price.amount)
261
+ product.value === null
262
+ ? ''
263
+ : money.format(product.value.price.amount, product.value.price.currency)
264
+ );
265
+
266
+ /** No price in the visitor's currency: shown, but not for sale until they shop in the default. */
267
+ const notSold = computed(() => product.value?.price.soldInCurrency === false);
268
+ const shopperCurrency = computed(() => storefront.currency.active.value ?? '');
269
+ const defaultCurrency = computed(() => storefront.currency.defaultCurrency ?? '');
270
+ const inDefault = computed(() => shopperCurrency.value === defaultCurrency.value);
271
+ // A read that failed keeps the last currency's answer on screen; only one made in this currency can say it is sold nowhere.
272
+ const readIn = ref(shopperCurrency.value);
273
+ watch(
274
+ () => productResult.data.value,
275
+ () => {
276
+ readIn.value = shopperCurrency.value;
277
+ }
278
+ );
279
+ // Every product has a price in the store's own currency, so only a default that is not it can lack one for real.
280
+ const notSoldAnywhere = computed(
281
+ () =>
282
+ notSold.value &&
283
+ inDefault.value &&
284
+ readIn.value === shopperCurrency.value &&
285
+ defaultCurrency.value !== storefront.currency.base
286
+ );
287
+ const cartWillSwitch = computed(
288
+ () => notSold.value && !notSoldAnywhere.value && storefront.cart.lines.value.length > 0
261
289
  );
262
290
 
263
291
  /** Spec States, Sale row: 'The saving badge ("Save $32") is calculated from the two prices, never
@@ -268,7 +296,7 @@ const saving = computed<string | null>(() => {
268
296
  if (price === undefined) return null;
269
297
  const compareAt = price.compareAt ?? null;
270
298
  if (compareAt === null || compareAt <= price.amount) return null;
271
- return money.format(roundMoney(compareAt - price.amount));
299
+ return money.format(roundMoney(compareAt - price.amount), price.currency);
272
300
  });
273
301
  const onSale = computed(() => saving.value !== null);
274
302
 
@@ -413,9 +441,13 @@ watch(
413
441
  * It costs nothing: before mount there is no cart request a visitor could have started, so the
414
442
  * gated value and the real one only ever differ on the render that must not use the real one.
415
443
  */
416
- const cartBusy = computed(() => mounted.value && storefront.cart.pending.value);
444
+ const cartBusy = computed(
445
+ () => mounted.value && (storefront.cart.pending.value || storefront.currency.pending.value)
446
+ );
417
447
 
418
448
  const addToCartLabel = computed(() => {
449
+ if (notSoldAnywhere.value) return t('currency.notSoldIn', { currency: defaultCurrency.value });
450
+ if (notSold.value) return t('currency.shopIn', { currency: defaultCurrency.value });
419
451
  if (soldOut.value) return t('product.notifyMe');
420
452
  if (isBackorder.value) return t('product.backorder');
421
453
  return t('product.addToCart', { price: formattedPrice.value });
@@ -501,6 +533,14 @@ watch(
501
533
  * refusal for stock flips its own stock line to sold out.
502
534
  */
503
535
  async function primaryAction(): Promise<void> {
536
+ if (notSold.value) {
537
+ if (notSoldAnywhere.value) return;
538
+ // Already in the default (its product read failed): read the product again.
539
+ if (inDefault.value) void productResult.refresh();
540
+ else storefront.currency.chooseBase();
541
+ return;
542
+ }
543
+ if (storefront.currency.pending.value) return;
504
544
  if (soldOut.value) {
505
545
  notifyOpen.value = true;
506
546
  return;
@@ -651,15 +691,22 @@ function tabValue(index: number): string {
651
691
  <h1 :id="titleId" :class="TITLE_CLASS">{{ product.title }}</h1>
652
692
 
653
693
  <div class="mt-2 flex flex-wrap items-center gap-x-4 gap-y-2">
694
+ <p v-if="notSold" class="text-text" data-eldra-not-sold>
695
+ {{ t('currency.notSoldInLong', { currency: shopperCurrency }) }}
696
+ </p>
654
697
  <Price
655
- :amount="money.minor(product.price.amount)"
698
+ v-else
699
+ :amount="money.minor(product.price.amount, product.price.currency)"
656
700
  :compare-at="
657
- product.price.compareAt == null ? null : money.minor(product.price.compareAt)
701
+ product.price.compareAt == null
702
+ ? null
703
+ : money.minor(product.price.compareAt, product.price.currency)
658
704
  "
705
+ :currency="product.price.currency"
659
706
  :revalidating="priceRevalidating"
660
707
  />
661
708
  <Badge
662
- v-if="saving"
709
+ v-if="saving && !notSold"
663
710
  variant="sale"
664
711
  :label="t('product.saving', { amount: saving })"
665
712
  />
@@ -734,7 +781,7 @@ function tabValue(index: number): string {
734
781
  </p>
735
782
 
736
783
  <FieldWrapper
737
- v-if="showQuantity && !soldOut"
784
+ v-if="showQuantity && !soldOut && !notSold"
738
785
  :label="t('product.quantity')"
739
786
  class="gap-2"
740
787
  >
@@ -754,6 +801,7 @@ function tabValue(index: number): string {
754
801
  size="lg"
755
802
  block
756
803
  :loading="cartBusy"
804
+ :disabled="notSoldAnywhere"
757
805
  :label="addToCartLabel"
758
806
  >
759
807
  <template v-if="soldOut" #leadingIcon>
@@ -777,6 +825,9 @@ function tabValue(index: number): string {
777
825
  </template>
778
826
  </Button>
779
827
  </div>
828
+ <p v-if="cartWillSwitch" class="text-muted text-body-sm -mt-2">
829
+ {{ t('currency.cartWillSwitch', { currency: defaultCurrency }) }}
830
+ </p>
780
831
  </form>
781
832
 
782
833
  <ul
@@ -822,7 +873,7 @@ function tabValue(index: number): string {
822
873
  </div>
823
874
 
824
875
  <StickyBuyBar
825
- v-if="stickyBarEnabled"
876
+ v-if="stickyBarEnabled && !notSold"
826
877
  :target="addToCartTarget"
827
878
  :title="product.title"
828
879
  :meta="
@@ -849,7 +900,14 @@ function tabValue(index: number): string {
849
900
  @submit="submitNotify"
850
901
  >
851
902
  <FieldWrapper :label="t('product.notifyEmail')" :error="notifyError ?? undefined">
852
- <Input v-model="notifyEmail" type="email" name="email" autocomplete="email" required />
903
+ <Input
904
+ v-model="notifyEmail"
905
+ type="email"
906
+ name="email"
907
+ autocomplete="email"
908
+ required
909
+ autofocus
910
+ />
853
911
  </FieldWrapper>
854
912
  <template #actions>
855
913
  <Button type="submit" variant="primary" :label="t('product.notifySubmit')">
@@ -1,10 +1,10 @@
1
1
  // @vitest-environment jsdom
2
2
  import { flushPromises, mount } from '@vue/test-utils';
3
- import { computed, defineComponent, h, nextTick, ref } from 'vue';
3
+ import { computed, defineComponent, h, nextTick, ref, watch } from 'vue';
4
4
  import { ELDRA_KEY, type EldraLocaleState } from '@eldrajs/theme-vue';
5
5
  import { EldraHttpError } from '@eldrajs/sdk';
6
6
  import { useToast, type ToastAction } from '@eldrajs/ui';
7
- import { afterEach, describe, expect, it } from 'vitest';
7
+ import { afterEach, describe, expect, it, vi } from 'vitest';
8
8
  import { axe } from '../../../test/support/axe';
9
9
  import { mountOptions } from '../../../test/support/mountBlock';
10
10
  import { createDemoStorefront } from '../../../app/storefront/demo';
@@ -1046,6 +1046,83 @@ describe('product-detail block', () => {
1046
1046
  expect(storefront.cart.lines.value[0]!.quantity).toBe(2);
1047
1047
  });
1048
1048
 
1049
+ it('offers the store currency in place of adding a product with no price in the chosen one', async () => {
1050
+ const storefront = storefrontWith({
1051
+ price: { amount: 96, compareAt: null, currency: 'USD', soldInCurrency: false },
1052
+ });
1053
+ storefront.currency.offered.value = ['USD', 'EUR'];
1054
+ storefront.currency.started.value = true;
1055
+ storefront.currency.choose('EUR');
1056
+ await vi.waitFor(() => expect(storefront.currency.active.value).toBe('EUR'));
1057
+ const wrapper = await mountReady(mock, { storefront });
1058
+
1059
+ expect(wrapper.get('[data-eldra-not-sold]').text()).toBe('Not available in EUR.');
1060
+ expect(addToCart(wrapper).attributes('disabled')).toBeUndefined();
1061
+ expect(addToCart(wrapper).text()).toBe('Shop in USD');
1062
+ expect(wrapper.find('[data-part="quantity"]').exists()).toBe(false);
1063
+ expect(await axe(wrapper.element)).toHaveNoViolations();
1064
+
1065
+ await wrapper.get('form').trigger('submit');
1066
+ await flushPromises();
1067
+ expect(storefront.cart.lines.value).toHaveLength(0);
1068
+ expect(storefront.currency.active.value).toBe('USD');
1069
+ });
1070
+
1071
+ it('4662896775: reads the product again when it is already in the store currency', async () => {
1072
+ const storefront = storefrontWith({
1073
+ price: { amount: 96, compareAt: null, currency: 'USD', soldInCurrency: false },
1074
+ });
1075
+ const refreshes: number[] = [];
1076
+ const product = storefront.catalog.product;
1077
+ storefront.catalog.product = (handle) => {
1078
+ const result = product(handle);
1079
+ return {
1080
+ ...result,
1081
+ refresh: async () => {
1082
+ refreshes.push(1);
1083
+ },
1084
+ };
1085
+ };
1086
+ storefront.currency.started.value = true;
1087
+ const wrapper = await mountReady(mock, { storefront });
1088
+ expect(storefront.currency.active.value).toBe('USD');
1089
+ await wrapper.get('form').trigger('submit');
1090
+ await flushPromises();
1091
+ expect(refreshes).toHaveLength(1);
1092
+ });
1093
+
1094
+ it('says the cart will switch when there is one', async () => {
1095
+ const storefront = storefrontWith({
1096
+ price: { amount: 96, compareAt: null, currency: 'USD', soldInCurrency: false },
1097
+ });
1098
+ storefront.currency.offered.value = ['USD', 'EUR'];
1099
+ storefront.currency.started.value = true;
1100
+ storefront.currency.choose('EUR');
1101
+ await vi.waitFor(() => expect(storefront.currency.active.value).toBe('EUR'));
1102
+ await storefront.cart.add({ productId: 'p', variantId: 'v', quantity: 1 });
1103
+ const wrapper = await mountReady(mock, { storefront });
1104
+ expect(wrapper.text()).toContain('Your cart will switch to USD.');
1105
+ });
1106
+
1107
+ it("holds Add to cart while the visitor's currency is still being applied", async () => {
1108
+ const storefront = storefrontWith();
1109
+ storefront.currency.offered.value = ['USD', 'EUR'];
1110
+ const wrapper = await mountReady(mock, { storefront });
1111
+ expect(storefront.currency.pending.value).toBe(true);
1112
+ await wrapper.get('form').trigger('submit');
1113
+ await flushPromises();
1114
+ expect(storefront.cart.lines.value).toHaveLength(0);
1115
+ expect(addToCart(wrapper).attributes('aria-busy')).toBe('true');
1116
+ });
1117
+
1118
+ it('formats the price in the currency it carries', async () => {
1119
+ const storefront = storefrontWith({
1120
+ price: { amount: 19.9, compareAt: null, currency: 'EUR' },
1121
+ });
1122
+ const wrapper = await mountReady(mock, { storefront });
1123
+ expect(addToCart(wrapper).text()).toContain('€19.90');
1124
+ });
1125
+
1049
1126
  it('toggles the wishlist button aria-pressed', async () => {
1050
1127
  const wrapper = await mountReady(mock);
1051
1128
  const button = wrapper.get('button[aria-pressed]');
@@ -1490,3 +1567,114 @@ describe('product-detail block', () => {
1490
1567
  });
1491
1568
  });
1492
1569
  });
1570
+
1571
+ describe('with the store currency turned off (WS-1399)', () => {
1572
+ function storefrontOffering(patch: Partial<StorefrontProduct>) {
1573
+ const source = createDemoStorefront({
1574
+ commerce: {
1575
+ currency: 'USD',
1576
+ taxInclusivePricing: false,
1577
+ defaultTaxRate: 0,
1578
+ currencies: ['EUR', 'GBP'],
1579
+ defaultCurrency: 'EUR',
1580
+ },
1581
+ });
1582
+ return {
1583
+ ...source,
1584
+ catalog: {
1585
+ ...source.catalog,
1586
+ product: (handle: Parameters<typeof source.catalog.product>[0]) => {
1587
+ const result = source.catalog.product(handle);
1588
+ return {
1589
+ ...result,
1590
+ data: computed(() => (result.data.value ? { ...result.data.value, ...patch } : null)),
1591
+ };
1592
+ },
1593
+ },
1594
+ } as ReturnType<typeof storefrontWith>;
1595
+ }
1596
+ const notSoldPrice = { amount: 96, compareAt: null, currency: 'USD', soldInCurrency: false };
1597
+
1598
+ it('offers the default currency, not the store currency, as the way out', async () => {
1599
+ const storefront = storefrontOffering({ price: notSoldPrice });
1600
+ storefront.currency.started.value = true;
1601
+ storefront.currency.choose('GBP');
1602
+ await vi.waitFor(() => expect(storefront.currency.active.value).toBe('GBP'));
1603
+ const wrapper = await mountReady(mock, { storefront });
1604
+
1605
+ expect(addToCart(wrapper).text()).toBe('Shop in EUR');
1606
+ await wrapper.get('form').trigger('submit');
1607
+ await flushPromises();
1608
+ expect(storefront.currency.active.value).toBe('EUR');
1609
+ });
1610
+
1611
+ it('shows no way out in the default currency, and holds the button', async () => {
1612
+ const storefront = storefrontOffering({ price: notSoldPrice });
1613
+ storefront.currency.started.value = true;
1614
+ const wrapper = await mountReady(mock, { storefront });
1615
+
1616
+ expect(storefront.currency.active.value).toBe('EUR');
1617
+ expect(wrapper.get('[data-eldra-not-sold]').text()).toBe('Not available in EUR.');
1618
+ expect(addToCart(wrapper).text()).toBe('Not available in EUR');
1619
+ expect(addToCart(wrapper).attributes('disabled')).toBeDefined();
1620
+ expect(wrapper.text()).not.toContain('Shop in');
1621
+ expect(await axe(wrapper.element)).toHaveNoViolations();
1622
+ });
1623
+ });
1624
+
1625
+ describe('a product read that failed after a currency change (WS-1399)', () => {
1626
+ it("does not take the last currency's availability for the new one", async () => {
1627
+ const source = createDemoStorefront({
1628
+ commerce: {
1629
+ currency: 'USD',
1630
+ taxInclusivePricing: false,
1631
+ defaultTaxRate: 0,
1632
+ currencies: ['EUR', 'GBP'],
1633
+ defaultCurrency: 'EUR',
1634
+ },
1635
+ });
1636
+ const refreshes: number[] = [];
1637
+ const storefront = {
1638
+ ...source,
1639
+ catalog: {
1640
+ ...source.catalog,
1641
+ product: (handle: Parameters<typeof source.catalog.product>[0]) => {
1642
+ const result = source.catalog.product(handle);
1643
+ const kept = ref<StorefrontProduct | null>(null);
1644
+ // The read in GBP answered; the one in EUR failed and left it on screen.
1645
+ watch(
1646
+ result.data,
1647
+ (loaded) => {
1648
+ if (loaded !== null && kept.value === null) {
1649
+ kept.value = {
1650
+ ...loaded,
1651
+ price: { amount: 96, compareAt: null, currency: 'USD', soldInCurrency: false },
1652
+ };
1653
+ }
1654
+ },
1655
+ { immediate: true }
1656
+ );
1657
+ return {
1658
+ ...result,
1659
+ data: kept,
1660
+ refresh: async () => {
1661
+ refreshes.push(1);
1662
+ },
1663
+ };
1664
+ },
1665
+ },
1666
+ } as ReturnType<typeof storefrontWith>;
1667
+ storefront.currency.started.value = true;
1668
+ storefront.currency.choose('GBP');
1669
+ await vi.waitFor(() => expect(storefront.currency.active.value).toBe('GBP'));
1670
+ const wrapper = await mountReady(mock, { storefront });
1671
+
1672
+ storefront.currency.choose('EUR');
1673
+ await flushPromises();
1674
+ expect(storefront.currency.active.value).toBe('EUR');
1675
+ expect(addToCart(wrapper).attributes('disabled')).toBeUndefined();
1676
+ await wrapper.get('form').trigger('submit');
1677
+ await flushPromises();
1678
+ expect(refreshes).toHaveLength(1);
1679
+ });
1680
+ });
Binary file
@@ -275,6 +275,7 @@ const isLoading = computed(() => response.value === null && searchResult.loading
275
275
  /** The store's currency and the page's locale, for the suggestion prices below and the
276
276
  * `<ProductCard>`s the no-results state renders (`money.minor`). */
277
277
  const money = useMoney();
278
+ const shopperCurrency = useStorefront().currency.active;
278
279
 
279
280
  const barResults = computed(() =>
280
281
  toSearchBarResults(response.value, suggestionsPerGroup.value, money.format)
@@ -289,7 +290,11 @@ const barResults = computed(() =>
289
290
  * would head a tab "Products (3)" over a grid showing fewer, or, when the pricing read failed, none.
290
291
  */
291
292
  const productCards = computed(() =>
292
- toProductCardEntries(response.value?.products ?? [], { ratio: '4x5', minorUnits: money.minor })
293
+ toProductCardEntries(response.value?.products ?? [], {
294
+ ratio: '4x5',
295
+ minorUnits: money.minor,
296
+ shopperCurrency: shopperCurrency.value,
297
+ })
293
298
  );
294
299
 
295
300
  function countFor(type: ResultTypeId): number {
@@ -380,6 +385,7 @@ const noResultsProducts = computed(() =>
380
385
  toProductCardEntries((noResultsCollection.data.value?.items ?? []).slice(0, 4), {
381
386
  ratio: '4x5',
382
387
  minorUnits: money.minor,
388
+ shopperCurrency: shopperCurrency.value,
383
389
  })
384
390
  );
385
391
  const hasNoResultsProducts = computed(() => noResultsProducts.value.length > 0);
@@ -500,7 +506,7 @@ const headingClass =
500
506
  ratio="4x5"
501
507
  :heading-level="2"
502
508
  :link-as="entry.internal ? EldraRouterLink : undefined"
503
- :currency="currency"
509
+ :currency="entry.currency ?? currency"
504
510
  :locale="locale"
505
511
  />
506
512
  </div>
@@ -13,6 +13,7 @@ import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
13
13
  import { isInternalHref, safeHref } from '../../app/utils/links';
14
14
  import { toProductCardEntries } from '../../app/storefront/toProductCard';
15
15
  import { useMoney } from '../../app/storefront/money';
16
+ import { useStorefront } from '../../app/composables/useStorefront';
16
17
  import type { StorefrontSearchProduct, StorefrontSearchResponse } from '../../app/storefront/types';
17
18
 
18
19
  type ResultTypeId = 'products' | 'journal' | 'pages';
@@ -52,8 +53,13 @@ const props = defineProps<{
52
53
 
53
54
  /** See the `products` prop: sanitised, unusable rows dropped, `internal` per card. */
54
55
  const money = useMoney();
56
+ const shopperCurrency = useStorefront().currency.active;
55
57
  const productCards = computed(() =>
56
- toProductCardEntries(props.products, { ratio: '4x5', minorUnits: money.minor })
58
+ toProductCardEntries(props.products, {
59
+ ratio: '4x5',
60
+ minorUnits: money.minor,
61
+ shopperCurrency: shopperCurrency.value,
62
+ })
57
63
  );
58
64
 
59
65
  /** The journal rows that have a usable link, with the sanitised href and whether it routes. */
@@ -97,7 +103,7 @@ const JOURNAL_GRID_CLASS = 'grid grid-cols-1 gap-6 @tablet:grid-cols-3 @tablet:g
97
103
  ratio="4x5"
98
104
  :heading-level="3"
99
105
  :link-as="entry.internal ? EldraRouterLink : undefined"
100
- :currency="currency"
106
+ :currency="entry.currency ?? currency"
101
107
  :locale="locale"
102
108
  />
103
109
  </div>
Binary file
@@ -45,7 +45,7 @@ function rankProducts(products: StorefrontSearchProduct[]): StorefrontSearchProd
45
45
  export function toSearchBarResults(
46
46
  response: StorefrontSearchResponse | null,
47
47
  suggestionsPerGroup: number,
48
- formatPrice: (amount: number) => string
48
+ formatPrice: (amount: number, currency?: string) => string
49
49
  ): SearchResults | undefined {
50
50
  if (response === null) return undefined;
51
51
 
@@ -58,7 +58,10 @@ export function toSearchBarResults(
58
58
  // `SearchResultItem.price` is optional, so a product this storefront could not price keeps its
59
59
  // row and loses only the price. Formatting a `null` as a number would print the store's own
60
60
  // "$0.00" — a real price, and the wrong one (`StorefrontSearchProduct`).
61
- price: product.price === null ? undefined : formatPrice(product.price.amount),
61
+ price:
62
+ product.price === null || product.price.soldInCurrency === false
63
+ ? undefined
64
+ : formatPrice(product.price.amount, product.price.currency),
62
65
  image: product.featuredImage?.src,
63
66
  imageAlt: product.featuredImage?.alt,
64
67
  }));
Binary file
Binary file
Binary file
@@ -67,6 +67,7 @@ const storefront = useStorefront();
67
67
  /** Hydrated in `onMounted`, never before — see the module comment. */
68
68
  const wishlist = useWishlist();
69
69
  const money = useMoney();
70
+ const shopperCurrency = useStorefront().currency.active;
70
71
  const resolveLink = useEldraLink();
71
72
 
72
73
  const headingId = `wishlist-heading-${useUiId()}`;
@@ -166,13 +167,15 @@ const products = computed<StorefrontProductListItem[]>(() =>
166
167
  * own doc comment has the reasoning, and it is the same one the gate on the wishlist has. */
167
168
  const { any: cardsRevalidating, refreshing } = useRevalidating({
168
169
  keys: () => result.revalidating.value,
169
- refreshing: () => result.loading.value && result.data.value !== null,
170
+ refreshing: () =>
171
+ (result.loading.value && result.data.value !== null) || storefront.currency.pending.value,
170
172
  });
171
173
 
172
174
  const cards = computed(() =>
173
175
  toProductCardEntries(products.value, {
174
176
  ratio: '4x5',
175
177
  minorUnits: money.minor,
178
+ shopperCurrency: shopperCurrency.value,
176
179
  revalidating: cardsRevalidating.value,
177
180
  })
178
181
  );
@@ -305,6 +308,7 @@ async function removeCard(handle: string): Promise<void> {
305
308
  the product page, and the one control this card owns is the heart. -->
306
309
  <ProductCard
307
310
  :product="entry.product"
311
+ :currency="entry.currency"
308
312
  ratio="4x5"
309
313
  :heading-level="2"
310
314
  :quick-add="false"
@@ -95,6 +95,7 @@
95
95
  "outOfStock": "This item is out of stock.",
96
96
  "unavailable": "This item is no longer available.",
97
97
  "cartOutOfDate": "Your cart is out of date. Reload the page and try again.",
98
+ "businessOwnCurrency": "Business customers shop in ISK.",
98
99
  "unresolvedCollectionLabel": "Publish to load products",
99
100
  "unresolvedCollectionHelp": "The collection is picked. Its products appear here once this page is published.",
100
101
  "orderStatus": {
@@ -124,7 +125,8 @@
124
125
  "wishlistOne": "Wishlist, 1 item",
125
126
  "wishlistMany": "Wishlist, {count} items",
126
127
  "viewAll": "View all",
127
- "viewAllOf": "View all {label}"
128
+ "viewAllOf": "View all {label}",
129
+ "cart": "Cart"
128
130
  },
129
131
  "editor": {
130
132
  "addLink": "Add a link"
@@ -502,7 +504,9 @@
502
504
  "emptyFallbackTitle": "Your cart is empty",
503
505
  "drawerHintLabel": "The cart drawer opens from the header",
504
506
  "drawerHintHelp": "Shoppers open it with the bag button; nothing shows here until they do.",
505
- "drawerHintHosted": "The theme already opens one on every page, so this block adds nothing and can be removed."
507
+ "drawerHintHosted": "The theme already opens one on every page, so this block adds nothing and can be removed.",
508
+ "loadFailed": "We couldn't load your cart.",
509
+ "tryAgain": "Try again"
506
510
  },
507
511
  "wishlist": {
508
512
  "saved": "Saved to wishlist",
@@ -547,6 +551,18 @@
547
551
  "trackingNumber": "Tracking number",
548
552
  "carrierEta": "Estimated delivery {eta} with {carrier}."
549
553
  },
554
+ "currency": {
555
+ "label": "Currency",
556
+ "notSoldIn": "Not available in {currency}",
557
+ "notSoldInLong": "Not available in {currency}.",
558
+ "shopIn": "Shop in {currency}",
559
+ "cartNotSold": "{items} can't be bought in {currency}.",
560
+ "checkoutWithout": "Remove and check out",
561
+ "cartWillSwitch": "Your cart will switch to {currency}.",
562
+ "notIncludedOne": "1 item not included",
563
+ "notIncludedMany": "{count} items not included",
564
+ "movedTo": "Prices are now in {currency}."
565
+ },
550
566
  "ui": {
551
567
  "clear": "Clear",
552
568
  "close": "Close",
@@ -628,6 +644,7 @@
628
644
  "filterPanelMin": "Min",
629
645
  "filterPanelMax": "Max",
630
646
  "filterPanelOrMore": " or more",
631
- "filterPanelShowProducts": "Show products"
647
+ "filterPanelShowProducts": "Show products",
648
+ "currencyPickerLabel": "Currency"
632
649
  }
633
650
  }
@@ -95,6 +95,7 @@
95
95
  "outOfStock": "Þessi vara er ekki til á lager.",
96
96
  "unavailable": "Þessi vara er ekki lengur í boði.",
97
97
  "cartOutOfDate": "Karfan þín er ekki uppfærð. Endurnýjaðu síðuna og prófaðu aftur.",
98
+ "businessOwnCurrency": "Fyrirtæki versla í krónum.",
98
99
  "unresolvedCollectionLabel": "Birtu síðuna til að hlaða vörum",
99
100
  "unresolvedCollectionHelp": "Vörulistinn er valinn. Vörurnar úr honum birtast hér þegar síðan hefur verið birt.",
100
101
  "orderStatus": {
@@ -124,7 +125,8 @@
124
125
  "wishlistOne": "Óskalisti, 1 vara",
125
126
  "wishlistMany": "Óskalisti, {count} vörur",
126
127
  "viewAll": "Sjá allt",
127
- "viewAllOf": "Sjá allt: {label}"
128
+ "viewAllOf": "Sjá allt: {label}",
129
+ "cart": "Karfa"
128
130
  },
129
131
  "editor": {
130
132
  "addLink": "Bæta við tengli"
@@ -502,7 +504,9 @@
502
504
  "emptyFallbackTitle": "Karfan þín er tóm",
503
505
  "drawerHintLabel": "Karfan opnast úr hausnum",
504
506
  "drawerHintHelp": "Kaupendur opna hana með töskuhnappnum; hér sést ekkert fyrr en þeir gera það.",
505
- "drawerHintHosted": "Þemað opnar hana þegar á öllum síðum, svo þessi hluti gerir ekkert og má fjarlægja."
507
+ "drawerHintHosted": "Þemað opnar hana þegar á öllum síðum, svo þessi hluti gerir ekkert og má fjarlægja.",
508
+ "loadFailed": "Ekki tókst að sækja körfuna.",
509
+ "tryAgain": "Reyna aftur"
506
510
  },
507
511
  "wishlist": {
508
512
  "saved": "Vistað á óskalista",
@@ -547,6 +551,18 @@
547
551
  "trackingNumber": "Sendingarnúmer",
548
552
  "carrierEta": "Áætlaður afhendingartími {eta} með {carrier}."
549
553
  },
554
+ "currency": {
555
+ "label": "Gjaldmiðill",
556
+ "notSoldIn": "Ekki til sölu í {currency}",
557
+ "notSoldInLong": "Ekki til sölu í {currency}.",
558
+ "shopIn": "Skipta yfir í {currency}",
559
+ "cartNotSold": "Þetta fæst ekki keypt í {currency}: {items}.",
560
+ "checkoutWithout": "Fjarlægja og ganga frá kaupum",
561
+ "cartWillSwitch": "Karfan færist yfir í {currency}.",
562
+ "notIncludedOne": "1 vara ekki talin með",
563
+ "notIncludedMany": "{count} vörur ekki taldar með",
564
+ "movedTo": "Verð eru nú í {currency}."
565
+ },
550
566
  "ui": {
551
567
  "clear": "Hreinsa",
552
568
  "close": "Loka",
@@ -628,6 +644,7 @@
628
644
  "filterPanelMin": "Lágm.",
629
645
  "filterPanelMax": "Hám.",
630
646
  "filterPanelOrMore": " eða meira",
631
- "filterPanelShowProducts": "Sýna vörur"
647
+ "filterPanelShowProducts": "Sýna vörur",
648
+ "currencyPickerLabel": "Gjaldmiðill"
632
649
  }
633
650
  }