3

My client has gift wrapping services but they apply to the entire order, not one single line item.

How would I add notes or custom fields to the entire order, at the shipping stage of checkout? is this possible without a plugin?

I tried to apply notes and giftwrapping options to the first line item by using the commerce/cart/updateLineItem form, on the cart.lineItems.first() but it didn't work. I presume that after the user proceeds to checkout the line Items no longer exist?

2

You could create a special product for the gift wrapping and offer to add it to the cart during the checkout process with a separate updateCart form.

As for the notes, you can add a custom field to your order as described in the following: How can I update custom order fields in the frontend

  • Two very good answers here! I like the idea of it being a product especially as it makes more of a feature and could show what gift wrapping looks like. (This is for luxury products) – ToddPadwick Nov 11 '17 at 12:52
  • Yep, lets you add variations and options for different gift wrapping too. :) – foamcow Nov 13 '17 at 10:16
2

First, add a custom field to your orders, let's call it orderNotes.

Then, in any updateCart form, you can use an input with name="fields[orderNotes]" to set the value of that field.

(Line items persist on the cart until the end of checkout. At that point they become a saved snapshot of those line items on the completed order.)

<form method="POST" >
       {{ getCsrfInput() }}
       <input type="hidden" name="action" value="commerce/cart/updateCart">
       <input type="text" name="fields[orderNotes]">
       ...etc
1

You can also add it to the cart.lineItems[].options:

<form method="POST" >
    {{ getCsrfInput() }}
    <input type="hidden" name="action" value="commerce/cart/updateCart">
    <input type="hidden" name="purchasables[{{ purchasable.id }}][id]" value="{{ purchasable.id }}">
    <input type="number" name="purchasables[{{ purchasable.id }}][qty]">

    // custom option
    <input name="purchasables[{{ purchasable.id }}][options][giftWrapping]" value="YES!">

</form>

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.