Score:0

How to add variations of a product to the cart if only the first variation have all attr values

hk flag

Consider a product. For example it has 5 different colors that is 5 product variations. But all other values of the product's attributes (size, weight etc.) are the same for all the variations of the product regardless of the color. That is all 5 variations of the same product have the same weight e.g. 2 kg.

Unfortunately, the module Drupal Commerce allows a buyer in the front-end to select by clicking radio input of a color and add corresponding variation of the product to the cart only if before I as an admin selected and saved in the admin panel the appropriate values of ALL the attributes for ALL the variations of the same product.

So, if there are for example 5 colors of the same product and the product has a weight e.g. 2 kg, in the admin panel I'm forced to open the first variation of the product, select 2 kg and for example red color, save them, then open the second variation of the same product and in total repeat all the actions 5 times, but selecting another color only.

But again, why if all the variations of the product has the same weight of 2 kg and all other attrs (except color) have also the same values as other variations of the same product? It doesn't make any sense.

So, as a developer I configured the template of the product details page to display only all the attribute values of the first variation of the product. And in the admin panel I selected and saved the attr values for the first variation only and for other variations of the same product I only selected the value of the attr color which differs for each variation (before I unchecked the checkbox "Required field" for all the attributes).

But now at the product details page in the AddToCartForm I see only the radio button of the first color (of the first product variation) and therefore can add to the cart only the first variation of the product.

The question is, how to enable the AddToCartForm to display the radio buttons of other colors and therefore enable buyers to add to the cart any of the product's variations?

p.s. Is this related to something like "purchasable entity" ?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.