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.js

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions studio/src/rte/ost.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const OST_OPTION_ATTRIBUTE_MAPPING = {
displayPerUnit: 'data-display-per-unit',
displayRecurrence: 'data-display-recurrence',
displayTax: 'data-display-tax',
forceTaxExclusive: 'data-tax-exclusive',
forceTaxExclusive: 'data-force-tax-exclusive',
isPerpetual: 'data-perpetual',
wcsOsi: 'data-wcs-osi',
workflow: 'data-checkout-workflow',
Expand All @@ -93,11 +93,21 @@ const OST_VALUE_MAPPING = {
false: false,
};

export function onPlaceholderSelect(offerSelectorId, type, offer, options, promoOverride) {
export async function onPlaceholderSelect(offerSelectorId, type, offer, options, promoOverride) {
const masCommerceService = document.querySelector('mas-commerce-service');
const settings = ostDefaultSettings();
let settings = ostDefaultSettings();
if (masCommerceService.featureFlags['mas-ff-defaults']) {
settings.displayPerUnit = offer.customer_segment !== 'INDIVIDUAL';
const taxFlags = await masCommerceService?.resolvePriceTaxFlags(
masCommerceService.settings.country,
null,
offer.customer_segment,
offer.market_segments[0],
);
settings = {
...settings,
...taxFlags,
displayPerUnit: offer.customer_segment !== 'INDIVIDUAL',
};
}
const changes = getObjectDifference(options, settings);

Expand Down
2 changes: 1 addition & 1 deletion studio/src/rte/rte-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ class RteField extends LitElement {
'data-display-tax': { default: null },
'data-perpetual': { default: null },
'data-promotion-code': { default: null },
'data-tax-exclusive': { default: null },
'data-force-tax-exclusive': { default: null },
'data-template': { default: null },
'data-wcs-osi': { default: null },
},
Expand Down
6 changes: 3 additions & 3 deletions web-components/dist/commerce.js

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions web-components/dist/mas.js

Large diffs are not rendered by default.

104 changes: 52 additions & 52 deletions web-components/dist/merch-card-collection.js

Large diffs are not rendered by default.

36 changes: 26 additions & 10 deletions web-components/src/inline-price.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const DISPLAY_TAX_MAP = {
'KR_ko',
],
[BUSINESS]: ['MU_en', 'LT_lt', 'LV_lv', 'NG_en', 'CO_es', 'KR_ko'],
[STUDENT]: ['LT_lt', 'LV_lv', 'SA_en', 'SG_en'],
[STUDENT]: ['LT_lt', 'LV_lv', 'SA_en', 'SA_ar', 'SG_en'],
Copy link
Contributor

@mirafedas mirafedas Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot find this change listed in the description of the Jira: https://jira.corp.adobe.com/browse/MWPW-185252 , could you please link the Jira where it was requested?
I included this change in my PR: #499 to not cause conflicts/regressions, and updated the documentation I added accordingly.


And in the PR description you need to update the first line:
Resolves https://jira.corp.adobe.com/browse/MWPW-NUMBER > Resolves https://jira.corp.adobe.com/browse/MWPW-185252

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Good catch. This is not requested anywhere. This is something that I noticed in production and I think it is a mistake in that excel file with tax included/excluded per country. For students it is included for sa_en but excluded for sa_ar (and tax label not displayed), which is not logical at all. So I changed that table in the code to have it as we have now in production.
But I will double check this with Lucy and Ravneet. Thanks for reminding me. Will CC you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[UNIVERSITY]: ['SG_en', 'KR_ko'],
};

Expand All @@ -94,6 +94,28 @@ const TAX_EXCLUDED_MAP_INDEX = [INDIVIDUAL, BUSINESS, STUDENT, UNIVERSITY];
const defaultTaxExcluded = (segment) =>
[BUSINESS, UNIVERSITY].includes(segment);

const getFromMap = (map, country, language, isArray) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use a named function with a more explicit name, it would help in the stacktrace.

if (map[country]) return map[country];
const locale = `${country}_${language}`;
if (map[locale]) return map[locale];

let result;
if (isArray) {
map.forEach((item) => {
if (!result && item.startsWith(`${country}_`)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since forEach cannot be broken, it is not optimal for performance.
suggestion:

const result = map.find(item => item.startsWith(`${country}_`));

result = item;
}
});
} else {
Object.keys(map).forEach((key) => {
if (!result && key.startsWith(`${country}_`)) {
result = map[key];
}
});
}
return result;
};

/**
* Resolves the default value for forceTaxExclusive for the provided geo info and segments.
* @param {string} country - uppercase country code e.g. US, AT, MX
Expand All @@ -108,9 +130,8 @@ const resolveTaxExclusive = (
customerSegment,
marketSegment,
) => {
const locale = `${country}_${language}`;
const segment = `${customerSegment}_${marketSegment}`;
const val = TAX_EXCLUDED_MAP[locale];
const val = getFromMap(TAX_EXCLUDED_MAP, country, language, false);
if (val) {
const index = TAX_EXCLUDED_MAP_INDEX.indexOf(segment);
return val[index];
Expand All @@ -133,21 +154,16 @@ const resolveDisplayTaxForGeoAndSegment = (
customerSegment,
marketSegment,
) => {
const locale = `${country}_${language}`;
if (
DISPLAY_ALL_TAX_COUNTRIES.includes(country) ||
DISPLAY_ALL_TAX_COUNTRIES.includes(locale)
) {
if (getFromMap(DISPLAY_ALL_TAX_COUNTRIES, country, language, true))
return true;
}

const segmentConfig =
DISPLAY_TAX_MAP[`${customerSegment}_${marketSegment}`];
if (!segmentConfig) {
return Defaults.displayTax;
}

if (segmentConfig.includes(country) || segmentConfig.includes(locale)) {
if (getFromMap(segmentConfig, country, language, true)) {
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions web-components/src/mas-commerce-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { getSettings } from './settings.js';
import { Wcs } from './wcs.js';
import { updateConfig as updateLanaConfig } from './lana.js';
import { printMeasure } from './utils.js';
import { resolvePriceTaxFlags } from './inline-price.js';
import { getParameter } from '@dexter/tacocat-core';

export const TAG_NAME_SERVICE = 'mas-commerce-service';
Expand Down Expand Up @@ -130,6 +131,7 @@ export class MasCommerceService extends HTMLElement {
...Constants,
// Defined serviceweb component API
Log,
resolvePriceTaxFlags,
get defaults() {
return Defaults;
},
Expand Down
30 changes: 22 additions & 8 deletions web-components/test/mocks/sites/fragments/mini-photo-no-cta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,38 @@
"title": "CCD Photography no CTA",
"id": "c90e1c91-8106-4ad8-9249-1ddf5ae3b057",
"description": "",
"model": { "id": "L2NvbmYvbWFzL3NldHRpbmdzL2RhbS9jZm0vbW9kZWxzL2NhcmQ" },
"model": {
"id": "L2NvbmYvbWFzL3NldHRpbmdzL2RhbS9jZm0vbW9kZWxzL2NhcmQ"
},
"fields": {
"variant": "mini",
"osi": "KpJ8-_gE7U3aOkxdHzSXsGJ1SV9fuL_TJuCqn_hvYSk",
"mnemonicIcon": [],
"mnemonicAlt": [],
"mnemonicLink": [],
"badge": { "mimeType": "text/html" },
"trialBadge": { "mimeType": "text/html" },
"badge": {
"mimeType": "text/html"
},
"trialBadge": {
"mimeType": "text/html"
},
"cardTitle": "CCD Apps: Photography no CTA",
"prices": {
"value": "<span is=\"inline-price\" data-display-per-unit=\"false\" data-tax-exclusive=\"true\" data-template=\"price\" data-wcs-osi=\"mini-photo\"></span>",
"value": "<span is=\"inline-price\" data-display-per-unit=\"false\" data-force-tax-exclusive=\"true\" data-template=\"price\" data-wcs-osi=\"mini-photo\"></span>",
"mimeType": "text/html"
},
"shortDescription": {
"mimeType": "text/html"
},
"description": {
"mimeType": "text/html"
},
"callout": {
"mimeType": "text/html"
},
"ctas": {
"mimeType": "text/html"
},
"shortDescription": { "mimeType": "text/html" },
"description": { "mimeType": "text/html" },
"callout": { "mimeType": "text/html" },
"ctas": { "mimeType": "text/html" },
"tags": [
"mas:offer_type/base",
"mas:plan_type/abm",
Expand Down
2 changes: 1 addition & 1 deletion web-components/test/price.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ describe('class "InlinePrice"', () => {
expected: [
[true, false],
[false, false],
[false, false],
[true, false],
[false, false],
],
},
Expand Down
Loading