From 3e040e4f2d66dcc95d26cb9f7f9b1e3d45b13e13 Mon Sep 17 00:00:00 2001 From: Jacek Pyziak Date: Tue, 27 Jan 2026 11:15:15 +0100 Subject: [PATCH] update --- .../theme/mojszablon/userdata_order_form.html | 52 ++++++++++++------- .../userdata_order_form_billing.html | 35 ++++++++++--- .../cvIngPlugin/lib/cvIngListener.class.php | 18 +++---- 3 files changed, 70 insertions(+), 35 deletions(-) diff --git a/apps/frontend/modules/stUserData/templates/theme/mojszablon/userdata_order_form.html b/apps/frontend/modules/stUserData/templates/theme/mojszablon/userdata_order_form.html index d9b0047..ac29029 100644 --- a/apps/frontend/modules/stUserData/templates/theme/mojszablon/userdata_order_form.html +++ b/apps/frontend/modules/stUserData/templates/theme/mojszablon/userdata_order_form.html @@ -326,29 +326,43 @@ var star_placeholder_billing = $("#full_name_billing").attr("placeholder"); var no_star_placeholder_billing = star_placeholder_billing.substring(2); - if ( $( '#user_data_billing_customer_type_2' ).attr( 'checked' ) ) - { - $("#company_billing_fields").show(); - $("#company_billing_fields input").attr('required', 'required'); - $('#full_name_billing' ).hide().removeAttr('required'); - } - else - { - $("#company_billing_fields").hide(); - $("#company_billing_fields input").removeAttr('required'); - $('#full_name_billing' ).show().attr('required', 'required'); + var IMOJE_PAYMENT_ID = 16; + + function updateFullNameVisibility() { + var isCompany = $('#user_data_billing_customer_type_2').is(':checked'); + var selectedPaymentId = parseInt($('input[name="delivery[default_payment]"]:checked').val()) || 0; + var isImoje = selectedPaymentId === IMOJE_PAYMENT_ID; + + if (isCompany) { + $("#company_billing_fields").show(); + $("#company_billing_fields input").attr('required', 'required'); + + if (isImoje) { + // Dla imoje pokazujemy i wymagamy Imię i nazwisko nawet dla firm + $('#full_name_billing').show().attr('required', 'required'); + $('#full_name_billing').attr("placeholder", star_placeholder_billing); + } else { + // Dla innych płatności ukrywamy dla firm + $('#full_name_billing').hide().removeAttr('required'); + } + } else { + $("#company_billing_fields").hide(); + $("#company_billing_fields input").removeAttr('required'); + $('#full_name_billing').show().attr('required', 'required'); + $('#full_name_billing').attr("placeholder", star_placeholder_billing); + } } - $('#user_data_billing_customer_type_1').click(function () { - $("#company_billing_fields").hide(); - $("#company_billing_fields input").removeAttr('required'); - $('#full_name_billing' ).show().attr('required', 'required'); + // Inicjalizacja i obsługa zmiany typu klienta + updateFullNameVisibility(); + + $('#user_data_billing_customer_type_1, #user_data_billing_customer_type_2').click(function () { + updateFullNameVisibility(); }); - $('#user_data_billing_customer_type_2').click(function () { - $("#company_billing_fields").show(); - $("#company_billing_fields input").attr('required', 'required'); - $('#full_name_billing' ).hide().removeAttr('required'); + // Obsługa zmiany metody płatności + $(document).on('change', 'input[name="delivery[default_payment]"]', function() { + updateFullNameVisibility(); }); $("#full_name_delivery").attr("placeholder", "Imię i nazwisko" ); diff --git a/apps/frontend/modules/stUserData/templates/theme/responsive/userdata_order_form_billing.html b/apps/frontend/modules/stUserData/templates/theme/responsive/userdata_order_form_billing.html index e60363b..a83dac0 100644 --- a/apps/frontend/modules/stUserData/templates/theme/responsive/userdata_order_form_billing.html +++ b/apps/frontend/modules/stUserData/templates/theme/responsive/userdata_order_form_billing.html @@ -133,24 +133,47 @@