chrisglass/django-shop-simplevariations — Issue #11: Text Option "Text" not honored when adding the same Text
Author: sn-devdev
Created: 2011-11-21 15:00:31+00:00
State: open

Hi

I am trying to get simplevariations to work in a given environment which requires exactly one text option (an engraving) and when I tryed to add the same product with the same text it was added to the same but product with another text, in fact always the first cart item of this product with whatever text option was used.

A quick look in the source code revealed (views.py ca line 50):

if len(cartitemoptions) + len(cartitemtxtoptions) == (len(option_ids) + len(text_option_ids)):
found_cartitem_id = cartitem.id
merge = True
break

So the actual value of the text is not honored currently.

This is my fix

if len(cartitemoptions) + len(cartitemtxtoptions) == (len(option_ids) + len(text_option_ids)):
## sn devdev fix
if len(text_option_ids):
for key, value in text_option_ids.items():
for opt in cartitemtxtoptions:
if value == opt.text:
found_cartitem_id = cartitem.id
merge = True
break
else:
found_cartitem_id = cartitem.id
merge = True
break
## end sn devdev fix

I hope you will find this useful.

Best, G