3
Answers
Vote up!
0
Vote down!

Add to cart button separate from add to cart form

Hi!
I am trying something and it's being difficult.
I have a store. Each product has two taxonomy items for customizing the product client want to buy.
As you know, these settings and the add to cart button are both in the add to cart form.
What I need is to separate the options and the add to cart button. I have tryed to display the add to cart form not displaying the button by css an create a block with a custom filter with the add to cart form so I will have two add to cart forms in the same node.
In the block, I hided the options so I finally have separated the add to cart button and the options.
What happens is that if you choose any option for customizing the product, the add to cart form which is in the field of the node disapears.
At the end, what I need is to separate the add to cart button from the add to cart form.
Any idea
Thanks a lot

Fernando Zabaleta
on May 22, 2015

3 Answers

Vote up!
0
Vote down!

this support is nonexistetn, what a shame, no posts are being answered, is this a joke? I will wait one more day, then I am going back to ubercart, at least they answer to support questions

bob geldof
Answer by: bob geldof
Posted: May 26, 2015
Vote up!
0
Vote down!

exactly bob geldof me too is looking since few months, that they should give reply to wait at least...!!!

swapnil samrit
Answer by: swapnil samrit
Posted: May 28, 2015
Vote up!
0
Vote down!

I picked around for ages trying to get this working. The dirty hack is create a view and include a 'product' field which links to the add to cart form.

I ended up adding code to my templates/node--product--type.tpl.php file (because that was were I wanted to use it). The code looked like this:

$prod_id = $field_product[0]['product_id'];
$quantity = 1;
$prod = commerce_product_load($prod_id);
$line_item = commerce_product_line_item_new($prod, $quantity);
$line_item->data['context']['product_ids'] = array($prod_id);
$form = drupal_get_form('commerce_cart_add_to_cart_form', $line_item);
$add_to_cart_link = drupal_render($form);

You might need to manually specify the $prod_id

Dan Todd
Answer by: Dan Todd
Posted: Jun 23, 2015