I'm searching a way to replace the dropDown menu (like on the image lipstick-2.jpg ) in the add to cart form of Commerce by images (in my case ) the different colors of a product (like on this image lipstick-3.jpg ).
I didn't find a module so I'm on the point to start writing my first module and guess what ... i see your module-description.

Are you thinking of create a feature like this in your module ?

lipstick-2.jpg is what i created in D7+Commerce
lipstick-3.jpg is what I need to make for my client.

(Btw, when I use "git clone http://git.drupal.org/sandbox/ryan.armstrong/1146154.git commerce_cart_options" I get the commerce_cart_options.info file. )

tnx

CommentFileSizeAuthor
lipstick-3.jpg83.3 KBlatulipeblanche
lipstick-2.jpg89.1 KBlatulipeblanche

Comments

latulipeblanche’s picture

The module works fine.

Now I'll try to rewrite the uc_radio_images module (patch for D7 > http://drupal.org/node/1140634) for DC.

With the module "commerce_cart_options" I changed the dropDown-list in radio buttons. Next I put a image, representing the color to replace the radio-button like this.

<?php 
function commerce_cart_options_form_alter(&$form, &$form_state, $form_id) {
	if (strpos($form_id, 'commerce_cart_add_to_cart_form_') === 0) {
		$form['submit']['#value'] = t('Add to Cart');
		$form['product_id']['#type'] = 'radios';
		$form['product_id']['#options'][5] = '<img src="/path/to/image/product_images/colors/tshirt-red.jpg" />';
		$form['product_id']['#options'][6] = '<img src="/path/to/image/product_images/colors/tshirt-orange.jpg" />';
	}
}

But this is static.
What I need is that to get the links to be dynamicaly instead of static, relative to the url. The url looks like this : ~/content/tshirt .

In this line : $form['product_id']['#options'][5] = 'Only local images are allowed.'; the
[5] and the URL must be generated dynamicaly.

latulipeblanche’s picture

latulipeblanche’s picture

Status: Active » Closed (fixed)

closed while solution is described here http://drupal.org/node/1180016