Skip to content

Commit

Permalink
Fix Add to Cart error on page load/slower connections (#3008)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoboludo authored Oct 5, 2023
1 parent 7ee3da2 commit a64da0f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion assets/product-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ if (!customElements.get('product-form')) {
}

if (!this.error)
publish(PUB_SUB_EVENTS.cartUpdate, { source: 'product-form', productVariantId: formData.get('id'), cartData: response });
publish(PUB_SUB_EVENTS.cartUpdate, {
source: 'product-form',
productVariantId: formData.get('id'),
cartData: response,
});
this.error = false;
const quickAddModal = this.closest('quick-add-modal');
if (quickAddModal) {
Expand Down
4 changes: 3 additions & 1 deletion snippets/buy-buttons.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
type="hidden"
name="id"
value="{{ product.selected_or_first_available_variant.id }}"
disabled
{% if product.selected_or_first_available_variant.available == false or quantity_rule_soldout %}
disabled
{% endif %}
class="product-variant-id"
>

Expand Down
4 changes: 3 additions & 1 deletion snippets/card-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@
name="id"
value="{{ card_product.selected_or_first_available_variant.id }}"
class="product-variant-id"
disabled
{% if card_product.selected_or_first_available_variant.available == false %}
disabled
{% endif %}
>
<button
id="{{ product_form_id }}-submit"
Expand Down

0 comments on commit a64da0f

Please sign in to comment.