Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion studio/ost/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ button.promo-tag-button {
.no-promo {
opacity: 0.2;
}
.price-strikethrough {
.price-strikethrough, .price-promo-strikethrough {
text-decoration: line-through;
}
.placeholders-list {
Expand Down
2 changes: 1 addition & 1 deletion studio/ost/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions web-components/dist/commerce.js

Large diffs are not rendered by default.

192 changes: 96 additions & 96 deletions web-components/dist/mas.js

Large diffs are not rendered by default.

178 changes: 89 additions & 89 deletions web-components/dist/merch-card-collection.js

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions web-components/src/inline-price.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ export class InlinePrice extends HTMLSpanElement {
}

static createInlinePrice(options) {
// eslint-disable-next-line react-hooks/rules-of-hooks
const service = getService();
if (!service) return null;
const {
Expand Down Expand Up @@ -311,7 +310,6 @@ export class InlinePrice extends HTMLSpanElement {
*/
async render(overrides = {}) {
if (!this.isConnected) return false;
// eslint-disable-next-line react-hooks/rules-of-hooks
const service = getService();
if (!service) return false;
const priceOptions = service.collectPriceOptions(overrides, this);
Expand All @@ -326,7 +324,7 @@ export class InlinePrice extends HTMLSpanElement {
const [offerSelectors] =
await service.resolveOfferSelectors(options);
let offers = selectOffers(await offerSelectors, options);
let [offer] = offers;
const [offer] = offers;

if (service.featureFlags[FF_DEFAULTS] || options[FF_DEFAULTS]) {
if (priceOptions.displayPerUnit === undefined) {
Expand Down Expand Up @@ -382,7 +380,6 @@ export class InlinePrice extends HTMLSpanElement {
*/
renderOffers(offers, options, version = undefined) {
if (!this.isConnected) return;
// eslint-disable-next-line react-hooks/rules-of-hooks
const service = getService();
if (!service) return false;
version ??= this.masElement.togglePending();
Expand Down
4 changes: 4 additions & 0 deletions web-components/src/price.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
pricePromo,
priceOptical,
priceStrikethrough,
pricePromoStrikethrough,
priceAnnual,
priceWithAnnual,
pricePromoWithAnnual,
Expand Down Expand Up @@ -90,6 +91,9 @@ export function Price({ literals, providers, settings }) {
case 'strikethrough':
method = priceStrikethrough;
break;
case 'promo-strikethrough':
method = pricePromoStrikethrough;
break;
case 'annual':
method = priceAnnual;
break;
Expand Down
4 changes: 4 additions & 0 deletions web-components/src/price/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const priceOptical = createPriceTemplate({
const priceStrikethrough = createPriceTemplate({
displayStrikethrough: true,
});
const pricePromoStrikethrough = createPriceTemplate({
displayPromoStrikethrough: true,
});
const priceAnnual = createPriceTemplate({
displayAnnual: true,
});
Expand All @@ -38,6 +41,7 @@ export {
pricePromo,
priceOptical,
priceStrikethrough,
pricePromoStrikethrough,
priceAnnual,
priceAlternative,
priceOpticalAlternative,
Expand Down
10 changes: 9 additions & 1 deletion web-components/src/price/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const cssClassNames = {
container: 'price',
containerOptical: 'price-optical',
containerStrikethrough: 'price-strikethrough',
containerPromoStrikethrough: 'price-promo-strikethrough',
containerAlternative: 'price-alternative',
containerAnnual: 'price-annual',
containerAnnualPrefix: 'price-annual-prefix',
Expand Down Expand Up @@ -215,6 +216,7 @@ const createPriceTemplate =
isAlternativePrice = false,
displayOptical = false,
displayStrikethrough = false,
displayPromoStrikethrough = false,
displayAnnual = false,
instant = undefined,
} = {}) =>
Expand Down Expand Up @@ -269,7 +271,10 @@ const createPriceTemplate =
let displayPrice;

if (promotion && !isPromoApplied && priceWithoutDiscount) {
displayPrice = isAlternativePrice ? price : priceWithoutDiscount;
displayPrice =
isAlternativePrice || displayPromoStrikethrough
? price
: priceWithoutDiscount;
} else if (displayStrikethrough && priceWithoutDiscount) {
displayPrice = priceWithoutDiscount;
} else {
Expand Down Expand Up @@ -368,6 +373,9 @@ const createPriceTemplate =
if (displayStrikethrough) {
cssClass += ' ' + cssClassNames.containerStrikethrough;
}
if (displayPromoStrikethrough) {
cssClass += ' ' + cssClassNames.containerPromoStrikethrough;
}
if (isAlternativePrice) {
cssClass += ' ' + cssClassNames.containerAlternative;
}
Expand Down
30 changes: 30 additions & 0 deletions web-components/test/price/__snapshots__/index.snapshot.js

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions web-components/test/price/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
price,
priceOptical,
priceStrikethrough,
pricePromoStrikethrough,
priceAnnual,
priceWithAnnual,
pricePromoWithAnnual,
Expand Down Expand Up @@ -37,6 +38,7 @@ Object.entries({
price,
priceOptical,
priceStrikethrough,
pricePromoStrikethrough,
priceAnnual,
priceWithAnnual,
pricePromoWithAnnual,
Expand Down
10 changes: 10 additions & 0 deletions web-components/test/price/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ describe('function "createPriceTemplate"', () => {
);
});

it('uses priceWithoutDiscount when displayPromoStrikethrough is true', function () {
const template = createPriceTemplate({
displayPromoStrikethrough: true,
});
renderAndComparePrice(
'createPriceTemplatePromoStrikethrough',
template(context, valueDiscount, {}),
);
});

it('uses price in default case', function () {
const template = createPriceTemplate();
renderAndComparePrice(
Expand Down
Loading