Where to find code of add to card button in Theme Taste

Hi,

I’m using the Shopify Theme Taste and I would like to find out where I can find the code of the add to card button at my product pages. I would like to add something to the code. I can’t find it in main.product.liquid or theme.liquid. The code starts with <button type=submit

The code should be in product.liquid, product-template.liquid, or product-form.liquid, but I can’t find the code.

Thank you so much in advance.

Hello @Franny1 ,

It’s in snippets/buy-buttons.liquid.

Thanks

Hi Guleria,

Thank you for your help.

We also need to add a code after the ending of the script in the same snippets to make the changes work, but we can only find at the end of the code but we don’t think it’s the right .

Could you help us out? We want to work with Pinterest and want Pinterest to track the add to card data for us.

This is the information I got:

Add to Cart Event

  1. Look for the code files named product.liquid, product-template.liquid,
    or product-form.liquid and open them. Where you can find the ‘add-to-cart code’ depends
    depends on the theme you have installed.
  2. If you have a ‘sticky add-to-cart’, also search for this file.
  3. Search within the files for ‘addtocart’. Sometimes you have multiple ‘add-to-cart’
    buttons’ or even a ‘sticky-add-to-cart’.
  4. Found it? Add the following code within all or elements
    (just before the closing caret):
    onclick=“atcPin()”
  5. At the bottom of the product-template.liquid file (or whatever the section is called), paste the
    following code:

Hoping you can help me, thank you in advance.

Please replace whole file code snippets/buy-buttons.liquid with this one

{% comment %}
  Renders product buy-buttons.
  Accepts:
  - product: {Object} product object.
  - block: {Object} passing the block information.
  - product_form_id: {String} product form id.
  - section_id: {String} id of section to which this snippet belongs.
  - show_pickup_availability: {Boolean} for the pickup availability. If true the pickup availability is rendered, false - not rendered (optional).

  Usage:
  {% render 'buy-buttons', block: block, product: product, product_form_id: product_form_id, section_id: section.id, show_pickup_availability: true %}
{% endcomment %}

  {%- if product != blank -%}
    {%- liquid
      assign gift_card_recipient_feature_active = false
      if block.settings.show_gift_card_recipient and product.gift_card?
        assign gift_card_recipient_feature_active = true
      endif

      assign show_dynamic_checkout = false
      if block.settings.show_dynamic_checkout and gift_card_recipient_feature_active == false
        assign show_dynamic_checkout = true
      endif
    -%}

    
  {%- else -%}
    

      

        
      

    

  {%- endif -%}

  {%- if show_pickup_availability -%}
    {{ 'component-pickup-availability.css' | asset_url | stylesheet_tag }}

    {%- assign pick_up_availabilities = product.selected_or_first_available_variant.store_availabilities
      | where: 'pick_up_enabled', true
    -%}

    

    
  {%- endif -%}

I’m sorry the code is not working, the add to card button is showing a liquid error line 103 and it says it could not find asset snippets/loading-spinner.liquid

Seems you are using different version of the theme.

Can you share your file code so i can make changes in it ?

This is the code at the moment:

{% comment %}
Renders product buy-buttons.
Accepts:

  • product: {Object} product object.
  • block: {Object} passing the block information.
  • product_form_id: {String} product form id.
  • section_id: {String} id of section to which this snippet belongs.
  • show_pickup_availability: {Boolean} for the pickup availability. If true the pickup availability is rendered, false - not rendered (optional).

Usage:
{% render ‘buy-buttons’, block: block, product: product, product_form_id: product_form_id, section_id: section.id, show_pickup_availability: true %}
{% endcomment %}

{%- if product != blank -%} {%- liquid assign gift_card_recipient_feature_active = false if block.settings.show_gift_card_recipient and product.gift_card? assign gift_card_recipient_feature_active = true endif

assign show_dynamic_checkout = false
if block.settings.show_dynamic_checkout and gift_card_recipient_feature_active == false
assign show_dynamic_checkout = true
endif
-%}

{%- form ‘product’,
product,
id: product_form_id,
class: ‘form’,
novalidate: ‘novalidate’,
data-type: ‘add-to-cart-form’
-%}
<input
type=“hidden”
name=“id”
value=“{{ product.selected_or_first_available_variant.id }}”
disabled
class=“product-variant-id”

{%- if gift_card_recipient_feature_active -%}
{%- render ‘gift-card-recipient-form’, product: product, form: form, section: section -%}
{%- endif -%}

{%- liquid assign check_against_inventory = true if product.selected_or_first_available_variant.inventory_management != 'shopify' or product.selected_or_first_available_variant.inventory_policy == 'continue' assign check_against_inventory = false endif if product.selected_or_first_available_variant.quantity_rule.min > product.selected_or_first_available_variant.inventory_quantity and check_against_inventory assign quantity_rule_soldout = true endif -%} {%- if product.selected_or_first_available_variant.available == false or quantity_rule_soldout -%} {{ 'products.product.sold_out' | t }} {%- else -%} {{ 'products.product.add_to_cart' | t }} {%- endif -%}
{%- if show_dynamic_checkout -%} {{ form | payment_button }} {%- endif -%}
{%- endform -%} {%- else -%}
{{ 'products.product.sold_out' | t }}
{%- endif -%}

{%- if show_pickup_availability -%}
{{ ‘component-pickup-availability.css’ | asset_url | stylesheet_tag }}

{%- assign pick_up_availabilities = product.selected_or_first_available_variant.store_availabilities
| where: ‘pick_up_enabled’, true
-%}

<pickup-availability
class=“product__pickup-availabilities no-js-hidden quick-add-hidden”
{% if product.selected_or_first_available_variant.available and pick_up_availabilities.size > 0 %}
available
{% endif %}
data-root-url=“{{ routes.root_url }}”
data-variant-id=“{{ product.selected_or_first_available_variant.id }}”
data-has-only-default-variant=“{{ product.has_only_default_variant }}”

{% render 'icon-unavailable' %}

{{ 'products.product.pickup_availability.unavailable' | t }}

{{ 'products.product.pickup_availability.refresh' | t }}

{%- endif -%}

Please update with this one

{% comment %}
Renders product buy-buttons.
Accepts:
- product: {Object} product object.
- block: {Object} passing the block information.
- product_form_id: {String} product form id.
- section_id: {String} id of section to which this snippet belongs.
- show_pickup_availability: {Boolean} for the pickup availability. If true the pickup availability is rendered, false - not rendered (optional).

Usage:
{% render 'buy-buttons', block: block, product: product, product_form_id: product_form_id, section_id: section.id, show_pickup_availability: true %}
{% endcomment %}

{%- if product != blank -%}
{%- liquid
assign gift_card_recipient_feature_active = false
if block.settings.show_gift_card_recipient and product.gift_card?
assign gift_card_recipient_feature_active = true
endif

assign show_dynamic_checkout = false
if block.settings.show_dynamic_checkout and gift_card_recipient_feature_active == false
assign show_dynamic_checkout = true
endif
-%}

{%- else -%}

{%- endif -%}

{%- if show_pickup_availability -%}
{{ 'component-pickup-availability.css' | asset_url | stylesheet_tag }}

{%- assign pick_up_availabilities = product.selected_or_first_available_variant.store_availabilities
| where: 'pick_up_enabled', true
-%}

{%- endif -%}