2

Haven't been able to get a reply from the guys at CartThrob since November, so hopefully someone here can help out.

We have the following in our add to cart form:

{if cf_products_stampinglimit}
 <p>
  <label for="stamping">
   <span class="label">Stamping:</span>
   {item_options:input:stamping type="text" value=""}
   <span class="note">Character limit: {cf_products_stampinglimit}. If you're ordering more than one charm, separate each stamp with a comma.</span>
  </label>
 </p>
{/if} 

While it works well 99% of the time, I’ve recently discovered that if a customer types something like “a + b” in the field, then the email shows up blank or with this error message:

Parse error: syntax error, unexpected T_STRING in /my/path/to/system/expressionengine/libraries/Functions.php(680) : eval()'d code on line 94

The field is filled out just fine in the order entry though (i.e., it gets saved just fine). Here’s the code snippet for that piece in the email template:

{if "{item:stamping}"}Stamping: <em>{item:stamping}</em><br />{/if} 

I’ve tested this extensively and the email appears normally unless it has something like “x + x”. Any idea on how to fix this?

Running EE 2.5.2 and CartThrob 2.1.5.

Update: We've since upgraded to EE 2.5.5 and CT 2.2.9 and now, instead of getting a blank email, this error is sent instead:

Parse error: syntax error, unexpected '" != "' (T_CONSTANT_ENCAPSED_STRING) in /path/to/system/expressionengine/libraries/Functions.php(683) : eval()'d code on line 81

Additionally, this is the case for various characters: + & ;

1

Have you tried using javascript to replace the + with &plus; or &#43; before submitting? That section of EE code is encoding the email and calling the typography library, something in there may be choking on the +.

| improve this answer | |
  • Haven't tried that yet. Will give it a shot this week. Thanks for the suggestion! – Angie Herrera Jan 14 '13 at 0:09
1

Finally got to the bottom of this. The issue wasn't even with the {item:stamping} field, it was with another one (SKU) that the site manager's fill in. On a few products the SKU included " and that's what was causing the problem.

So I simply changed the code to use single quotes and everything is working great:

{if '{item:cf_products_sku}' != ""}SKU #{item:cf_products_sku}<br />{/if}

| improve this answer | |
0

Try the conditional written like any of the following:

{if "{item:stamping}" != ""}

or

{if '{item:stamping}' != ''}

or

{if {item:stamping} != ""}
| improve this answer | |
  • 1
    Have definitely tried that, doesn't make a difference. :/ – Angie Herrera Jan 14 '13 at 0:08

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.