Skip to content

Commit

Permalink
Updated html update utility to not clone node, updated buy buttons to…
Browse files Browse the repository at this point in the history
… display 'unavailable' if the underlying variant is nil
  • Loading branch information
lhoffbeck committed May 21, 2024
1 parent 96a0d21 commit 00780c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions assets/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ class HTMLUpdateUtility {
viewTransition(oldNode, newContent) {
this.#preProcessCallbacks.forEach((callback) => callback(newContent));

const newNode = oldNode.cloneNode();
HTMLUpdateUtility.setInnerHTML(newNode, newContent.innerHTML);
const newNodeWrapper = document.createElement('div');
HTMLUpdateUtility.setInnerHTML(newNodeWrapper, newContent.outerHTML);
const newNode = newNodeWrapper.firstChild;
oldNode.parentNode.insertBefore(newNode, oldNode);
oldNode.style.display = 'none';

Expand Down
4 changes: 3 additions & 1 deletion snippets/buy-buttons.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@
{% endif %}
>
<span>
{%- if product.selected_or_first_available_variant.available == false or quantity_rule_soldout -%}
{%- if product.selected_or_first_available_variant == nil -%}
{{ 'products.product.unavailable' | t }}
{%- elsif product.selected_or_first_available_variant.available == false or quantity_rule_soldout -%}
{{ 'products.product.sold_out' | t }}
{%- else -%}
{{ 'products.product.add_to_cart' | t }}
Expand Down

0 comments on commit 00780c0

Please sign in to comment.