I'm working on a custom basket field that saves attribute data on a sku, so I can fill in the options on product page if the customer goes back to the product page to make changes.
I have this working, but only if I have one of that sku in the basket. I can't get the custom basket field to rewrite with if there's another line item.
On the basket page, in the code for the products options, I have this:
So if that option is on the line item, it will read the current custom basket field, and if it doesnt match the option data in the basket field, it should re-write the field with its data.
I've displayed the basket fields on the line items to see what data its showing and its like this-
Line 1 - Make Model Option data = abc; Custom basket field = 123
Line 2 - Make Model Option data = 123; Custom basket field = abc
I think what's happening is the first line item doesn't match the basket field, so it rewrites. And now the 2nd line item doesn't match it because it was just rewritten, so it rewrites it again. Any ideas on how I can set this up?
I have this working, but only if I have one of that sku in the basket. I can't get the custom basket field to rewrite with if there's another line item.
On the basket page, in the code for the products options, I have this:
HTML Code:
<mvt:elseif expr="( l.settings:option:attr_code EQ 'MakeModel' )"> <mvt:item name="customfields" param="Read_Basket( 'makeModel', g.makeModel )" /> <strong>&mvt:option:attr_prompt;:</strong> &mvt:option:data; - &mvt:global:makeModel; <mvt:assign name="g.optionData" value="l.settings:option:data" /> <mvt:if expr="g.makeModel NE g.optionData"> <mvt:item name="customfields" param="Write_Basket( 'makeModel', l.settings:option:data )" /> </mvt:if>
I've displayed the basket fields on the line items to see what data its showing and its like this-
Line 1 - Make Model Option data = abc; Custom basket field = 123
Line 2 - Make Model Option data = 123; Custom basket field = abc
I think what's happening is the first line item doesn't match the basket field, so it rewrites. And now the 2nd line item doesn't match it because it was just rewritten, so it rewrites it again. Any ideas on how I can set this up?
Comment