Forum

Thread tagged as: Shop

Shop Gift Option / Shop Forms

Hi there!

Are there any suggested best practices for adding a gift message field / form to the checkout process?

I guess the primary requirement is that the contents of the form are posted to / associated with the particular order.

Thank you greatly!

Olympia Kyriakides

Olympia Kyriakides 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Any field with the cart-property attribute set show be saved with the order.

<perch:input type="textarea" id="gift_message" cart-property="gift_message" />

Thanks Drew!

Can the message be displayed at the order review step? I've not had luck with <perch:shop id="gift_message" />

I've also not completed a full order submission yet, with payment etc. Would the content of the form only post when the entire order is processed? I've not located my test gift message submissions anywhere.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't think there's a way to display cart properties back. If that's a requirement then I'm not sure we have a solution for it right now.

The cart properties can be set from any shop form.

Okay, thanks Drew.

I've notice that some shops do this in lieu of actually displaying the gift message back:

<?php
                if (perch_shop_cart_has_property('gift_invoice')) {

                    echo 'Gift Invoice: Yes';
                } else {
                    echo 'Gift Invoice: No';
                }

                ?>


                <?php
                if (perch_shop_cart_has_property('gift_message')) {

                    echo 'Gift Message: Yes';
                } else {
                    echo 'Gift Message: No';
                }

                ?>

The issue that I'm having now is with type="textarea" in my message form... I added app="perch_forms perch_shop" so that I can view the submissions in the forms app for now. Even when left blank, the textarea is being treated as a form submission with no contents. And in turn, is causing if (perch_shop_cart_has_property('gift_message')) to be TRUE, whether blank, or populated.

Is there a way to submit this single form without interpreting blank textarea as content?

This is my template:


<perch:label for="Gift Message"> <perch:input type="textarea" id="gift_message" cart-property="gift_message" /> </perch:label> <perch:label for="Gift Invoice Option"> <perch:input type="checkbox" value="true" id="gift_invoice" cart-property="gift_invoice" /> Select this box if you are sending a gift and would like to conceal the invoice. </perch:label> <div> <perch:input type="submit" id="submit" value="Continue" /> </div>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you saying perch_shop_cart_has_property() is returning true even if the property has no value?

Yes, but it only seems to be happening with text fields. The text portion of the form posts as if there is content even when blank, no (apparent) value; and the textarea always returns true for perch_shop_cart_has_property() --- when a value has been entered as well as when it's left blank.

I'm not having this issue with the checkbox input that's a part of the same form. When it's checked I get a "true," and when it's not checked I get a "false."

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'll take a look at it!

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can actually use perch_shop_get_cart_property() to get a property.

Thanks Drew!

perch_shop_get_cart_property() even before the order is complete? I doesn't seem to return anything in the review step.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, should be fine. Are you passing in the property you want to get?

Also I hope 1.0.2 should fix your textarea issue - let me know.

Ah---

I was doing this---which does not work:

<?php perch_shop_get_cart_property('gift_message'); ?>

But this works:

<?php
if (perch_shop_cart_has_property('gift_message')) {

echo 'Gift Message:',perch_shop_get_cart_property('gift_message');
} else {
echo 'Gift Message: No';
}
?>

One other little thing happening---

I have a checkbox saying "check if you'd like to conceal the invoice for a gift" (template is above)

If the customer selects this, it returns "true" as expected. However, if they go back to revise their selection to not-checked, and then proceed to order review again, it does not update the section to "false." (n.b. I'm using my beloved next attribute to move through the checkout flow)

Once they've gone gift, there's no going back!

And funny enough, textarea is not such an issue with perch_shop_get_cart_property() because blank space just shows up blank. It's still a problem if you want to test for an else condition because it is always returning 'true' -- I'll check it out after the next release! ...... BUT all this is to say: that the textarea value is updating properly when I go back and change the message, the checkbox is not.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Check the release and let me know if these are still issues.

Will do, thanks Drew!!

Hi Drew,

I'm on Shop 1.0.6 and still running into this issue:

When "gift_invoice" (checkbox) and "gift message" (textarea) are selected during the gift step they cannot be revised prior to checkout when the customer goes back to the gift step and resubmits as blank selections.

That is to say "once you go gift, you [still] never go back" ---[can I say that enough? apparently not!]

Cheers Drew.

Drew McLellan

Drew McLellan 2638 points
Perch Support

It sounds like we're still having issues unsetting a cart property. I'll take a look into it.

Hi Drew, I saw that Mike Harrison brought up changing cart properties in another thread. I have:

<?php perch_shop_form('checkout/gift_form.html'); ?>  

and in gift_form.html

<perch:input type="textarea" id="gift_message" editor="markitup" markdown="true" cart-property="gift_message" />

The cart properties are not resetting when the customer goes back to this step in the checkout flow. Just wondering if this is still an open issue, or does your reply to Mike have some bearing here?----

" In Shop 1.0.6 you can do this:

perch_shop_set_cart_property('change_details', null);

"

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's in 1.0.7, not 1.0.6 - my mistake.

Hi Drew, I'm on 1.0.7 (cool!) and the textarea cart property is resetting as expected.

The cart properties set with a checkbox are still not resetting when I go back and change the selection during my checkout flow.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you changing it to a new positive value, or removing it?