I need capability to pre-populate commerce cart using a link (preferably add to the cart if one already exists).

For example a link like http://aziteez.com/cart?add_product=prod1+prod2 should add prod1 and prod2 to the existing cart of the user on my website.

Thanks in advance.


You could use Rules for triggering an event on your link with Rules link event and maybe combine it with Rules Link to attach the link to your commerce order entities.

If you prefer to code, you'd need either to create a new menu using hook_menu or alter an existing one with hook_menu_alter and then use commerce_cart_product_add or commerce_cart_product_add_by_id to add the product to the cart user, you can retrieve the current cart from the user with commerce_cart_order_load

  • That looks promising. I am gonna try it out and let you know. – Gokul N K Oct 21 '13 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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