How do I insert "Add to cart" button in my custom module?
Hello Experts,
I am new to Drupal Commerce and I am loving it. I have a unique requirement where my product is a Card Design, hence it needs a lots of customization, I have done the customizations part in my custom module. Now I would like to display an "Add to Cart" button in my custom module, clicking which that product and (X) number of quantity should be added to the Drupal Commerce Cart.
To make a note here is what I am looking for.
1- Add to cart button my my custom modules to template page where I know the product id, and upon clicking it, it should add the product to the cart. I also want to pass the number of quantity from the module it self.
2- Then it should take the user to the cart page.
Thanks in advance.
Comments
Have a look at the order_example at http://drupal.org/project/commerce_examples. It should have all you need to create your customized order. I used drupal_goto for my redirection.
Many thanks dear, I will have a look at it.
having another question here, using drupal_goto can I add a product to cart and it will redirect to the shopping cart page as well. Please advice. !
I was using drupal_goto('checkout/' . $order_id) to bypass the cart and proceed directly to checkout. The $order_id was returned when the order was created. In drupalcommerce, it seem that each user can own multiple carts, and each cart is linked to an order_id.
So you will need to redirect to the correct cart. There is also some kind of "default cart". Anyone can confirm this, maybe elaborate further?