How to add code to only one product page

New Member
9 0 0

Hi,

 

I have been editing the code on my store to insert subtitles under the product name and an image as a product description. But the changes show up on all my products, how do I just apply the code to one product?

0 Likes
Shopify Partner
1156 133 204

You can add a conditional and match on product handle. Say your product page URL you want the customization to apply looks like:

/products/my-super-product

then in the liquid code you can have:

{% if product.handle == 'my-super-product' %}
... add the bits of customizations ...
{% endif %}

this will execute only for this specific product.

 

Alternatively, you can have a separate product template assigned to this one product and have the customizations reflected in the template. But first approach would be simpler.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Shopify Staff
Shopify Staff
381 45 82

Hey, @nlim391 

 

Lizzy here, from Shopify.

 

@Visely-Team is absolutely right, in that you can either tweak your code in the original product template, or create an alternate template. 

 

The second option is a bit more complicated, but may be faster if this change applies to multiple products. The template you build can be copied code from your orignal product template, with any adjustments you need added in. Once built, you can change any product in your store to use the alternate template, while keeping others using the original. You can read more about using alternate templates here, if the solution sounds like it could work!

 

Depending on the exact change you'd like to make, you may also be able to alter the HTML of the product description to get it set up. You can access this in the Rich Text Editor in your product pages within the admin. Click on this button to switch to HTML mode and edit away!


17-18-shufi-p44yl


Is this addition something that you're using to help explain your products to customers? Or is it an organizational features for your store at all?

 

Thank you!

Lizzy | Social Care @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

0 Likes