How to display only part of the product part number

Solved

How to display only part of the product part number

BenPF
Tourist
18 0 2

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

Accepted Solution (1)
ExpertRookie
Shopify Partner
1518 249 324

This is an accepted solution.

@BenPF 

 

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

- Was my reply helpful? Please Like and Accept Solution to let me know!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me on expert.rookie.team@gmail.com regarding any help.

View solution in original post

Replies 6 (6)

GemPages
Shopify Partner
5625 1262 1266

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.

GemPages - Build any high-converting store pages for any business


- If you find my reply helpful, please hit Like and Mark as Solution
- Get connected: App Store | Blog | Community | Help Center
BenPF
Tourist
18 0 2

Hi @GemPages 

URL is trade4x4.myshopify.com

GemPages
Shopify Partner
5625 1262 1266

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

GemPages - Build any high-converting store pages for any business


- If you find my reply helpful, please hit Like and Mark as Solution
- Get connected: App Store | Blog | Community | Help Center
BenPF
Tourist
18 0 2

Hello yes, but we would only like to display the part number before the #

ExpertRookie
Shopify Partner
1518 249 324

This is an accepted solution.

@BenPF 

 

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

- Was my reply helpful? Please Like and Accept Solution to let me know!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me on expert.rookie.team@gmail.com regarding any help.
BenPF
Tourist
18 0 2

@ExpertRookie that worked!! THANK YOU