Re: Add SKU into cart page

Solved

Add SKU into cart page

OpalProducts
Tourist
6 2 2

Hi there,

 

Just wondering if someone can advise. We're using the symmetry theme and trying to get the SKU to show on the cart page. 

 

I've added into the main.cart.liquid template the following code on line 45:

<span>SKU: {{ item.variant.sku }}</span>

This is now showing the variant SKU which we need to show, however if products are added to the cart that don't have variants then no SKU is displayed.

 

Can someone tell me what to edit so I can have this displayed as well?

 

Many thanks!

Accepted Solution (1)
OpalProducts
Tourist
6 2 2

This is an accepted solution.

Hi there,

 

Thank you for your suggestion, you helped me get to the solution myself!

 

I had to change it slightly, so I had to change the code to this:

<div class="variant"> SKU: {{ item.sku }}</div>

I had to move it up a few lines to drop underneath the top level products rather than having it after the variant details.

 

This means it still pulls through whether its a top level product or a variant.

 

Thank you for your help, we got there in the end!

View solution in original post

Replies 5 (5)

wisn_shaftler
Shopify Partner
9 0 0

do you want to hide the SKU: text if the variant does not have SKU?

 

if yes then change the line to something like this
{% unless item.variant.sku == blank %} 

<span>SKU: {{ item.variant.sku }}</span>

{% endunless %}

 

or

 

{% if item.variant.sku %}

<span>SKU: {{ item.variant.sku }}</span>

{% endif %}

WISNSHAFTLER
want to connect? send me DM or mail me, wisnshaftler@gmail.com
OpalProducts
Tourist
6 2 2

All of our variants have SKU's so that part is fine.

 

The problem I've got is when its just a standalone product with no variants then I can't get the SKU to show, if that makes sense?

 

Thank you for coming back to me!

wisn_shaftler
Shopify Partner
9 0 0

is this good? 

{{ item.sku }}

 

( i think you get line_item as the item )

WISNSHAFTLER
want to connect? send me DM or mail me, wisnshaftler@gmail.com

BSSCommerce-B2B
Shopify Partner
1307 340 406

Hi @OpalProducts 

change code on line 45 to this:

<span>SKU: {{ item.sku }}</span>

or

<span>SKU: {{ line_item.sku }}</span>

Hope this can help you,

If our suggestions are useful, please let us know by giving it a like or marking it as a solution. Thank you 

If our suggestions are useful, please let us know by giving it a like, marking it as a solution.


BSS: B2B Wholesale Solution |BSS: B2B Portal, Quote, Net 30 | B: B2B Lock Password Protect


Need help from our expert? Kindly share your request with us via community@bsscommerce.com


BSS Commerce - Full-service eCommerce Agency
OpalProducts
Tourist
6 2 2

This is an accepted solution.

Hi there,

 

Thank you for your suggestion, you helped me get to the solution myself!

 

I had to change it slightly, so I had to change the code to this:

<div class="variant"> SKU: {{ item.sku }}</div>

I had to move it up a few lines to drop underneath the top level products rather than having it after the variant details.

 

This means it still pulls through whether its a top level product or a variant.

 

Thank you for your help, we got there in the end!