This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% comment %} | |
Returns the color code most contrasted with the given color. | |
Accepts: | |
color {Hex color} - The background color of the element. Defaults to #ffffff. | |
black {Hex color} - The first color we calculate the contrast with. Defaults to #000000. (Optional) | |
white {Hex color} - The second color we calculate the constrast with. Defaults to #ffffff. (Optional) | |
Usage: | |
{% render 'color-contrast', color: section.settings.background_color %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% comment %} | |
- I have a product with a variant metafield containing associated cross-sell product list | |
- Objective is to show cross-sell products associated with the variant | |
- Second objective was to use object construction to remove complexity in markup | |
- Inside the markup, we need the product reference for data population as well as the variant IDs which needs to show the cross sell card (used by Javascript) | |
{% endcomment %} | |
{% liquid | |
# First, we make a duplicate-free list of cross-sell products | |
assign cross_sell_product_list = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% # Snippet documentation comment %} | |
{%- comment -%} | |
Renders the template name based on the template object. | |
Accepts: | |
- template {Template object} - Template object | |
Usage: | |
{% render 'template-name' %} | |
{%- endcomment -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% # Checking the presence of a block %} | |
{% liquid | |
assign announcement_block_list = section.blocks | where: 'type', 'announcement' | |
if announcement_block_list == empty | |
# Take action to prepare fallback content | |
endif | |
%} | |
///////////////////////////////////////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% comment %} | |
In this case, the merchant, for UX testing would like subscription products to be on top of the cart drawer, followed by the one-time purchase items. | |
Usually, we would have two forloops inside the markup, with their distinctive conditions in order to sort the different products. | |
Instead, we will prepare all the necessary data beforehand and loop over the more explicit arrays in the markup. | |
For performance, in place of two for loops over the items, we only have one. In more critical use-cases, several ms are gained. | |
For readability and maintenability, we have a DRY declaration at defined location which makes it more maintainable and readable. | |
Note: The arrays are constructed using a for loop, a common pattern that works pretty well ! | |
{% endcomment %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% # Cart filters testing %} | |
{% liquid | |
# A small liquid snippet to compare the two new filters from what was possible before | |
# See https://shopify.dev/docs/api/liquid/filters/cart-filters for reference | |
# Quite redundant in my opinion as this is basically sugar but maybe they'll find their audience | |
assign targetProduct = all_products['product-handle'] | |
assign productId = targetProduct.id | |
assign targetVariant = targetProduct.selected_or_first_available_variant | |
assign variantId = targetVariant.id |
NewerOlder