I have a whole mess of products that allow a customer to choose if they want personalization or not. If they do select personalization, then the price of that product goes up $15. I am passing through the attributes so that only those types of products are targeted. The problem I am facing is that if I have those products already in the cart that fit the criteria, when a customer adds another product to the cart, with the same criteria, it will update the price on all the products, again…that fit that criteria. Which obviously is not desired, in this case.
I need to figure out how to only target the product being added to the cart, or updated in the cart. Some things I’ve tried:
- Unique strings. Timestamp or other, but there’s no way to dynamically get the string in the run script to match up. And since the transform runs in sandbox, there’s no way to get the current timestamp.
- Global cart attribute. I was setting a cart attribute to have all the current line item keys. So, theoretically if the existing cart attribute had the current cart keys, and a new product was added to the cart, in my script, I would compare the attribute with what was in the cart. It would see that the new one didn’t exist, so it would update just that price. Well, that doesn’t work since the cart item key is not the same as a line item ID. And from what I can tell, there’s no way to get the key in the transform. I can’t use the product ID, since there might be different variations of the same ID in the cart, which would result in all of those updating.
Another idea would to have a temporary line item property that once a product was added, I would remove it. So any subsequent adds, it would see that those properties didn’t exist, and only update the one with that property. While it could work, if a customer decides to update the quantity in their cart, that property wouldn’t be there, so that price wouldn’t be updated.
Sorry for being so long-winded, but there has to be a better solution for this. I would imagine this isn’t the first time that this has been the desired action.
Appreciate any insight/help.