Is there a way to mimic the add item to cart so a product(subscription) is added to cart during a registration process? In short I wanted to automatically add item in the cart using Expresso Store, that is if it's possible.
2 Answers
It is possible to add a product to the cart by simply visiting a page so upon successful registration you could redirect them to a success page which then adds the subscription item to their cart in the background.
It can be achieved by using AJAX to POST directly to Store's action URL. You simply add the add the product tag to the page as normal and then using JavaScript to make the submission automatically. Along these lines:
$("#productform").submit()
Where #productform
is the ID of your form.
This can either be hidden or visible.
You could also use the Product Form Tag so that you can add multiple items to the cart with a single Add to Cart form and submit button. You would need to have something along the lines of:
{exp:store:product entry_id="{subscription_entry_id}"}
<input type="hidden" value="1" name="item_qty" />
{/exp:store:product}