-
Notifications
You must be signed in to change notification settings - Fork 8
[COM-38695] Port product-price formatter from template-compiler #31
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
[COM-38695] Port product-price formatter from template-compiler #31
Conversation
| }); | ||
|
|
||
| loader.paths('f-product-quick-view-%N.html').forEach((path) => { | ||
| test(`product quick view - ${path}`, () => loader.execute(path)); |
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.
All of the new tests in this file and all of the related test files were ported over from template-compiler (tests, test templates)
| }; | ||
|
|
||
| export class ProductPriceFormatter extends Formatter { | ||
| private static BILLING_PERIOD_MONTHLY = 'MONTH'; |
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.
This was ported from the ProductPriceFormatter in template-compiler
| const first = variants.get(0); | ||
| let moneyNode = isTruthy(first.path(['onSale'])) ? first.path(['salePriceMoney']) : first.path(['priceMoney']); | ||
| let price = getAmountFromMoneyNode(moneyNode); | ||
| if (price === undefined) { |
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.
This condition is never true because getAmountFromMoneyNode always returns a Node
| return DEFAULT_MONEY_NODE; | ||
| } | ||
| let moneyNode = variants.get(0); | ||
| let moneyNode = variants.get(0).path(['priceMoney']); |
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.
This was an existing bug that I found from product-price tests failing. The corresponding line in template-compiler is here
|
@jmariconda I created a PR #32 to remove the |
|
@phensley Sounds good. I misread that at first and merged the first PR in the stack, but I'll leave the rest for you |
|
Also add lodash package for access to the `capitalize` util
4aea92e to
bf39a96
Compare
|
@sizhang12 @jmariconda All of your changes are released in version |
Ticket: COM-38695
Prerequisite PRs
Description
Port product-price template, formatter, unimplemented commerce utils, and test cases from template-compiler
NOTE: There are a lot of files changed, but most are just test templates that were ported from template-compiler. The main changes are in
src/plugins.Reasoning
The Commerce Merchandising team is currently working on a project to port the product list and detail pages over to the SDK, and as a result of that, those sections are now going through the client-side rendering pipeline on edit. Because of this, we need this formatter implemented in template engine so that the section re-renders properly on edit
NOTE: There will be a follow-up PR for the product-price formatter as well, so it might be good to wait on a release until then @phensley
Tests