Re: Split SKU into different numbers

Split SKU into different numbers

Andersreilly
Shopify Partner
1 0 0

Hi, 
Hope anybody can help here! 🙂 

So to start off with my SKU for products in Shopify is setup this way: 100880\99000\34 .

The first number being the style number (100880), Second number is colour (99000) and the last is the size (34). 

 

I would like to split the SKU into only style and colour number so (100880\99000), which should be used to pass onto a third party software. So far i have used this code:

{%- liquid assign parts = product.variants.first.sku | split: '\\' -%}
{%- liquid assign result = parts[0] | append: '\\' | append: parts[1] | split: '\\' | first -%}

 

But it still sends the product as the whole SKU. Anybody that can help solve this issue? 🙂

 

Reply 1 (1)

Liam
Community Manager
3108 340 871

If you try the following, is it working for you?

 

{%- assign parts = product.variants.first.sku | split: '\\' -%}
{%- assign result = parts[0] | append: '\\' | append: parts[1] -%}

 (without additional splitting and selecting of the first part)

Liam | Developer Advocate @ 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 Shopify.dev or the Shopify Web Design and Development Blog