Skip to content

Instantly share code, notes, and snippets.

@bakura10
Last active April 4, 2023 01:10
Show Gist options
  • Save bakura10/d52b0491ff17ecf5d01cb5c0cc5214b2 to your computer and use it in GitHub Desktop.
Save bakura10/d52b0491ff17ecf5d01cb5c0cc5214b2 to your computer and use it in GitHub Desktop.
Impact

⚠️ EDIT April 4th: we have been informed that the root cause has been solved at Shopify level. Those fixes are therefore not needed anymore as every store should be working normally again.

⚠️ Merchants who already upgraded to the 4.0.6 or newer do not need to apply those changes.

Starting from 1st April 2023, Shopify rolled out a change that broke our theme Impact. What is happening is that we were using the {{ 'now' | date: '%N' }} filter in Liquid to generate a unique ID (%N being nanoseconds and allows to have a unique ID each time it is called).

Unfortunately, Shopify seems to have broke this, with the same date being returned all the time, which lead to no longer generate unique ID. We are currently working with Shopify to hope that they can restore the old behavior to prevent breakage.

To fix this, we need to change the logic in various files. This document shows the various changes:

snippet checkbox.liquid

Replace (around line 23):

{%- capture id -%}checkbox-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture id -%}checkbox-{{ section.id }}-{{ form }}-{{ context}}-{{ name | handle }}-{{ value | handle }}{%- endcapture -%}

snippet horizontal-product.liquid

Replaces:

{%- capture quick_buy_id -%}quick-buy-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture quick_buy_id -%}quick-buy-{{ section.id }}-{{ product.id }}{%- endcapture -%}

snippet input.liquid

Replaces (around line 27):

{%- capture id -%}input-{{ section.id }}-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture id -%}input-{{ section.id }}-{{ form }}-{{ name | handle }}{%- endcapture -%}

snippet localization-selector.liquid

Replaces:

{%- capture localization_form_id -%}localization-form-{{ 'now' | date: '%N' }}{%- endcapture -%}
{%- capture localization_popover_id -%}popover-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture localization_form_id -%}localization-form-{{ type }}-{{ popover_vertical_position }}-{{ section.id }}{%- endcapture -%}
{%- capture localization_popover_id -%}popover-localization-form-{{ type }}-{{ popover_vertical_position }}-{{ section.id }}{%- endcapture -%}

snippet product-card.liquid

Replaces (around line 105):

{%- capture quick_buy_id -%}quick-buy-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture quick_buy_id -%}quick-buy-{{ section.id }}-{{ product.id }}{%- endcapture -%}

Replaces (around line 174):

{%- capture name -%}swatch-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture name -%}swatch-{{ section.id }}-{{ product.id }}-{{ product_option.position }}{%- endcapture -%}

snippet select.liquid

Replaces (around line 21):

{%- capture id -%}select-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture id -%}select-{{ section.id }}-{{ form }}-{{ name | handle }}{%- endcapture -%}

snippet swatch.liquid

Replaces (around line 36):

{%- capture id -%}swatch-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture id -%}swatch-{{ section.id }}-{{ form }}-{{ context }}-{{ name | handle }}-{{ value | handle }}{%- endcapture -%}

snippet variant-picker.liquid

Replaces (around line 74):

{%- capture popover_id -%}popover-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture popover_id -%}popover-variant-picker-{{ section.id }}-{{ product.id }}-{{ option.position }}{%- endcapture -%}

snippet navigation-promo-block.liquid

Replaces (around line 3):

{%- capture promo_id -%}{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture promo_id -%}{{ mega_menu_block.id }}{% if is_navigation_drawer %}-drawer{% endif %}-{{ link_col }}{%- endcapture -%}

Replaces (around line 220):

{%- capture carousel_id -%}promo-carousel-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture carousel_id -%}promo-carousel-{{ promo_id }}{%- endcapture -%}

snippet facets-vertical.liquid

Replaces (around line 20):

{%- capture id_prefix -%}facets-{{ section.id }}{%- endcapture -%}

By:

{%- capture context -%}{% if update_on_change %}sidebar{% else %}drawer{% endif %}{%- endcapture -%}
{%- capture id_prefix -%}facets-{{ context }}-{{ section.id }}{%- endcapture -%}

Replaces (around line 49):

{%- render 'checkbox', type: 'radio', label: option.name, name: 'sort_by', value: option.value, checked: checked -%}

By:

{%- render 'checkbox', type: 'radio', label: option.name, name: 'sort_by', value: option.value, checked: checked, context: context -%}

Replaces (around line 103):

{% render 'swatch' with 'color', allow_multiple: true, selected: filter_value.active, value: filter_value.label, name: filter_value.param_name, disabled: disabled, show_tooltip: true %}

By:

{% render 'swatch' with 'color', allow_multiple: true, selected: filter_value.active, value: filter_value.label, name: filter_value.param_name, disabled: disabled, show_tooltip: true, context: context %}

Replaces (around line 120):

{%- render 'checkbox', label: label, name: filter_value.param_name, value: filter_value.value, checked: filter_value.active, disabled: disabled -%}

By:

{%- render 'checkbox', label: label, name: filter_value.param_name, value: filter_value.value, checked: filter_value.active, disabled: disabled, context: context -%}

snippet "collection-top-bar.liquid"

Replaces (around line 44):

{%- capture id_prefix -%}facets-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture id_prefix -%}facets-{{ section.id }}{%- endcapture -%}

Replaces (around line 115):

{%- capture checkbox_id -%}checkbox-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture checkbox_id -%}checkbox-{{ section.id }}-{{ filter_value.param_name }}-{{ forloop.index }}{%- endcapture -%}

Replaces (around line 133):

{%- capture sort_by_popover_id -%}popover-{{ 'now' | date: '%N' }}{%- endcapture -%}

By:

{%- capture sort_by_popover_id -%}popover-sort-by-{{ section.id }}{%- endcapture -%}
@bakura10
Copy link
Author

bakura10 commented Apr 3, 2023

@yahalomer , you're correct... Sorry, I am adding that right now!

@bakura10
Copy link
Author

bakura10 commented Apr 3, 2023

This is done @yahalomer ! The changes are outlined in the collection-top-bar.liquid

@yahalomer
Copy link

@bakura10 Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment