Hey Everyone ! can we set the value of a custom fi...
# suitecommerce
j
Hey Everyone ! can we set the value of a custom field in the Cart component using the Frontend Extensibility API, similar to how we can perform actions like addLine or getLine. Also, is there a way to have two separate lines for the same item in the cart?
s
If you want identical items to be separate line items there will need to be something different about them or else NetSuite will combine them. The simplest way to do this is to set a custom transaction line field either on add or by updating it to a random string. As the strings will be different for each item, they will not combine.
j
can you please clearify more?
s
I am assuming that you are talking about situations where a customer adds two or more of the same item, yes? Such that it says quantity x 2 rather than have separate line items, each one saying x 1?
If so, NetSuite will always try to combine identical items together into a single line item and show the quantity
If you want to stop this behaviour, you need to give NetSuite a reason to do this, which means making the two identical items seem different
The easiest way to do this is to set a custom transaction item field on each of them, and ensure that that field value is different for each line
So you would create a custom transaction item field, called whatever you want, and then bind a script to the add to cart event such that it sets a random value for each of those items
In the UI, this field and value could be hidden from the user
j
okay, thanks man