I’m trying to figure out if there is a way to create a metafield that pulls the first two digits of a SKU.
I’m trying to run a report that shows the quantity of line items sold by the first two digits of the SKU.
I assumed a metafield would be the way to go about this, but I may be wrong, as I’m entirely new to metafields. Any help would be appreciated.
Thanks!
You don’t necessarily need a metafield for this! You can achieve this directly in your Liquid code when generating your report. Here’s how you can extract the first two digits of the SKU:
{% assign first_two_digits = line_item.sku | slice: 0, 2 %}
{{ first_two_digits }}
Then, in your report generation, you can group or filter by this first_two_digits variable. This avoids the need for a metafield altogether, which simplifies things
Thanks so much for your reply. Where do I add it to the code?
I’m using the Xporter app to run my reports. Will I be able to access this is a field there?
Thanks again!
sorry but I’m not familiar with that app