Shopify themes, liquid, logos, and UX
Hello.
We have part numbers which contain hashtag, like this:
RRP584#Sport
We only want to display the part number up to the hashtag, we don't want anything including and after the hashtag to be displayed, like this:
RRP584
We display the part number (SKU) like this:
<div class="Sku">
Part number:
{% assign current_variant = product.selected_or_first_available_variant %}
<span class="variant-sku">{{ current_variant.sku }}</span>
</div>
Is there some logic we can add to do this?
Thanks
Solved! Go to the solution
This is an accepted solution.
Try this code
<div class="Sku">
Part number:
{% assign current_variant = product.selected_or_first_available_variant %}
{% assign sku = current_variant.sku | split: "#" %}
<span class="variant-sku">{{ sku.first }}</span>
</div>
Try it and let me know
Hello @BenPF
Could you please share your store URL or the page link ( with a pass if your store password is enabled ). I think I can give you the right solution.
I checked, the code you used is correct
The content displayed is the content entered in the SKU
You should type content with only the content you want
eg: RRP584
Hello yes, but we would only like to display the part number before the #
This is an accepted solution.
Try this code
<div class="Sku">
Part number:
{% assign current_variant = product.selected_or_first_available_variant %}
{% assign sku = current_variant.sku | split: "#" %}
<span class="variant-sku">{{ sku.first }}</span>
</div>
Try it and let me know
Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025