@shoppexio/storefront-react 0.6.2 → 0.6.4
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.
- package/CHANGELOG.md +8 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.js +221 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.4
|
|
4
|
+
|
|
5
|
+
- Product: `formatSubscriptionRenewal(subscription, lang?)` reads in the page's locale (`<html lang>`, which the edge sets to the served locale; `lang` overrides it) with the Easy-lane buy boxes' words in all 16 locales, so a German page reads "Verlängert sich monatlich, bis du kündigst." instead of the English line. Unknown locales read English.
|
|
6
|
+
|
|
7
|
+
## 0.6.3
|
|
8
|
+
|
|
9
|
+
- Product: whether a subscription's buyer can switch plans is the selected option's answer. `StorefrontPriceVariant.planChangeOffered` reads each option's `plan_change_offered` (false when the backend does not send it), and `subscriptionForVariant` puts it on the subscription, so `formatSubscriptionRenewal` promises "Switch plans any time in your account." only for an option that has another plan to switch to (under "Upgrades only" the top plan has none). With no option selected the product's answer stands.
|
|
10
|
+
|
|
3
11
|
## 0.6.2
|
|
4
12
|
|
|
5
13
|
- Product: `formatSubscriptionRenewal(subscription)` gives the line under a subscription's buy buttons, "Renews every month until you cancel.", plus "Switch plans any time in your account." only when the catalog's `plan_change_offered` says the buyer can switch (the shop allows buyer plan changes and a second plan is offered); `ProductSubscription.planChangeOffered` carries it, false when the backend does not send the field. Empty for a plan without an interval.
|
package/dist/index.d.ts
CHANGED
|
@@ -1583,6 +1583,12 @@ interface StorefrontPriceVariant {
|
|
|
1583
1583
|
* with the product's (`subscriptionForVariant`).
|
|
1584
1584
|
*/
|
|
1585
1585
|
ownTrial: SubscriptionTrial | 'none' | null;
|
|
1586
|
+
/**
|
|
1587
|
+
* A buyer of this option can switch its plan in their account (the option's
|
|
1588
|
+
* `plan_change_offered`): under "Upgrades only" the top plan has nothing to
|
|
1589
|
+
* switch to. False when the wire does not say so.
|
|
1590
|
+
*/
|
|
1591
|
+
planChangeOffered: boolean;
|
|
1586
1592
|
}
|
|
1587
1593
|
interface VolumeDiscountRule {
|
|
1588
1594
|
quantity: number;
|
|
@@ -1809,9 +1815,10 @@ declare function formatSubscriptionCadence(subscription: ProductSubscription): s
|
|
|
1809
1815
|
/**
|
|
1810
1816
|
* The line under a subscription's buy buttons: "Renews every month until you cancel." and, when the
|
|
1811
1817
|
* producer says the buyer can switch plans, "Switch plans any time in your account." Empty for a plan
|
|
1812
|
-
* without an interval.
|
|
1818
|
+
* without an interval. In the page's locale (`lang` defaults to `<html lang>`), with the Easy-lane buy
|
|
1819
|
+
* boxes' words in every one.
|
|
1813
1820
|
*/
|
|
1814
|
-
declare function formatSubscriptionRenewal(subscription: ProductSubscription): string;
|
|
1821
|
+
declare function formatSubscriptionRenewal(subscription: ProductSubscription, lang?: string | null): string;
|
|
1815
1822
|
/**
|
|
1816
1823
|
* "7-day free trial" for a free trial, "$4.99 for 7 days" for a paid intro
|
|
1817
1824
|
* (`formatAmount` prints its price); empty when the plan has no trial.
|
|
@@ -1822,9 +1829,11 @@ declare function formatSubscriptionTrial(subscription: ProductSubscription, form
|
|
|
1822
1829
|
* interval (`billing_interval`, stored with its count or not at all) is charged
|
|
1823
1830
|
* at that cadence, every other one at the product's. An option with its own
|
|
1824
1831
|
* trial ("No trial" included) starts with it, every other one with the
|
|
1825
|
-
* product's: the rule checkout's `resolveProductTrial` applies.
|
|
1832
|
+
* product's: the rule checkout's `resolveProductTrial` applies. Whether the
|
|
1833
|
+
* buyer can switch plans is the option's own answer (`plan_change_offered`),
|
|
1834
|
+
* the rule the Easy-lane buy box applies.
|
|
1826
1835
|
*/
|
|
1827
|
-
declare function subscriptionForVariant(subscription: ProductSubscription, variant: Pick<StorefrontPriceVariant, 'billingInterval' | 'ownTrial'> | null | undefined): ProductSubscription;
|
|
1836
|
+
declare function subscriptionForVariant(subscription: ProductSubscription, variant: Pick<StorefrontPriceVariant, 'billingInterval' | 'ownTrial' | 'planChangeOffered'> | null | undefined): ProductSubscription;
|
|
1828
1837
|
/**
|
|
1829
1838
|
* What a product image shows, from the backend's pixel analysis. `art` is a
|
|
1830
1839
|
* cover, artwork or photo; `logo` is a flat mark, drawn on a contrasting plate.
|
package/dist/index.js
CHANGED
|
@@ -445,6 +445,210 @@ function buildStatusPageModel(products) {
|
|
|
445
445
|
return { entries, counts, presentStates, lastUpdatedAt };
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
+
// src/subscription-renewal-messages.ts
|
|
449
|
+
var SUBSCRIPTION_RENEWAL_MESSAGES = {
|
|
450
|
+
ar: {
|
|
451
|
+
renewsUntilCancel: "\u064A\u062A\u062C\u062F\u062F {interval} \u062D\u062A\u0649 \u062A\u0644\u063A\u064A\u0647.",
|
|
452
|
+
switchPlansInAccount: "\u064A\u0645\u0643\u0646\u0643 \u062A\u063A\u064A\u064A\u0631 \u0627\u0644\u062E\u0637\u0629 \u0641\u064A \u0623\u064A \u0648\u0642\u062A \u0645\u0646 \u062D\u0633\u0627\u0628\u0643.",
|
|
453
|
+
renewEveryDay: "\u0643\u0644 \u064A\u0648\u0645",
|
|
454
|
+
renewEveryDays: "\u0643\u0644 {count} \u064A\u0648\u0645",
|
|
455
|
+
renewEveryWeek: "\u0643\u0644 \u0623\u0633\u0628\u0648\u0639",
|
|
456
|
+
renewEveryWeeks: "\u0643\u0644 {count} \u0623\u0633\u0628\u0648\u0639",
|
|
457
|
+
renewEveryMonth: "\u0643\u0644 \u0634\u0647\u0631",
|
|
458
|
+
renewEveryMonths: "\u0643\u0644 {count} \u0634\u0647\u0631",
|
|
459
|
+
renewEveryYear: "\u0643\u0644 \u0633\u0646\u0629",
|
|
460
|
+
renewEveryYears: "\u0643\u0644 {count} \u0633\u0646\u0629"
|
|
461
|
+
},
|
|
462
|
+
de: {
|
|
463
|
+
renewsUntilCancel: "Verl\xE4ngert sich {interval}, bis du k\xFCndigst.",
|
|
464
|
+
switchPlansInAccount: "Du kannst den Plan jederzeit in deinem Konto wechseln.",
|
|
465
|
+
renewEveryDay: "t\xE4glich",
|
|
466
|
+
renewEveryDays: "alle {count} Tage",
|
|
467
|
+
renewEveryWeek: "w\xF6chentlich",
|
|
468
|
+
renewEveryWeeks: "alle {count} Wochen",
|
|
469
|
+
renewEveryMonth: "monatlich",
|
|
470
|
+
renewEveryMonths: "alle {count} Monate",
|
|
471
|
+
renewEveryYear: "j\xE4hrlich",
|
|
472
|
+
renewEveryYears: "alle {count} Jahre"
|
|
473
|
+
},
|
|
474
|
+
en: {
|
|
475
|
+
renewsUntilCancel: "Renews {interval} until you cancel.",
|
|
476
|
+
switchPlansInAccount: "Switch plans any time in your account.",
|
|
477
|
+
renewEveryDay: "every day",
|
|
478
|
+
renewEveryDays: "every {count} days",
|
|
479
|
+
renewEveryWeek: "every week",
|
|
480
|
+
renewEveryWeeks: "every {count} weeks",
|
|
481
|
+
renewEveryMonth: "every month",
|
|
482
|
+
renewEveryMonths: "every {count} months",
|
|
483
|
+
renewEveryYear: "every year",
|
|
484
|
+
renewEveryYears: "every {count} years"
|
|
485
|
+
},
|
|
486
|
+
es: {
|
|
487
|
+
renewsUntilCancel: "Se renueva {interval} hasta que lo canceles.",
|
|
488
|
+
switchPlansInAccount: "Cambia de plan cuando quieras desde tu cuenta.",
|
|
489
|
+
renewEveryDay: "cada d\xEDa",
|
|
490
|
+
renewEveryDays: "cada {count} d\xEDas",
|
|
491
|
+
renewEveryWeek: "cada semana",
|
|
492
|
+
renewEveryWeeks: "cada {count} semanas",
|
|
493
|
+
renewEveryMonth: "cada mes",
|
|
494
|
+
renewEveryMonths: "cada {count} meses",
|
|
495
|
+
renewEveryYear: "cada a\xF1o",
|
|
496
|
+
renewEveryYears: "cada {count} a\xF1os"
|
|
497
|
+
},
|
|
498
|
+
fi: {
|
|
499
|
+
renewsUntilCancel: "Uusiutuu {interval}, kunnes peruutat.",
|
|
500
|
+
switchPlansInAccount: "Vaihda tilausta milloin tahansa tilill\xE4si.",
|
|
501
|
+
renewEveryDay: "p\xE4ivitt\xE4in",
|
|
502
|
+
renewEveryDays: "{count} p\xE4iv\xE4n v\xE4lein",
|
|
503
|
+
renewEveryWeek: "viikoittain",
|
|
504
|
+
renewEveryWeeks: "{count} viikon v\xE4lein",
|
|
505
|
+
renewEveryMonth: "kuukausittain",
|
|
506
|
+
renewEveryMonths: "{count} kuukauden v\xE4lein",
|
|
507
|
+
renewEveryYear: "vuosittain",
|
|
508
|
+
renewEveryYears: "{count} vuoden v\xE4lein"
|
|
509
|
+
},
|
|
510
|
+
fr: {
|
|
511
|
+
renewsUntilCancel: "Se renouvelle {interval} jusqu'\xE0 ce que vous r\xE9siliiez.",
|
|
512
|
+
switchPlansInAccount: "Changez de formule \xE0 tout moment depuis votre compte.",
|
|
513
|
+
renewEveryDay: "chaque jour",
|
|
514
|
+
renewEveryDays: "tous les {count} jours",
|
|
515
|
+
renewEveryWeek: "chaque semaine",
|
|
516
|
+
renewEveryWeeks: "toutes les {count} semaines",
|
|
517
|
+
renewEveryMonth: "chaque mois",
|
|
518
|
+
renewEveryMonths: "tous les {count} mois",
|
|
519
|
+
renewEveryYear: "chaque ann\xE9e",
|
|
520
|
+
renewEveryYears: "tous les {count} ans"
|
|
521
|
+
},
|
|
522
|
+
hi: {
|
|
523
|
+
renewsUntilCancel: "\u0930\u0926\u094D\u0926 \u0915\u0930\u0928\u0947 \u0924\u0915 {interval} \u0928\u0935\u0940\u0928\u0940\u0915\u0943\u0924 \u0939\u094B\u0924\u093E \u0939\u0948\u0964",
|
|
524
|
+
switchPlansInAccount: "\u0905\u092A\u0928\u0947 \u0916\u093E\u0924\u0947 \u092E\u0947\u0902 \u0915\u092D\u0940 \u092D\u0940 \u092A\u094D\u0932\u093E\u0928 \u092C\u0926\u0932\u0947\u0902\u0964",
|
|
525
|
+
renewEveryDay: "\u0939\u0930 \u0926\u093F\u0928",
|
|
526
|
+
renewEveryDays: "\u0939\u0930 {count} \u0926\u093F\u0928",
|
|
527
|
+
renewEveryWeek: "\u0939\u0930 \u0939\u092B\u093C\u094D\u0924\u0947",
|
|
528
|
+
renewEveryWeeks: "\u0939\u0930 {count} \u0939\u092B\u093C\u094D\u0924\u0947",
|
|
529
|
+
renewEveryMonth: "\u0939\u0930 \u092E\u0939\u0940\u0928\u0947",
|
|
530
|
+
renewEveryMonths: "\u0939\u0930 {count} \u092E\u0939\u0940\u0928\u0947",
|
|
531
|
+
renewEveryYear: "\u0939\u0930 \u0938\u093E\u0932",
|
|
532
|
+
renewEveryYears: "\u0939\u0930 {count} \u0938\u093E\u0932"
|
|
533
|
+
},
|
|
534
|
+
it: {
|
|
535
|
+
renewsUntilCancel: "Si rinnova {interval} finch\xE9 non annulli.",
|
|
536
|
+
switchPlansInAccount: "Cambia piano quando vuoi dal tuo account.",
|
|
537
|
+
renewEveryDay: "ogni giorno",
|
|
538
|
+
renewEveryDays: "ogni {count} giorni",
|
|
539
|
+
renewEveryWeek: "ogni settimana",
|
|
540
|
+
renewEveryWeeks: "ogni {count} settimane",
|
|
541
|
+
renewEveryMonth: "ogni mese",
|
|
542
|
+
renewEveryMonths: "ogni {count} mesi",
|
|
543
|
+
renewEveryYear: "ogni anno",
|
|
544
|
+
renewEveryYears: "ogni {count} anni"
|
|
545
|
+
},
|
|
546
|
+
lt: {
|
|
547
|
+
renewsUntilCancel: "Atnaujinama {interval}, kol at\u0161auksite.",
|
|
548
|
+
switchPlansInAccount: "Plan\u0105 galite bet kada pakeisti savo paskyroje.",
|
|
549
|
+
renewEveryDay: "kasdien",
|
|
550
|
+
renewEveryDays: "kas {count} d.",
|
|
551
|
+
renewEveryWeek: "kas savait\u0119",
|
|
552
|
+
renewEveryWeeks: "kas {count} sav.",
|
|
553
|
+
renewEveryMonth: "kas m\u0117nes\u012F",
|
|
554
|
+
renewEveryMonths: "kas {count} m\u0117n.",
|
|
555
|
+
renewEveryYear: "kasmet",
|
|
556
|
+
renewEveryYears: "kas {count} m."
|
|
557
|
+
},
|
|
558
|
+
nl: {
|
|
559
|
+
renewsUntilCancel: "Wordt {interval} verlengd tot je opzegt.",
|
|
560
|
+
switchPlansInAccount: "Wissel op elk moment van abonnement in je account.",
|
|
561
|
+
renewEveryDay: "elke dag",
|
|
562
|
+
renewEveryDays: "elke {count} dagen",
|
|
563
|
+
renewEveryWeek: "elke week",
|
|
564
|
+
renewEveryWeeks: "elke {count} weken",
|
|
565
|
+
renewEveryMonth: "elke maand",
|
|
566
|
+
renewEveryMonths: "elke {count} maanden",
|
|
567
|
+
renewEveryYear: "elk jaar",
|
|
568
|
+
renewEveryYears: "elke {count} jaar"
|
|
569
|
+
},
|
|
570
|
+
pl: {
|
|
571
|
+
renewsUntilCancel: "Odnawia si\u0119 {interval}, dop\xF3ki nie anulujesz.",
|
|
572
|
+
switchPlansInAccount: "Zmie\u0144 plan w dowolnym momencie na swoim koncie.",
|
|
573
|
+
renewEveryDay: "codziennie",
|
|
574
|
+
renewEveryDays: "co {count} dni",
|
|
575
|
+
renewEveryWeek: "co tydzie\u0144",
|
|
576
|
+
renewEveryWeeks: "co {count} tyg.",
|
|
577
|
+
renewEveryMonth: "co miesi\u0105c",
|
|
578
|
+
renewEveryMonths: "co {count} mies.",
|
|
579
|
+
renewEveryYear: "co roku",
|
|
580
|
+
renewEveryYears: "co {count} l."
|
|
581
|
+
},
|
|
582
|
+
pt: {
|
|
583
|
+
renewsUntilCancel: "Renova {interval} at\xE9 voc\xEA cancelar.",
|
|
584
|
+
switchPlansInAccount: "Troque de plano quando quiser na sua conta.",
|
|
585
|
+
renewEveryDay: "todos os dias",
|
|
586
|
+
renewEveryDays: "a cada {count} dias",
|
|
587
|
+
renewEveryWeek: "toda semana",
|
|
588
|
+
renewEveryWeeks: "a cada {count} semanas",
|
|
589
|
+
renewEveryMonth: "todo m\xEAs",
|
|
590
|
+
renewEveryMonths: "a cada {count} meses",
|
|
591
|
+
renewEveryYear: "todo ano",
|
|
592
|
+
renewEveryYears: "a cada {count} anos"
|
|
593
|
+
},
|
|
594
|
+
ru: {
|
|
595
|
+
renewsUntilCancel: "\u041F\u0440\u043E\u0434\u043B\u0435\u0432\u0430\u0435\u0442\u0441\u044F {interval}, \u043F\u043E\u043A\u0430 \u0432\u044B \u043D\u0435 \u043E\u0442\u043C\u0435\u043D\u0438\u0442\u0435.",
|
|
596
|
+
switchPlansInAccount: "\u0421\u043C\u0435\u043D\u0438\u0442\u044C \u0442\u0430\u0440\u0438\u0444 \u043C\u043E\u0436\u043D\u043E \u0432 \u043B\u044E\u0431\u043E\u0439 \u043C\u043E\u043C\u0435\u043D\u0442 \u0432 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0435.",
|
|
597
|
+
renewEveryDay: "\u043A\u0430\u0436\u0434\u044B\u0439 \u0434\u0435\u043D\u044C",
|
|
598
|
+
renewEveryDays: "\u0440\u0430\u0437 \u0432 {count} \u0434\u043D.",
|
|
599
|
+
renewEveryWeek: "\u043A\u0430\u0436\u0434\u0443\u044E \u043D\u0435\u0434\u0435\u043B\u044E",
|
|
600
|
+
renewEveryWeeks: "\u0440\u0430\u0437 \u0432 {count} \u043D\u0435\u0434.",
|
|
601
|
+
renewEveryMonth: "\u043A\u0430\u0436\u0434\u044B\u0439 \u043C\u0435\u0441\u044F\u0446",
|
|
602
|
+
renewEveryMonths: "\u0440\u0430\u0437 \u0432 {count} \u043C\u0435\u0441.",
|
|
603
|
+
renewEveryYear: "\u043A\u0430\u0436\u0434\u044B\u0439 \u0433\u043E\u0434",
|
|
604
|
+
renewEveryYears: "\u0440\u0430\u0437 \u0432 {count} \u0433."
|
|
605
|
+
},
|
|
606
|
+
tr: {
|
|
607
|
+
renewsUntilCancel: "\u0130ptal edene kadar {interval} yenilenir.",
|
|
608
|
+
switchPlansInAccount: "Plan\u0131n\u0131z\u0131 istedi\u011Finiz zaman hesab\u0131n\u0131zdan de\u011Fi\u015Ftirebilirsiniz.",
|
|
609
|
+
renewEveryDay: "her g\xFCn",
|
|
610
|
+
renewEveryDays: "her {count} g\xFCnde bir",
|
|
611
|
+
renewEveryWeek: "her hafta",
|
|
612
|
+
renewEveryWeeks: "her {count} haftada bir",
|
|
613
|
+
renewEveryMonth: "her ay",
|
|
614
|
+
renewEveryMonths: "her {count} ayda bir",
|
|
615
|
+
renewEveryYear: "her y\u0131l",
|
|
616
|
+
renewEveryYears: "her {count} y\u0131lda bir"
|
|
617
|
+
},
|
|
618
|
+
uk: {
|
|
619
|
+
renewsUntilCancel: "\u041F\u043E\u0434\u043E\u0432\u0436\u0443\u0454\u0442\u044C\u0441\u044F {interval}, \u0434\u043E\u043A\u0438 \u0432\u0438 \u043D\u0435 \u0441\u043A\u0430\u0441\u0443\u0454\u0442\u0435.",
|
|
620
|
+
switchPlansInAccount: "\u0417\u043C\u0456\u043D\u0438\u0442\u0438 \u043F\u043B\u0430\u043D \u043C\u043E\u0436\u043D\u0430 \u0431\u0443\u0434\u044C-\u043A\u043E\u043B\u0438 \u0432 \u043E\u0431\u043B\u0456\u043A\u043E\u0432\u043E\u043C\u0443 \u0437\u0430\u043F\u0438\u0441\u0456.",
|
|
621
|
+
renewEveryDay: "\u0449\u043E\u0434\u043D\u044F",
|
|
622
|
+
renewEveryDays: "\u0440\u0430\u0437 \u043D\u0430 {count} \u0434\u043D.",
|
|
623
|
+
renewEveryWeek: "\u0449\u043E\u0442\u0438\u0436\u043D\u044F",
|
|
624
|
+
renewEveryWeeks: "\u0440\u0430\u0437 \u043D\u0430 {count} \u0442\u0438\u0436.",
|
|
625
|
+
renewEveryMonth: "\u0449\u043E\u043C\u0456\u0441\u044F\u0446\u044F",
|
|
626
|
+
renewEveryMonths: "\u0440\u0430\u0437 \u043D\u0430 {count} \u043C\u0456\u0441.",
|
|
627
|
+
renewEveryYear: "\u0449\u043E\u0440\u043E\u043A\u0443",
|
|
628
|
+
renewEveryYears: "\u0440\u0430\u0437 \u043D\u0430 {count} \u0440."
|
|
629
|
+
},
|
|
630
|
+
zh: {
|
|
631
|
+
renewsUntilCancel: "{interval}\u81EA\u52A8\u7EED\u8BA2\uFF0C\u76F4\u5230\u4F60\u53D6\u6D88\u3002",
|
|
632
|
+
switchPlansInAccount: "\u53EF\u968F\u65F6\u5728\u4F60\u7684\u8D26\u6237\u4E2D\u5207\u6362\u65B9\u6848\u3002",
|
|
633
|
+
renewEveryDay: "\u6BCF\u5929",
|
|
634
|
+
renewEveryDays: "\u6BCF {count} \u5929",
|
|
635
|
+
renewEveryWeek: "\u6BCF\u5468",
|
|
636
|
+
renewEveryWeeks: "\u6BCF {count} \u5468",
|
|
637
|
+
renewEveryMonth: "\u6BCF\u6708",
|
|
638
|
+
renewEveryMonths: "\u6BCF {count} \u4E2A\u6708",
|
|
639
|
+
renewEveryYear: "\u6BCF\u5E74",
|
|
640
|
+
renewEveryYears: "\u6BCF {count} \u5E74"
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
function resolveSubscriptionRenewalLocale(lang) {
|
|
644
|
+
const base = (lang ?? "").trim().toLowerCase().split(/[-_]/)[0] ?? "";
|
|
645
|
+
return base in SUBSCRIPTION_RENEWAL_MESSAGES ? base : "en";
|
|
646
|
+
}
|
|
647
|
+
function subscriptionRenewalMessage(key, lang) {
|
|
648
|
+
const activeLang = lang === void 0 && typeof document !== "undefined" ? document.documentElement.getAttribute("lang") : lang;
|
|
649
|
+
return SUBSCRIPTION_RENEWAL_MESSAGES[resolveSubscriptionRenewalLocale(activeLang)][key];
|
|
650
|
+
}
|
|
651
|
+
|
|
448
652
|
// src/video-embed.ts
|
|
449
653
|
var ALLOWED_VIDEO_EMBED_HOSTS = /* @__PURE__ */ new Set([
|
|
450
654
|
"www.youtube-nocookie.com",
|
|
@@ -575,13 +779,19 @@ function formatSubscriptionCadence(subscription) {
|
|
|
575
779
|
const noun = SUBSCRIPTION_INTERVAL_NOUNS[unit];
|
|
576
780
|
return subscription.intervalCount === 1 ? `per ${noun}` : `every ${subscription.intervalCount} ${noun}s`;
|
|
577
781
|
}
|
|
578
|
-
|
|
782
|
+
var RENEWAL_INTERVAL_KEYS = {
|
|
783
|
+
DAY: ["renewEveryDay", "renewEveryDays"],
|
|
784
|
+
WEEK: ["renewEveryWeek", "renewEveryWeeks"],
|
|
785
|
+
MONTH: ["renewEveryMonth", "renewEveryMonths"],
|
|
786
|
+
YEAR: ["renewEveryYear", "renewEveryYears"]
|
|
787
|
+
};
|
|
788
|
+
function formatSubscriptionRenewal(subscription, lang) {
|
|
579
789
|
const unit = subscription.intervalUnit;
|
|
580
790
|
if (unit === null) return "";
|
|
581
|
-
const
|
|
582
|
-
const
|
|
583
|
-
const renews =
|
|
584
|
-
return subscription.planChangeOffered ? `${renews}
|
|
791
|
+
const [one, many] = RENEWAL_INTERVAL_KEYS[unit];
|
|
792
|
+
const interval = subscription.intervalCount === 1 ? subscriptionRenewalMessage(one, lang) : subscriptionRenewalMessage(many, lang).replace("{count}", String(subscription.intervalCount));
|
|
793
|
+
const renews = subscriptionRenewalMessage("renewsUntilCancel", lang).replace("{interval}", interval);
|
|
794
|
+
return subscription.planChangeOffered ? `${renews} ${subscriptionRenewalMessage("switchPlansInAccount", lang)}` : renews;
|
|
585
795
|
}
|
|
586
796
|
function formatSubscriptionTrial(subscription, formatAmount) {
|
|
587
797
|
const trial = subscription.trial;
|
|
@@ -590,13 +800,14 @@ function formatSubscriptionTrial(subscription, formatAmount) {
|
|
|
590
800
|
return `${formatAmount(trial.price, trial.currency)} for ${trial.days} ${trial.days === 1 ? "day" : "days"}`;
|
|
591
801
|
}
|
|
592
802
|
function subscriptionForVariant(subscription, variant) {
|
|
593
|
-
|
|
594
|
-
const
|
|
595
|
-
|
|
803
|
+
if (!variant) return subscription;
|
|
804
|
+
const own = variant.billingInterval;
|
|
805
|
+
const ownTrial = variant.ownTrial;
|
|
596
806
|
return {
|
|
597
807
|
...subscription,
|
|
598
808
|
...own ? { intervalUnit: own.unit, intervalCount: own.count } : {},
|
|
599
|
-
...ownTrial ? { trial: ownTrial === "none" ? null : ownTrial } : {}
|
|
809
|
+
...ownTrial ? { trial: ownTrial === "none" ? null : ownTrial } : {},
|
|
810
|
+
planChangeOffered: variant.planChangeOffered
|
|
600
811
|
};
|
|
601
812
|
}
|
|
602
813
|
function parseSubscription(product, productType) {
|
|
@@ -1058,6 +1269,7 @@ function parsePriceVariants(value, productContext) {
|
|
|
1058
1269
|
license: parseVariantLicense(variant),
|
|
1059
1270
|
billingInterval: parseVariantBillingInterval(variant),
|
|
1060
1271
|
ownTrial: parseVariantTrial(variant),
|
|
1272
|
+
planChangeOffered: variant.plan_change_offered === true,
|
|
1061
1273
|
price: unitPrice,
|
|
1062
1274
|
baseUnitPrice: unitPrice,
|
|
1063
1275
|
stock: normalizeStock(variant.stock, `${context}.stock`),
|