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?
Solved! Go to the solution