From 2cebdbc11782a4f1901c87a1f29df22ad6fa9810 Mon Sep 17 00:00:00 2001 From: Alexandr Priezzhev Date: Sun, 25 Sep 2016 17:18:18 +0300 Subject: [PATCH] Prevent error in `cartPayerName` helper if buyer name contains non-latin characters. The latter are not accepted by payment gateways, resulting the error in the payment form. --- imports/plugins/core/checkout/client/helpers/cart.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/imports/plugins/core/checkout/client/helpers/cart.js b/imports/plugins/core/checkout/client/helpers/cart.js index 2429a35df81..8b9c8556c85 100644 --- a/imports/plugins/core/checkout/client/helpers/cart.js +++ b/imports/plugins/core/checkout/client/helpers/cart.js @@ -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; } });