Add to Cart Button

Hi. I am using the Dawn 2.0 theme. I want to change the add to cart button to ‘hire now’ for specific products, not the entire store.
I assume this is done through creating a custom page template within the code, however am not sure of how and what to change the code to have it say ‘Hire now’

I would also like to do an another similar change, i would like to change the add to cart button to link to a contact page fo other specific products.

Please let me know if this is possible and how to do so. My website URL is https://93d862.myshopify.com/password

password is stecew

thanks in advance

Hi @Ryanxanthopoulo , this is possible. You should add specific tags to your products (one way of doing this). For example, for products that you want to show ‘Hire now’ you can add tag ‘hire’.
Then go to edit code > snippets > buy-buttons.liquid find this:


              {%- 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 -%}
            

And replace it with:


              {%- if product.selected_or_first_available_variant.available == false or quantity_rule_soldout -%}
                {{ 'products.product.sold_out' | t }}
              {%- else -%}
{% assign productTags = product.tags | join: ', ' %}
               {% if productTags contains 'hire' %}
Hire now
{% else %}
                {{ 'products.product.add_to_cart' | t }}
{%endif%}
              {%- endif -%}
            

Hi Marina,

Thank you for the quick response. I will try this shortly and let you know.

Could you please also let me know if it is possible to change the add to cart button to a ‘contact’ link for other specific products.

thanks again

@MarinaPetrovic

Yeah, of course. In that case you can add tag, for example, ‘contact’ to those products and add additional condition in your code:


              {%- if product.selected_or_first_available_variant.available == false or quantity_rule_soldout -%}
                {{ 'products.product.sold_out' | t }}
              {%- else -%}
{% assign productTags = product.tags | join: ', ' %}
               {% if productTags contains 'hire' %}
Hire now
{% elsif productTags contains 'contact' %}
Contact us
{% else %}
                {{ 'products.product.add_to_cart' | t }}
{%endif%}
              {%- endif -%}
            

This has worked to have it display contact, however once clicking the button t is still adding an item to the cart and not linking to the contact page?

Once we resolve this, I have a few further questions, is it easiest to continue asking on here or should i personally message?

Thanks Marina, I really appreciate your help?

Hi @Ryanxanthopoulo , replace your file buy-buttons.liquid with this:

{% 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, show_pickup_availability: true %} 

{% endcomment %} 

 

  {%- if product != blank -%} 

     

  {%- 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 -%}