1/* 2 * Alma Frontend Widget Implementation 3 * This script initializes the Alma payment widget on the frontend. 4 * @see includes/Infrastructure/Helper/AssetsHelper.php 5 */ 6(function ($) { 7 $(function () { 8 /** 9 * Hide or display the payment plan details based on the selected payment method. 10 */ 11 function displayInstallmentsPlanForPaymentMethods() { 12 let $checked = $('input[name="alma_plan_key"]:checked'); 13 14 $('.alma_woocommerce_gateway_checkout_plan').hide(); 15 16 if ($checked.length) { 17 let value = $checked.val(); 18 let id = '#alma-checkout-plan-' + value; 19 $(id).show(); 20 } 21 } 22 23 function selectFirstPaymentMethod(paymentBox) { 24 let $first = paymentBox.find("input[name='alma_plan_key']").first(); 25 $first.prop('checked', true); 26 displayInstallmentsPlanForPaymentMethods(); 27 } 28 29 $(document).on('change', 'input[name="payment_method"]', function() { 30 if ($(this).val().startsWith('alma_')) { 31 let paymentBox = $(this).nextAll('.payment_box').first(); 32 selectFirstPaymentMethod(paymentBox); 33 } 34 }); 35 36 $(document).on('change', 'input[name="alma_plan_key"]', function() { 37 displayInstallmentsPlanForPaymentMethods(); 38 }); 39 40 if ($('input[name="payment_method"]:checked').val()?.startsWith('alma_')) { 41 let paymentBox = $('input[name="payment_method"]:checked').nextAll('.payment_box').first(); 42 selectFirstPaymentMethod(paymentBox); 43 } else { 44 displayInstallmentsPlanForPaymentMethods(); 45 } 46 }) 47})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.