3

Edit When adding more than one of the same product to the cart, the qty obviously increases, but it is possible to treat one or more products separately. Ie, if i add product A twice, it shows up as two separate products in the cart? // end edit

I have done the following.

1) Included order_custom1 and 2 on checkout. I use 1 to generate a random string which serves as the gift card number. I use 2 to save the value of the gift card (the item sub total)

2) Since the custom fields are inside the {items} tag pair, they are duplicated for each product (gift card) in the cart. However I'm beginning to think that it's not possible to submit more than one of each custom field, and that they are really supposed to be outside the {items} pair, is this correct?

The reason I ask is because when I output the custom fields in the order overview, I am only able to get the values saved within the last custom field (1 and 2). This is despite outputting them inside the {items} pair.

edit

If i can only submit this once per checkout, is there a way to only allow one product from a specific channel to be in the cart per order? In other words, can i force the user to only be allowed one "gift card" per order?

2

Correct, the order custom fields belong to the order, not individual line items, so they will be the same for all items.

A better way to approach this would be to generate the random string (gift card token) when you add the individual product to the cart, using modifiers. Store will always merge duplicate products into a single line item, however if they have different modifiers then they will not be merged.

You can start by using custom text modifiers in your product tag:

{exp:store:product entry_id="123" input:code="Gift Code"}

    <input type="hidden" name="code" value="random-string" />
    <input type="hidden" name="item_qty" value="1" />
    <input type="submit" value="Add to Cart" />

{/exp:store:product}

To let customers choose a price, you can either create modifiers on the publish page, or simply create unique products for each price, or you can enable "dynamic product prices" for the channel field, and let customers submit a price field.

Then, in your cart, each item will have a different unique code, and will appear as a separate line item on the invoice. Using this method you won't need to use order custom fields.

  • Aha, excellent. Can I see the code on the invoice, but can I output it inside {items} in the customers order overview (frontend template)? Better yet, can I output it next to the item in the cart so I can use channel:form to submit it where i want it to go? – Stian Karlsen Feb 10 '14 at 10:10
  • Never mind, {modifiers} {modifier_value}<br> {/modifiers} did the trick – Stian Karlsen Feb 10 '14 at 10:19
  • These will be used for physical gift cards, but as a bonus, is there a way to make channel form submit a discount code in store as well? – Stian Karlsen Feb 10 '14 at 10:33
  • How do you mean "submit" a discount code? Use it when paying for an order, or do you want to actually create it in the database? – Adrian Macneil Feb 10 '14 at 22:50
  • Wouldn't it have to be created in order to be used? What I mean is, now I have a setup where the discount codes are stores as channel entries so the customers can use them in the physical store (I used channel:form for that), but in addition, could they be created as discount codes in Store as well? – Stian Karlsen Feb 12 '14 at 13:35

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.