How to add code behind a button in a new page based on a new template?

Hi everyone,

I’m using the Dawn 2.0 theme, I added before some logic in the main-product.liquid file to show/hide the Add to Cart button in the product page depending on a certain condition. I need to do something similar but for a button in a new page created out of a new template. I was expecting to find a liquid file for that newly created page or template where I could enter the necessary code but I only find a json file in the templates section, I’ll be grateful if someone can tell me where I can enter the code.

Thank you,

Mike

Hi Mike,

If you’ve created a new page using a new template in Shopify, you should be able to find the corresponding Liquid file under the “Templates” section in your Shopify theme editor. If you only see a JSON file, that might be because the new page is not using a Liquid template, but rather a JSON template.

To add logic to your new page, you’ll need to find the appropriate Liquid or JSON file in your theme editor. If you’re not sure which file corresponds to your new page, you can check the “page” attribute in the JSON file. It should have the same name as your new page.

Once you’ve found the correct file, you can add your logic to show/hide the button just like you did with the main-product.liquid file. If you’re working with a Liquid file, you can use Liquid syntax to add the necessary code. If you’re working with a JSON file, you’ll need to use JSON syntax instead.

I hope this helps! Let me know if you have any other questions.

1 Like

Hi Ignelis,

Thank you for your reply.

I created the template based on the default page but there’s no choice to select either liquid or json file:

As per your suggestion, I tried to find the Page attribute in the json file but there’s no such attribute in the file.

Do you know by any chance how to convert the following liquid logic to json?

{% unless customer.tags contains ‘appstle_subscription_active_customer’ %}

<button

{% else %}

Note: To swap toys click here and then click on the “See details button”.

{% endunless %}

Thanks a lot,

Mike