I'm trying to get a conditional to work in a Magento email template, but for whatever reason, I can't get the 'if' to evaluate to true. In my template, I have:
Shipping Method:{{var order.shipping_method}}<br /><br />
{{if order.shipping_method=="wsastorepickup_wsastorepickup"}}
Run this<br /><br />
{{else}}
WTF, OVER?<br /><br />
{{/if}}
When Magento sends the email it has:
Shipping Method:wsastorepickup_wsastorepickup
WTF, OVER?
I've tried it with and without the 'var' in the conditional. What am I missing?
Related
I'm using WYSIHTML5 editor. Field value was imported to the database and now I want to display it to user.
Value saved in db:
Abstract<br />Introduction<br />Material and methods<br /><br /><br />Material studied<br /><br />Treatment of material<br /><br />
Value in editor:
Abstract<br>Introduction<br>Material and methods<br><br><br>Material studied<br><br>Treatment of material<br><br>
As you can see
<br />
was replaced by
<br>
The thing is that we notify user if he changed value of the field and didn't click "save". Since we compare texts, this difference in br tag counts and I want to avoid it.
Is there any way to turn it off in wysihtml5?
Run the following experiments on your ColdFusion server/development environment:
1) Create the following, basic HTML form that submits to itself using the post method:
<form method="post">
DATE: <input type="text" name="date" value="gfsgfdgfsd"><br>
MARTIN: <input type="text" name="martin" value="beardy"><br>
PAYMENT: <input type="text" name="payment" value="50 POUNDS"><br>
PAYMENT_DATE: <input type="text" name="payment_date" value="06:05:13 Apr 09, 2014 PDT"><br>
XEVI: <input type="text" name="xevi" value="cool"><br>
<input type="submit" value="submit"><br>
</form>
<cfdump var="#FORM#" />
Now access the page and hit the Submit button. Notice you get the error Form entries are incomplete or invalid. Now remove the ' POUNDS' from the end of the PAYMENT field so the value only contains numeric values. Re-submit the form and notice the error goes away.
2) Now study the CF Dump of the FORM structure. Notice how PAYMENT_DATE is missing from the comma separated list under the FIELDNAMES element! Clearly it exists because it's visible as the penultimate element in the dump. So why is it not listed?
Note: This strange bug wasted 4 hours of my life while trying to integrate the PayPal IPN (Instant Payment Notification) notification verification/validation stage which requires you to post everything back to the PayPal server with the arguments in the same order they were when submitted to you. Because payment_date was missing is was returning as INVALID. I fixed it with a dirty hack that looks for mc_gross while looping over fieldnames and inserts payment_date manually. Eerrgh, I feel unclean!
Experiment 1 proves that FORM.PAYMENT is a reserved value that must be numeric.
Experiment 2 proves that FORM.PAYMENT_DATE is a reserved value that gets ignored when FORM.FIELDNAMES is populated.
Why?
In the form scope in ColdFusion anything ending in _date is reserved as per http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec173d0-7ffe.html for validation purposes.
I cannot replicate the issue you are having with 'payment' being an integer. As soon as I change the payment_date field to paymentdate it submits just fine.
I have been having trouble with a bit of classic asp code
pretty much what I want to do is when a hidden field has a value of 1 a message is displayed
here is the code i have:
<% if (CStr(Request.form("HiddenLog")) = CStr("1")) then %>
<br /> <p style="color:Red;">Message here</p>
<%end if %>
<input type="hidden" id="HiddenLog" value="1" />
The result is nothing appears on screen however if I add an else to the if statment like so
<% if (CStr(Request.form("HiddenLog")) = CStr("1")) then %>
<br /> <p style="color:Red;">Message here</p>
<%else%>
<br /> <p style="color:Red;">Message here</p>
<%end if %>
The message always appears (of course this was to prove that the if statment is working and that the problem most likly is with getting the form values), can someone please tell me what it is I have done wrong
Thanks
Edit A couple of people have asked about my form so I will post that here as well
<form id="form1" method="post">
all the controls are contained inside this form
you have to give the input field a name attribute. you only have an id attribute this is not posted so just use
<input type="hidden" id="HiddenLog" name="HiddenLog" value="1" />
I am making an app that creates a custom PDF, mails it and then deletes it. I have tested all 3 components separately and they work but when I put them together the email doesn't send.
Is it possible that the attachment gets deleted before the email is sent even though the delete is after it in the script?
Here is my code.
<!---Get the PDF--->
<cfscript>
PDFBuilder = createobject("component", "form_admin.email.PDFBuilder" );
pdf = PDFBuilder.createPDF(form_id);
</cfscript>
<!---Create link to the pdf --->
<cfscript>
foo = expandPath('../email/tmp/') & pdf & '.pdf';
</cfscript>
<!---Create email--->
<cfmail to="will#hazardousfrog.com"
from="will#hazardoufrog.com"
subject="Jag intrest form. "
type="text/html" >
<cfmailparam file="#foo#">
Dear #getEmail.title#, #getEmail.first_name# #getEmail.surname# <br />
Attached is a PDF boucher telling you more information about the cars you were interested in. <br />
Best wishes <br />
Jaguar <br /><br /><br /><br /><br /><br /><br /><br />
This is not actually jaguar this is a test application by Hazardousfrog.
</cfmail>
<!---Delete the file after it has been sent --->
<cfif FileExists(#foo#)>
<cffile action="delete"
file="#foo#">
<cfelse>
<cfoutput >
error
</cfoutput>
<cfabort>
</cfif>
Sorry if the code isn't great I have only been doing CF for like 2 weeks.
Ok I managed to get the answer from a work friend.
When cfmail is processed the mail is saved into a spool and periodically sent out after about 3 mins.
In my case it meant that the email PDF attachment was being deleted before the message could be sent so the mail was not sending.
The coldFusion mail tag has an attribute to send it straight away or keep it spooled.
spoolenable : Whether to spool mail or always send it Immediately.
So to get it to get my code to work I added this line to my mail attributes.
spoolenable="false"
One other option would be to use the remove attribute of the cfmailparam tag which will tell CF to remove the file after it is sent. This way your spoolenable attribute can be true and it should work as desired. The remove attribute was introduced in version 8.0.1.
I would also place a fileExists() around the cfmail code on whether the pdf file indeed has been created.
I have a 'customer' form which has a section called 'contacts'. To start with this contacts section will contain the following elements..
<input type="text" name="contacts[0][fname]" />
<input type="text" name="contacts[0][sname]" />
But the user may want to add another contact which will duplicate the elements with javascript to produce the following:
<input type="text" name="contacts[0][fname]" />
<input type="text" name="contacts[0][sname]" />
<br />
<input type="text" name="contacts[1][fname]" />
<input type="text" name="contacts[1][sname]" />
I know how to produce the first set of elements, however if the form gets submitted and there are errors, how can i ensure that the correct number of 'contacts' elements get rendered?
Ive never had to do this with Zend_Form but i have done it with Symfony 1.4's sfForm which has a similar API and theory of operation. Based on that the basic process is:
In the parent forms constructor intialize some default number of subforms. Youll want to separate out the logic for actually creating and embedding n subforms into a separate method(s). Ill refer to this as the method emebedContacts($count = 1)
Override the isValid and setDefaults methods on the parent form so that they detect the number of subforms in the $data arguments passed to them and then call embedContacts before calling parent::isValid() or parent::setDefaults().
Hope that helps.