Skip to content

Commit

Permalink
Prevent error in cartPayerName helper if buyer name contains non-la…
Browse files Browse the repository at this point in the history
…tin characters. The latter are not accepted by payment gateways, resulting the error in the payment form. (#1432)
  • Loading branch information
priezz authored and Aaron Judd committed Sep 30, 2016
1 parent a3dea41 commit a4d0865
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions imports/plugins/core/checkout/client/helpers/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,10 @@ Template.registerHelper("cart", function () {
* @summary gets current cart billing address / payment name
* @return {String} returns cart.billing[0].fullName
*/

Template.registerHelper("cartPayerName", function () {
const cart = Cart.findOne();
if (cart) {
if (cart.billing) {
if (cart.billing[0].address) {
if (cart.billing[0].address.fullName) {
return cart.billing[0].address.fullName;
}
}
}
if (cart && cart.billing && cart.billing[0] && cart.billing[0].address && cart.billing[0].address.fullName) {
const name = cart.billing[0].address.fullName;
if (name.replace(/[a-zA-Z ]*/, "").length === 0) return name;
}
});

0 comments on commit a4d0865

Please sign in to comment.