Hi all, I would like to find a way to automatically remove leading and trailing whitespace from ZipCode of the Shipping Estimator and the Profile fields.
We often have reports form customers, that No Shipping Methods error message is shown when using the Shipping Estimator and in the Cart.
This problem occurs when a customer drags and drops the ZipCode from an external page (like an email or another webpage) to the shipping estimator Zipcode textarea.
Often, leading and trailing spaces or other whitespace are also in the string as its dropped in.
Is there a simple smarty command that automatically remove leading and trailing (only) whitespace?
For example in v2.1.4, the shipping_estimation.tpl template has this code:
So the $cart.user_data.s_zipcode variable will need to be trimmed somehow before the estimator sends the data to the Real-Time Shipping Calculator, in this case Australia Post. It may also effect Manual shipping methods.
We do lose sales and get time consuming emails regarding this issue… any help will be greatly appreciated.
Ive added the cm-trim microformat to core.js of our v2.1.4 store and it seems to work. It trims both leading and trailing whitespace from the zipcode. It will not trim spaces within the string, which is exactly what we want.
For v2.1.4, core.js file:
Find at about line 1802:
// Check the email field
replace it with"
// Check the need to trim value
if (lbl.hasClass('cm-trim')) {
elm.val($.trim(elm.val()));
}
// Check the email field
To trim the shipping estimator zipcode, edit /customer/views/checkout/components/shipping_estimation.tpl
Replace:
With:
Likewise any field should be able to be trimmed just by adding "cm-trim " to the class of the associated withn the same ID as the following .
So adding to /customer/views/profiles/components/profile_fields.tpl will trim all profile fields.
Also, need to add cm-trim to the /customer/views/auth/login_form.tpl at about line 11 (v2.1.4)
Replace:
with:
This will trim the Sign-in and Returning Customer email address.
We had a customer today complain he could not log in to purchase. After a 30 minute phone call we discovered that he had pasted his email address with trailing spaces… So much time (and perhaps orders) lost because of such a simple lack of programming refinement.