3

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.

1 Answer 1

3

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

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

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.