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 @@