Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi,
I am new to Shopify so apologies if this is obvious.
I have added a size chart to my products. I created the page and added a block to the default products in the Dawn Template. All is working well.
I only want to show the block with the pop up link for a specific Vendor. For others, I don't want to display the block.
Could somebody please point me in the right direction?
Many thanks in advance..
Solved! Go to the solution
This is an accepted solution.
No worries, this isn’t too complicated. Here’s how you can show the size chart block only for products from a specific vendor:
Go to Shopify Admin: Click on “Online Store” and then “Themes.”
Edit Code: Find your Dawn theme, click “Actions,” and then “Edit code.”
Find Product Template: Look for product.liquid or main-product.liquid under the “Templates” or “Sections” folder.
Add Conditional Code: Locate the section where you added the size chart block. You’ll need to wrap it in an if statement to check for the specific vendor.
For example:
{% if product.vendor == "YourVendorName" %}
<!-- Your size chart block code here -->
{% endif %}
Save Your Changes: Click “Save” to apply the update.
Replace "YourVendorName" with the actual name of the vendor you want to target. This code will ensure the size chart block only appears for products from that vendor.
There is currently no high level system for conditional settings/blocks/section show/hide behavior with in shopifys visual theme editor(designer).
Only what the themes developers built in or you customize with code.
Use alternate templates https://help.shopify.com/en/manual/online-store/themes/os20/theme-structure/templates#create-a-new-t...
Otherwise as a band-aid use a custom-liquid block or section to add conditional style for CSS that hides the link.
You will have to figure out the CSS selector that targets the link/button/element.
{% if product.vendor == "vendorname" %}
<style>
/* custom CSS here */
</style>
{% endif %}
Spelling and case sensitivity matters for the vendor name
If you need this customization then contact me by my email for services.
Contact info in forum signature.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.
Good Hunting.
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
This is an accepted solution.
No worries, this isn’t too complicated. Here’s how you can show the size chart block only for products from a specific vendor:
Go to Shopify Admin: Click on “Online Store” and then “Themes.”
Edit Code: Find your Dawn theme, click “Actions,” and then “Edit code.”
Find Product Template: Look for product.liquid or main-product.liquid under the “Templates” or “Sections” folder.
Add Conditional Code: Locate the section where you added the size chart block. You’ll need to wrap it in an if statement to check for the specific vendor.
For example:
{% if product.vendor == "YourVendorName" %}
<!-- Your size chart block code here -->
{% endif %}
Save Your Changes: Click “Save” to apply the update.
Replace "YourVendorName" with the actual name of the vendor you want to target. This code will ensure the size chart block only appears for products from that vendor.
In the end... I added the Size Popup section to my product theme. I could not find the Size element in the liquid code. However, when I browsed to the page, I found that the popup was wrapped in a class called "modal-opener".
I then edited sections/main-product.liquid and searched for the wrapping class "modal-opener" and I added the vendor condition:
{% if product.vendor == "vendor" %}
<modal-opener class="product-popup-modal__opener no-js-hidden quick-add-hidden" data-modal="#PopupModal-{{ block.id }}"{{ block.shopify_attributes }}>
<button id="ProductPopup-{{ block.id }}" class="product-popup-modal__button link" type="button" aria-haspopup="dialog">
{{ block.settings.text | default: block.settings.page.title }}
</button>
</modal-opener>
{%- endif -%}
I just need to be careful - this will stop all popups for the vendor.. I now want to figure out how to just do it for a specific link text..
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024