-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Show default price for placeholder content #3572
Changes from 1 commit
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 |
---|---|---|
|
@@ -567,6 +567,7 @@ | |
{%- else -%} | ||
{%- liquid | ||
assign ratio = 1 | ||
assign placeholder = true | ||
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. Is this 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. Yeah the |
||
if media_aspect_ratio == 'portrait' | ||
assign ratio = 0.8 | ||
endif | ||
|
@@ -610,7 +611,7 @@ | |
<span class="visually-hidden">{{ 'accessibility.vendor' | t }}</span> | ||
<div class="caption-with-letter-spacing light">{{ 'products.product.vendor' | t }}</div> | ||
{%- endif -%} | ||
{% render 'price', show_compare_at_price: true %} | ||
{% render 'price', placeholder: placeholder, show_compare_at_price: true %} | ||
</div> | ||
</div> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
Accepts: | ||
- product: {Object} Product Liquid object (optional) | ||
- placeholder: {Boolean} Renders a placeholder price (optional) | ||
- use_variant: {Boolean} Renders selected or first variant price instead of overall product pricing (optional) | ||
- show_badges: {Boolean} Renders 'Sale' and 'Sold Out' tags if the product matches the condition (optional) | ||
- price_class: {String} Adds a price class to the price element (optional) | ||
|
@@ -37,94 +38,97 @@ | |
endif | ||
-%} | ||
|
||
{%- unless target == nil -%} | ||
<div | ||
class=" | ||
price | ||
{%- if price_class %} {{ price_class }}{% endif -%} | ||
{%- if available == false %} price--sold-out{% endif -%} | ||
{%- if compare_at_price > price and product.quantity_price_breaks_configured? != true %} price--on-sale{% endif -%} | ||
{%- if compare_at_price > price and product.quantity_price_breaks_configured? %} volume-pricing--sale-badge{% endif -%} | ||
{%- if product.price_varies == false and product.compare_at_price_varies %} price--no-compare{% endif -%} | ||
{%- if show_badges %} price--show-badge{% endif -%} | ||
" | ||
> | ||
<div class="price__container"> | ||
{%- comment -%} | ||
Explanation of description list: | ||
- div.price__regular: Displayed when there are no variants on sale | ||
- div.price__sale: Displayed when a variant is a sale | ||
{%- endcomment -%} | ||
<div class="price__regular"> | ||
{%- if product.quantity_price_breaks_configured? -%} | ||
{%- if show_compare_at_price and compare_at_price -%} | ||
{%- unless product.price_varies == false and product.compare_at_price_varies %} | ||
<span class="visually-hidden visually-hidden--inline"> | ||
{{- 'products.product.price.regular_price' | t -}} | ||
</span> | ||
<span> | ||
<s class="price-item price-item--regular variant-item__old-price"> | ||
{% if settings.currency_code_enabled %} | ||
{{ compare_at_price | money_with_currency }} | ||
{% else %} | ||
{{ compare_at_price | money }} | ||
{% endif %} | ||
</s> | ||
</span> | ||
{%- endunless -%} | ||
{%- unless target == null and placeholder == null -%} | ||
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. Is the default value of an undefined liquid prop 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. 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. One thing I actually noticed which is minimal. But curious to know how we want to go about it. There is an issue where if you add a feat. collection to the product page, the placeholder product cards get a price that matches the currently selected variant. So I might keep the The other solution could be to keep your approach with
Cause when on a product template, it will always return the product object of the template as a fallback. Let me know what you think. cc: @Roi-Arthur @emma-boardman @lhoffbeck 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 I can see the theoretical improvement as it preserves the same example price 👍🏼 On the other hand, I think the important piece is to show any price (rather than none), and ultimately the example shouldn't stick around for too long. I also somewhat doubt that Merchants would go around changing the product to see how it affects the example. Overall I think I would go for the least amount of code/complexity but happy to go either way. 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. Readability wise, I prefer with 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. Ooh nice catch! Agree that while merchants may not notice, it'd be better to have consistent placeholder prices. And +1 for 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. Agree that 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.
Some of the placeholder content is also set at "higher" level sometimes. I do it mostly in the The other place using price where there is placeholder content is the feat. product. I just updated one more spot where I noticed the logic could be using the new |
||
<div | ||
class=" | ||
price | ||
{%- if price_class %} {{ price_class }}{% endif -%} | ||
{%- if available == false %} price--sold-out{% endif -%} | ||
{%- if compare_at_price > price and product.quantity_price_breaks_configured? != true %} price--on-sale{% endif -%} | ||
{%- if compare_at_price > price and product.quantity_price_breaks_configured? %} volume-pricing--sale-badge{% endif -%} | ||
{%- if product.price_varies == false and product.compare_at_price_varies %} price--no-compare{% endif -%} | ||
{%- if show_badges %} price--show-badge{% endif -%} | ||
" | ||
> | ||
<div class="price__container"> | ||
{%- comment -%} | ||
Explanation of description list: | ||
- div.price__regular: Displayed when there are no variants on sale | ||
- div.price__sale: Displayed when a variant is a sale | ||
{%- endcomment -%} | ||
<div class="price__regular"> | ||
{%- if product.quantity_price_breaks_configured? -%} | ||
{%- if show_compare_at_price and compare_at_price -%} | ||
{%- unless product.price_varies == false and product.compare_at_price_varies %} | ||
<span class="visually-hidden visually-hidden--inline"> | ||
{{- 'products.product.price.regular_price' | t -}} | ||
</span> | ||
<span> | ||
<s class="price-item price-item--regular variant-item__old-price"> | ||
{% if settings.currency_code_enabled %} | ||
{{ compare_at_price | money_with_currency }} | ||
{% else %} | ||
{{ compare_at_price | money }} | ||
{% endif %} | ||
</s> | ||
</span> | ||
{%- endunless -%} | ||
{%- endif -%} | ||
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span> | ||
<span class="price-item price-item--regular"> | ||
{{- | ||
'products.product.volume_pricing.price_range' | ||
| t: minimum: money_price_min, maximum: money_price_max | ||
-}} | ||
</span> | ||
{%- else -%} | ||
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span> | ||
<span class="price-item price-item--regular"> | ||
{{ money_price }} | ||
</span> | ||
{%- endif -%} | ||
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span> | ||
<span class="price-item price-item--regular"> | ||
{{- 'products.product.volume_pricing.price_range' | t: minimum: money_price_min, maximum: money_price_max -}} | ||
</span> | ||
{%- else -%} | ||
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span> | ||
<span class="price-item price-item--regular"> | ||
</div> | ||
<div class="price__sale"> | ||
{%- unless product.price_varies == false and product.compare_at_price_varies %} | ||
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span> | ||
<span> | ||
<s class="price-item price-item--regular"> | ||
{% if settings.currency_code_enabled %} | ||
{{ compare_at_price | money_with_currency }} | ||
{% else %} | ||
{{ compare_at_price | money }} | ||
{% endif %} | ||
</s> | ||
</span> | ||
{%- endunless -%} | ||
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.sale_price' | t }}</span> | ||
<span class="price-item price-item--sale price-item--last"> | ||
{{ money_price }} | ||
</span> | ||
{%- endif -%} | ||
</div> | ||
<div class="price__sale"> | ||
{%- unless product.price_varies == false and product.compare_at_price_varies %} | ||
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span> | ||
<span> | ||
<s class="price-item price-item--regular"> | ||
{% if settings.currency_code_enabled %} | ||
{{ compare_at_price | money_with_currency }} | ||
{% else %} | ||
{{ compare_at_price | money }} | ||
{% endif %} | ||
</s> | ||
</div> | ||
<small class="unit-price caption{% if product.selected_or_first_available_variant.unit_price_measurement == nil %} hidden{% endif %}"> | ||
<span class="visually-hidden">{{ 'products.product.price.unit_price' | t }}</span> | ||
<span class="price-item price-item--last"> | ||
<span>{{- product.selected_or_first_available_variant.unit_price | money -}}</span> | ||
<span aria-hidden="true">/</span> | ||
<span class="visually-hidden"> {{ 'accessibility.unit_price_separator' | t }} </span> | ||
<span> | ||
{%- if product.selected_or_first_available_variant.unit_price_measurement.reference_value != 1 -%} | ||
{{- product.selected_or_first_available_variant.unit_price_measurement.reference_value -}} | ||
{%- endif -%} | ||
{{ product.selected_or_first_available_variant.unit_price_measurement.reference_unit }} | ||
</span> | ||
</span> | ||
{%- endunless -%} | ||
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.sale_price' | t }}</span> | ||
<span class="price-item price-item--sale price-item--last"> | ||
{{ money_price }} | ||
</span> | ||
</small> | ||
</div> | ||
<small class="unit-price caption{% if product.selected_or_first_available_variant.unit_price_measurement == nil %} hidden{% endif %}"> | ||
<span class="visually-hidden">{{ 'products.product.price.unit_price' | t }}</span> | ||
<span class="price-item price-item--last"> | ||
<span>{{- product.selected_or_first_available_variant.unit_price | money -}}</span> | ||
<span aria-hidden="true">/</span> | ||
<span class="visually-hidden"> {{ 'accessibility.unit_price_separator' | t }} </span> | ||
<span> | ||
{%- if product.selected_or_first_available_variant.unit_price_measurement.reference_value != 1 -%} | ||
{{- product.selected_or_first_available_variant.unit_price_measurement.reference_value -}} | ||
{%- endif -%} | ||
{{ product.selected_or_first_available_variant.unit_price_measurement.reference_unit }} | ||
</span> | ||
{%- if show_badges -%} | ||
<span class="badge price__badge-sale color-{{ settings.sale_badge_color_scheme }}"> | ||
{{ 'products.product.on_sale' | t }} | ||
</span> | ||
</small> | ||
</div> | ||
{%- if show_badges -%} | ||
<span class="badge price__badge-sale color-{{ settings.sale_badge_color_scheme }}"> | ||
{{ 'products.product.on_sale' | t }} | ||
</span> | ||
|
||
<span class="badge price__badge-sold-out color-{{ settings.sold_out_badge_color_scheme }}"> | ||
{{ 'products.product.sold_out' | t }} | ||
</span> | ||
{%- endif -%} | ||
</div> | ||
{% endunless %} | ||
<span class="badge price__badge-sold-out color-{{ settings.sold_out_badge_color_scheme }}"> | ||
{{ 'products.product.sold_out' | t }} | ||
</span> | ||
{%- endif -%} | ||
</div> | ||
{% endunless %} |
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 any benefit to updating the existing placeholder logic on line 113 to use the same
placeholder
value, for consistency?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.
Done! Updated a couple instances to use the placeholder check.
We shall if that's the approach we take based on Arthur's feedback 👍