-
Notifications
You must be signed in to change notification settings - Fork 191
[3in1] MWPW-173962 #4258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3in1] MWPW-173962 #4258
Changes from all commits
d521920
81c2c45
5c5b2e3
985371a
81397c4
34786fa
249f191
0ae3c3f
763addf
f992eca
c299eb4
8a6e2dd
013306d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ const PARAMETERS = new Map([ | |
['clientId', 'cli'], | ||
['context', 'ctx'], | ||
['productArrangementCode', 'pa'], | ||
['addonProductArrangementCode', 'ao'], | ||
['offerType', 'ot'], | ||
['marketSegment', 'ms'], | ||
]); | ||
|
@@ -27,6 +28,7 @@ const PARAMETERS = new Map([ | |
const ALLOWED_KEYS = new Set([ | ||
'af', | ||
'ai', | ||
'ao', | ||
'apc', | ||
'appctxid', | ||
'cli', | ||
|
@@ -132,30 +134,21 @@ export function setItemsParameter(items, parameters) { | |
* @param {string} addonProductArrangementCode - Addon product arrangement code | ||
* @returns URL object | ||
*/ | ||
export function add3in1Parameters({ url, modal, customerSegment, cs, ms, marketSegment, quantity, productArrangementCode, addonProductArrangementCode }) { | ||
const masFF3in1 = document.querySelector('meta[name=mas-ff-3in1]'); | ||
if (!Object.va F438 lues(MODAL_TYPE_3_IN_1).includes(modal) || !url?.searchParams || !customerSegment || !marketSegment || (masFF3in1 && masFF3in1.content === 'off')) return url; | ||
export function add3in1Parameters({ url, modal, is3in1 }) { | ||
if (!is3in1 || !url?.searchParams) return url; | ||
url.searchParams.set('rtc', 't'); | ||
url.searchParams.set('lo', 'sl'); | ||
url.searchParams.set('af', 'uc_new_user_iframe,uc_new_system_close'); | ||
if (url.searchParams.get('cli') !== 'doc_cloud') { | ||
url.searchParams.set('cli', modal === MODAL_TYPE_3_IN_1.CRM ? 'creative' : 'mini_plans'); | ||
} | ||
if (modal === MODAL_TYPE_3_IN_1.TWP || modal === MODAL_TYPE_3_IN_1.D2P) { | ||
if (customerSegment === 'INDIVIDUAL' && marketSegment === 'EDU') { | ||
url.searchParams.set('ms', 'e'); | ||
} | ||
if (customerSegment === 'TEAM' && marketSegment === 'COM') { | ||
url.searchParams.set('cs', 't'); | ||
} | ||
// used on catalog page by MEP to preselect plan | ||
const metaPreselectPlan = document.querySelector('meta[name="preselect-plan"]'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. buildCheckoutUrl.js is should be agnostic of context. It should just generate an URL as string. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mmm i could move it to checkout.js but not sure how to move it to checkout-mixin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at https://github.com/adobecom/milo/blob/stage/libs/features/mas/src/checkout-mixin.js#L196 |
||
if (metaPreselectPlan?.content?.toLowerCase() === 'edu') { | ||
url.searchParams.set('ms', 'EDU'); | ||
} else if (metaPreselectPlan?.content?.toLowerCase() === 'team') { | ||
url.searchParams.set('cs', 'TEAM'); | ||
} | ||
if (quantity) url.searchParams.set('q', quantity); | ||
if (addonProductArrangementCode) url.searchParams.set('ao', addonProductArrangementCode); | ||
if (productArrangementCode) url.searchParams.set('pa', productArrangementCode); | ||
// cs and ms are params manually set by authors, they should take precedence over marketSegment and customerSegment | ||
if (cs) url.searchParams.set('cs', cs); | ||
if (ms) url.searchParams.set('ms', ms); | ||
if (url.searchParams.get('ot') === 'PROMOTION') url.searchParams.delete('ot'); | ||
return url; | ||
} | ||
|
||
|
@@ -164,36 +157,36 @@ export function add3in1Parameters({ url, modal, customerSegment, cs, ms, marketS | |
*/ | ||
export function buildCheckoutUrl(checkoutData) { | ||
validateCheckoutData(checkoutData); | ||
const { env, items, workflowStep, ms, cs, marketSegment, customerSegment, ot, offerType, pa, productArrangementCode, landscape, modal, ...rest } = | ||
const { env, items, workflowStep, ms, cs, marketSegment, customerSegment, ot, offerType, pa, productArrangementCode, landscape, modal, is3in1, ...rest } = | ||
checkoutData; | ||
const segmentationParameters = { | ||
marketSegment: marketSegment ?? ms, | ||
offerType: offerType ?? ot, | ||
productArrangementCode: productArrangementCode ?? pa, | ||
}; | ||
|
||
let url = new URL(getHostName(env)); | ||
url.pathname = `${UCV3_PREFIX}${workflowStep}`; | ||
if (workflowStep !== CheckoutWorkflowStep.SEGMENTATION && workflowStep !== CheckoutWorkflowStep.CHANGE_PLAN_TEAM_PLANS) { | ||
setItemsParameter(items, url.searchParams); | ||
} | ||
addParameters({ cs, ...rest }, url.searchParams, ALLOWED_KEYS); | ||
addParameters({ ...rest }, url.searchParams, ALLOWED_KEYS); | ||
if (landscape === Landscape.DRAFT) { | ||
addParameters({ af: AF_DRAFT_LANDSCAPE }, url.searchParams, ALLOWED_KEYS); | ||
} | ||
if (workflowStep === CheckoutWorkflowStep.SEGMENTATION) { | ||
// ms, ot, cs, pa are params manually set by authors, they should take precedence over 'marketSegment', etc | ||
const segmentationParameters = { | ||
marketSegment: ms ?? marketSegment, | ||
offerType: ot ?? offerType, | ||
customerSegment: cs ?? customerSegment, | ||
productArrangementCode: pa ?? productArrangementCode, | ||
quantity: items?.[0]?.quantity > 1 ? items?.[0]?.quantity : undefined, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: store |
||
addonProductArrangementCode: productArrangementCode | ||
? items?.find((item) => item.productArrangementCode !== productArrangementCode)?.productArrangementCode | ||
: items?.[1]?.productArrangementCode, | ||
}; | ||
addParameters(segmentationParameters, url.searchParams, ALLOWED_KEYS); | ||
if (url.searchParams.get('ot') === 'PROMOTION') url.searchParams.delete('ot'); | ||
url = add3in1Parameters({ | ||
url, | ||
modal, | ||
customerSegment, | ||
marketSegment, | ||
cs, | ||
ms, | ||
quantity: items?.[0]?.quantity > 1 && items?.[0]?.quantity, | ||
productArrangementCode, | ||
addonProductArrangementCode: productArrangementCode | ||
? items?.find((item) => item.productArrangementCode !== productArrangementCode)?.productArrangementCode | ||
: items?.[1]?.productArrangementCode, | ||
is3in1, | ||
}); | ||
} | ||
return url.toString(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: paramter > parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will fix it in the follow up pr, thx!