0

Would there be a way in Expresso Store to pre populate a cart with certain products?

And even better, to populate the cart based on a link? E.g to send a link to a customer and when the customer clicks the link he is taken to the cart with products X, Y and Z already in the cart?

0

I would recommend populating an Expresso Add to Cart form (Docs), making the form elements hidden and styling the submit button to look like a link, seems the most straight forward way...

Here's an example from the Docs, that I have modified to suit. The below example will add 1 of every product in the channel entry loop :

{!-- start the product form --}
{exp:store:product_form}
  {!-- iterates the products channel --}
  {exp:channel:entries channel="products"}
    {!-- individual product form elements --}
    {exp:store:product entry_id="{entry_id}" disable_form="yes"}

      <input type="hidden" name="items[{count}][entry_id]" value="{entry_id}" />
      <input type="hidden" name="items[{count}][item_qty]" value="1" />

    {/exp:store:product}
  {/exp:channel:entries}

  {!-- Form submit, looks like a link --}
  <input type="submit" value="Add to Cart" style="background-color:transparent; text-decoration:underline; border:none; color:blue; cursor:pointer;" />

{/exp:store:product_form}

To select the products use the entry_id Tag on the exp:channel:entries loop.

If you wanted to go 'off the reservation' you could construct the post array in PHP and submit it to the relivent ACTion ID or Expresso Store Model function, put the code on a seperate template and link to that template, but thats another ball game, and Expresso probsbly won't recommend it!! :D

1
  • confused... apparently I got -15 points for this answer today, why has the answer tick been unaccepted? Is there a further issue with this? Anything we can help with?? – Blatant Jun 17 '15 at 15:45

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.