From 6ec9e2244f09ed67d14fee675f79aa8e93ef6b72 Mon Sep 17 00:00:00 2001 From: Ievgen Shakhsuvarov Date: Fri, 26 May 2017 16:32:44 +0300 Subject: [PATCH] Backport of MAGETWO-69379 for Magento 2.1: use payment method name to make checkbox of agreements more unique #6207 #9717 (cherry picked from commit 14b9b9813c9a16c0c45505885503cfb71bc4eb8d) --- .../web/js/view/checkout-agreements.js | 20 +++++++++++++++++++ .../checkout/checkout-agreements.html | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js index c6d709fab8486..359db155c5499 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js @@ -45,6 +45,26 @@ define( agreementsModal.showModal(); }, + /** + * build a unique id for the term checkbox + * + * @param {Object} context - the ko context + * @param {Number} agreementId + */ + getCheckboxId: function (context, agreementId) { + var paymentMethodName = '', + paymentMethodRenderer = context.$parents[1]; + + // corresponding payment method fetched from parent context + if (paymentMethodRenderer) { + // item looks like this: {title: "Check / Money order", method: "checkmo"} + paymentMethodName = paymentMethodRenderer.item ? + paymentMethodRenderer.item.method : ''; + } + + return 'agreement_' + paymentMethodName + '_' + agreementId; + }, + /** * Init modal window for rendered element * diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html index 4b657748dc988..a448537d64e83 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html @@ -11,11 +11,11 @@
-