Liquid, JavaScript, themes, sales channels
Hey folks,
Trying to generate a unique hash in JS using md5 to use as a part of a cart line item duplication feature I'm developing.
First, we sell laser engraved products, so in our add-to-cart process we capture text information from the customer which is added to the properties of a line item in the cart.
I have a button that when clicked reads the current line items line_item.id, grabs the json object matching the id, creates a new JSON object and POSTs to add.js. As you can suspect, this simply increments the line item by 1.
My desired behavior is to simply duplicate that line item including the custom properties the customer has added and add it to the cart as a new, but identical, line item. I looked at the cart JSON after I added two identical product/variant combo's with identical text customization in its properties. The only difference between these two line items was the key (variant_id:md5hash). So I pass that object in as the hash and notice for the value of key. Again, its still only incrementing the qty +1.
Thoughts on what I'm doing wrong?
Thanks!
Solved! Go to the solution
This is an accepted solution.
Looks like that was the wrong approach. I had to create unique information in the properties so I adjusted the timestamp field we had - boom worked.
This is an accepted solution.
Looks like that was the wrong approach. I had to create unique information in the properties so I adjusted the timestamp field we had - boom worked.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024