Hi I am developing a site for T-shirt designing. I have a custom UI where all the T-shirt products in my site are loaded. customer can design the T-shirt according to their needs like changing color,adding text/image etc using my UI. At the end of UI I have a buy button where user can buy the custom product. How can I add this product to my Drupal cart when user clicks buy button? I have the product id and price loaded in my hand and am using Drupal commerce module in my site.

This is my button form

<button type="submit" class="btn btn-primary"  name="button">
                                Buy Now! </button>

1 Answer 1


I think you can done it using commerce_cart_product_add(). Pass product id and line item as parameters. For details please check here.Hope this will help you..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.