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:
SKU: {{ item.variant.sku }}
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!
1 Like
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 %}
SKU: {{ item.variant.sku }}
{% endunless %}
or
{% if item.variant.sku %}
SKU: {{ item.variant.sku }}
{% endif %}
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!
1 Like
is this good?
{{ item.sku }}
( i think you get line_item as the item )
Hi @OpalProducts
change code on line 45 to this:
SKU: {{ item.sku }}
or
SKU: {{ line_item.sku }}
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
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:
SKU: {{ item.sku }}
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!