-
Notifications
You must be signed in to change notification settings - Fork 613
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
fix(storefront): STRF-4701 - Fixed a use case that prevented retail/sale prices from displaying on PDP #1262
Changes from all commits
5de8070
8dd15c2
58f8388
e839bbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,6 +268,7 @@ | |
} | ||
|
||
.price--rrp, | ||
.price--non-sale, | ||
.price--discounted { | ||
text-decoration: line-through; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
{{#and price.retail_price_range.min.without_tax price.retail_price_range.max.without_tax}} | ||
<div class="price-section price-section--withTax" {{#if schema_org}}itemprop="offers" itemscope itemtype="http://schema.org/Offer"{{/if}}> | ||
<span data-product-price-without-tax class="price price--rrp">{{price.retail_price_range.min.without_tax.formatted}} - {{price.retail_price_range.max.without_tax.formatted}}</span> | ||
{{#if schema_org}} | ||
<meta itemprop="availability" content="{{product.availability}}"> | ||
<meta itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/{{product.condition}}Condition"> | ||
<div itemprop="priceSpecification" itemscope itemtype="http://schema.org/PriceSpecification"> | ||
<meta itemprop="minPrice" content="{{price.retail_price_range.min.without_tax.value}}" /> | ||
<meta itemprop="price" content="{{price.retail_price_range.min.without_tax.value}}"> | ||
<meta itemprop="maxPrice" content="{{price.retail_price_range.max.without_tax.value}}" /> | ||
<meta itemprop="priceCurrency" content="{{currency_selector.active_currency_code}}"> | ||
<meta itemprop="valueAddedTaxIncluded" content="true"> | ||
</div> | ||
{{/if}} | ||
{{#and price.retail_price_range.min.with_tax price.retail_price_range.max.with_tax}} | ||
<div class="price-section price-section--withTax rrp-price--withTax" {{#if schema_org}}itemprop="offers" itemscope itemtype="http://schema.org/Offer"{{/if}}> | ||
{{theme_settings.pdp-retail-price-label}} | ||
<span data-product-rrp-price-with-tax class="price price--rrp">{{price.retail_price_range.min.with_tax.formatted}} - {{price.retail_price_range.max.with_tax.formatted}}</span> | ||
</div> | ||
{{else}} | ||
{{#if price.with_tax}} | ||
<div class="price-section price-section--withTax rrp-price--withTax" style="display: none;"> | ||
{{theme_settings.pdp-retail-price-label}} | ||
<span data-product-rrp-with-tax class="price price--rrp"> | ||
{{price.rrp_with_tax.formatted}} | ||
</span> | ||
</div> | ||
{{/if}} | ||
{{/and}} | ||
{{#and price.price_range.min.with_tax price.price_range.max.with_tax}} | ||
<div class="price-section price-section--withTax non-sale-price--withTax" style="display: none;"> | ||
{{theme_settings.pdp-non-sale-price-label}} | ||
<span data-product-non-sale-price-with-tax class="price price--non-sale"> | ||
{{price.non_sale_price_with_tax.formatted}} | ||
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. Price range, I think, is associated with calculated_price which I think would be like "sale price" in this context? worth double checking, but I'm assuming if you dont have a range then you want to display the more closely associated price value. 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. The "price_range" we generate will take any sale price that is affecting a variant into account. As a result the "price range" which we are displaying in the This "sale price" HTML block we have here though is not intended to display a price range. It is specifically to for use for displaying the "non-sale price" of a variant after making option selections on the page. 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. I must be confused about something, it seems like if options are selected, then what we want to be showing is 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. Once options are selected we do want to show the |
||
</span> | ||
</div> | ||
<div class="price-section price-section--withTax" {{#if schema_org}}itemprop="offers" itemscope itemtype="http://schema.org/Offer"{{/if}}> | ||
<span class="price-label">{{theme_settings.pdp-price-label}}</span> | ||
<span class="price-now-label" style="display: none;">{{theme_settings.pdp-sale-price-label}}</span> | ||
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. same concern here with the 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. You will see the page load with a price range which then changes to an individual price if you have default option selections enabled on the product and it has a price range. This is the same issue that exists right now, this PR unfortunately does not address that issue. I don't think that I can correct this JS loading issue by just adding an "unless" statement here. I'd either need to add some logic that tries to identify if there are any default options selected (which can be parsed from the option value content in the page context) or I would need to add a new property to the context that gives me this information (a 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. If you have a suggestion on how to use the "unless" though that maybe I am missing then lets discuss. |
||
<span data-product-price-with-tax class="price">{{price.price_range.min.with_tax.formatted}} - {{price.price_range.max.with_tax.formatted}}</span> | ||
{{#and price.price_range.min.without_tax price.price_range.max.without_tax}} | ||
<abbr title="{{lang 'products.including_tax'}}">{{lang 'products.price_with_tax' tax_label=price.price_range.min.tax_label}}</abbr> | ||
|
@@ -33,8 +40,31 @@ | |
{{/if}} | ||
</div> | ||
{{/and}} | ||
{{#and price.retail_price_range.min.without_tax price.retail_price_range.max.without_tax}} | ||
This comment was marked as resolved.
Sorry, something went wrong. 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. I moved the |
||
<div class="price-section price-section--withoutTax rrp-price--withoutTax" {{#if schema_org}}itemprop="offers" itemscope itemtype="http://schema.org/Offer"{{/if}}> | ||
{{theme_settings.pdp-retail-price-label}} | ||
<span data-product-rrp-price-without-tax class="price price--rrp">{{price.retail_price_range.min.without_tax.formatted}} - {{price.retail_price_range.max.without_tax.formatted}}</span> | ||
</div> | ||
{{else}} | ||
{{#if price.without_tax}} | ||
<div class="price-section price-section--withoutTax rrp-price--withoutTax {{#if price.with_tax}}price-section--minor{{/if}}" style="display: none;"> | ||
{{theme_settings.pdp-retail-price-label}} | ||
<span data-product-rrp-price-without-tax class="price price--rrp"> | ||
{{price.rrp_without_tax.formatted}} | ||
</span> | ||
</div> | ||
{{/if}} | ||
{{/and}} | ||
{{#and price.price_range.min.without_tax price.price_range.max.without_tax}} | ||
<div class="price-section price-section--withoutTax non-sale-price--withoutTax {{#if price.with_tax}}price-section--minor{{/if}}" style="display: none;"> | ||
{{theme_settings.pdp-non-sale-price-label}} | ||
<span data-product-non-sale-price-without-tax class="price price--non-sale"> | ||
{{price.non_sale_price_without_tax.formatted}} | ||
</span> | ||
</div> | ||
<div class="price-section price-section--withoutTax {{#and price_range.min.with_tax price_range.max.with_tax}}price-section--minor{{/and}}" {{#if schema_org}}itemprop="offers" itemscope itemtype="http://schema.org/Offer"{{/if}}> | ||
<span class="price-label">{{theme_settings.pdp-price-label}}</span> | ||
<span class="price-now-label" style="display: none;">{{theme_settings.pdp-sale-price-label}}</span> | ||
<span data-product-price-without-tax class="price price--withoutTax">{{price.price_range.min.without_tax.formatted}} - {{price.price_range.max.without_tax.formatted}}</span> | ||
{{#and price.price_range.min.with_tax price.price_range.max.with_tax}} | ||
<abbr title="{{lang 'products.excluding_tax'}}">{{lang 'products.price_without_tax' tax_label=price.price_range.min.tax_label}}</abbr> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,24 @@ | |
{{> components/products/price-range price=price schema_org=schema_org}} | ||
{{else}} | ||
{{#if price.with_tax}} | ||
<div class="price-section price-section--withTax rrp-price--withTax"> | ||
{{#if price.rrp_with_tax}} | ||
{{lang 'products.retail_price'}} | ||
<span data-product-rrp-with-tax class="price price--rrp"> {{price.rrp_with_tax.formatted}}</span> | ||
{{/if}} | ||
<div class="price-section price-section--withTax rrp-price--withTax" {{#unless price.rrp_with_tax}}style="display: none;"{{/unless}}> | ||
{{theme_settings.pdp-retail-price-label}} | ||
<span data-product-rrp-with-tax class="price price--rrp"> | ||
{{price.rrp_with_tax.formatted}} | ||
</span> | ||
</div> | ||
<div class="price-section price-section--withTax non-sale-price---withTax"> | ||
{{#if price.non_sale_price_with_tax}} | ||
{{lang 'products.price_was'}} | ||
<span data-product-non-sale-price-with-tax class="price price--rrp"> {{price.non_sale_price_with_tax.formatted}}</span> | ||
{{/if}} | ||
<div class="price-section price-section--withTax non-sale-price--withTax" {{#unless price.non_sale_price_with_tax}}style="display: none;"{{/unless}}> | ||
{{theme_settings.pdp-non-sale-price-label}} | ||
<span data-product-non-sale-price-with-tax class="price price--non-sale"> | ||
{{price.non_sale_price_with_tax.formatted}} | ||
</span> | ||
</div> | ||
<div {{#if schema_org}}itemprop="offers" itemscope itemtype="http://schema.org/Offer"{{/if}}> | ||
<span class="price-now-label"> | ||
{{#if price.non_sale_price_with_tax}} | ||
{{lang 'products.price_now'}} | ||
{{/if}} | ||
<div class="price-section price-section--withTax" {{#if schema_org}}itemprop="offers" itemscope itemtype="http://schema.org/Offer"{{/if}}> | ||
<span class="price-label" {{#if price.non_sale_price_with_tax}}style="display: none;"{{/if}}> | ||
{{theme_settings.pdp-price-label}} | ||
</span> | ||
<span class="price-now-label" {{#unless price.non_sale_price_with_tax}}style="display: none;"{{/unless}}> | ||
{{theme_settings.pdp-sale-price-label}} | ||
</span> | ||
<span data-product-price-with-tax class="price"> {{price.with_tax.formatted}}</span> | ||
{{#if schema_org}} | ||
|
@@ -31,30 +32,31 @@ | |
</div> | ||
{{/if}} | ||
{{#if price.without_tax}} | ||
<abbr title="{{lang 'products.excluding_tax'}}">{{lang 'products.price_with_tax' tax_label=price.tax_label}}</abbr> | ||
<abbr title="{{lang 'products.including_tax'}}">{{lang 'products.price_with_tax' tax_label=price.tax_label}}</abbr> | ||
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. 🙃 im not sure whats going on here: the if check block is 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. Yep, this is specifically for the use case of displaying both including and excluding tax prices on the page. When the condition passes we have both price including and excluding tax in our context. In such a case we want to display identifying text after the price Using this specific line as an example, we have immediately before this point printed the price including tax. So if the context also has a price excluding tax, then we need to print |
||
{{/if}} | ||
</div> | ||
{{/if}} | ||
{{#if price.without_tax}} | ||
<div class="price-section rrp-price--withoutTax price-section--withoutTax {{#if price.with_tax}}price-section--minor{{/if}}"> | ||
{{#if price.rrp_without_tax}} | ||
{{lang 'products.retail_price'}} | ||
<span data-product-rrp-price-without-tax class="price price--rrp"> {{price.rrp_without_tax.formatted}}</span> | ||
{{/if}} | ||
<div class="price-section price-section--withoutTax rrp-price--withoutTax {{#if price.with_tax}}price-section--minor{{/if}}" {{#unless price.rrp_without_tax}}style="display: none;"{{/unless}}> | ||
{{theme_settings.pdp-retail-price-label}} | ||
<span data-product-rrp-price-without-tax class="price price--rrp"> | ||
{{price.rrp_without_tax.formatted}} | ||
</span> | ||
</div> | ||
<div class="price-section non-sale-price---withoutTax price-section--withoutTax {{#if price.with_tax}}price-section--minor{{/if}}"> | ||
{{#if price.non_sale_price_without_tax}} | ||
{{lang 'products.price_was'}} | ||
<span data-product-non-sale-price-without-tax class="price price--rrp"> {{price.non_sale_price_without_tax.formatted}}</span> | ||
{{/if}} | ||
<div class="price-section price-section--withoutTax non-sale-price--withoutTax {{#if price.with_tax}}price-section--minor{{/if}}" {{#unless price.non_sale_price_without_tax}}style="display: none;"{{/unless}}> | ||
{{theme_settings.pdp-non-sale-price-label}} | ||
<span data-product-non-sale-price-without-tax class="price price--non-sale"> | ||
{{price.non_sale_price_without_tax.formatted}} | ||
</span> | ||
</div> | ||
<div {{#if schema_org}}itemprop="offers" itemscope itemtype="http://schema.org/Offer"{{/if}}> | ||
<span class="price-now-label"> | ||
{{#if price.non_sale_price_without_tax}} | ||
{{lang 'products.price_now'}} | ||
{{/if}} | ||
<div class="price-section price-section--withoutTax" {{#if schema_org}}itemprop="offers" itemscope itemtype="http://schema.org/Offer"{{/if}}> | ||
<span class="price-label" {{#if price.non_sale_price_without_tax}}style="display: none;"{{/if}}> | ||
{{theme_settings.pdp-price-label}} | ||
</span> | ||
<span class="price-now-label" {{#unless price.non_sale_price_without_tax}}style="display: none;"{{/unless}}> | ||
{{theme_settings.pdp-sale-price-label}} | ||
</span> | ||
<span data-product-price-without-tax class="price price--withoutTax"> {{price.without_tax.formatted}}</span> | ||
<span data-product-price-without-tax class="price"> {{price.without_tax.formatted}}</span> | ||
{{#if schema_org}} | ||
<meta itemprop="availability" itemtype="http://schema.org/ItemAvailability" | ||
content="http://schema.org/{{#if product.pre_order}}PreOrder{{else if product.out_of_stock}}OutOfStock{{else if product.can_purchase '===' false}}OutOfStock{{else}}InStock{{/if}}"> | ||
|
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.
is there a benefit of using these over
lang
? should thelang
strings be removed now?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.
The benefit is easier access to changing these values by a client. It allows them to set the value they want via the "Theme Customization" setting. It looks like this:
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.
very nice, dont want to remove the old strings from whatever lang files where in it before?
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.
Thanks for the reminder! I will do that. I had meant to run a search on those language values and make sure they are not used elsewhere, then remove them if not.