2
Answers
Vote up!
0
Vote down!

How to remove blank options from Add to Cart forms?

I've used Feeds to import individual products from a large CSV export (that our store point of sale system generates).

Feeds translates fields for "SizeName" and "Colour" in the CSV to products associated with taxonomy vocabularies, which is then used with the add to cart form.

However, not all items need to use these fields (if they don't have different sizes or colours associated). Unfortunately, the Feeds Importer created some blank terms associated with these products. I need the importer to "Auto create" the term if it's not blank, but to leave it empty if it is.

Also: I was able to set up views bulk operations to find and manually remove the blank taxonomy terms from the "size" and "colour" vocabularies. However, add to cart forms are still displaying with empty terms?

How do I stop blank terms from being imported while still allowing the association or auto-creation of new "sizes", "colours" and "options"?

How do I remove blank / empty options from add to cart forms?

Asked by: JemBijoux
on August 2, 2013

2 Answers

Vote up!
1
Vote down!

The Add to Cart form constructs the options for attribute widgets from the values actually used by products on the form. If I have 4 sizes but only reference 3 sizes of products for a form, that fourth size option just shouldn't appear. This means your form must be including products that still reference these blank terms.

That said, you may have some luck using Feeds Tamper to prevent the creation of these empty terms in the first place. I know it can be used to massage import data into the proper format, but I don't know for certain it can be used to prevent something like the creation of a taxonomy term.

Ryan Szrama
Answer by: Ryan Szrama
Posted: Aug 5, 2013
Vote up!
0
Vote down!

Rules is the way

Create a rule type "Before saving an item imported via Product {type}"

Conditions:
Entity has field -> commerce-product -> field_size
Data value is empty -> commerce-product:field-size:name

Actions:
Execute custom PHP code
unset($commerce_product->field_size);

and then, another rule like this but looking if field_color is empty

Answer by: edu
Posted: Nov 1, 2013