line_item.instance_variable_set Alternative OR How can I restrict product quantity

Hello All,

In the script editor we have the ability with the line_item instance_variable_set() method the ability to alter the quantity of a given line item in the cart.

Say for example for a specific product the limit is one per purchase, but in the cart the customer tries to adjust the quantity from 1 to 2, with instance_variable_set I could test it the quantity was greater than 1 and reset it back to 1.

Is there a similar function to do this with the new cart transform api or similar?

Thanks for your help,

Gary