Merge branch 'main' of https://git.project-pro.pl/Project-Pro/grzanieplus.pl
This commit is contained in:
@@ -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" );
|
||||
|
||||
@@ -136,21 +136,44 @@
|
||||
|
||||
const billingFullName = $("#full_name_billing");
|
||||
const billingFullNameSpan = $("#required-mark-full-name-billing");
|
||||
const billingFullNameFormGroup = billingFullName.closest('.form-group');
|
||||
const IMOJE_PAYMENT_ID = 16;
|
||||
|
||||
function updateFullNameRequirement() {
|
||||
var isCompany = $('input[name="user_data_billing[customer_type]"]:checked').val() == 2;
|
||||
var selectedPaymentId = parseInt($('input[name="delivery[default_payment]"]:checked').val()) || 0;
|
||||
var isImoje = selectedPaymentId === IMOJE_PAYMENT_ID;
|
||||
|
||||
if (isCompany && !isImoje) {
|
||||
billingFullName.removeAttr("aria-required");
|
||||
billingFullNameSpan.css("display", "none");
|
||||
billingFullNameFormGroup.removeClass('imoje-required');
|
||||
} else {
|
||||
billingFullName.attr("aria-required", "true");
|
||||
billingFullNameSpan.css("display", "inline");
|
||||
if (isImoje && isCompany) {
|
||||
billingFullNameFormGroup.addClass('imoje-required');
|
||||
} else {
|
||||
billingFullNameFormGroup.removeClass('imoje-required');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('#user_data_billing_customer_type_2, #user_data_billing_customer_type_1').click(function() {
|
||||
var radio = $(this);
|
||||
|
||||
if (radio.val() == 1) {
|
||||
$(".company_billing_fields").hide();
|
||||
billingFullName.attr("aria-required", "true");
|
||||
billingFullNameSpan.css("display", "inline");
|
||||
} else {
|
||||
$(".company_billing_fields").show();
|
||||
billingFullName.removeAttr("aria-required");
|
||||
billingFullNameSpan.css("display", "none");
|
||||
}
|
||||
updateFullNameRequirement();
|
||||
}).filter(':checked').click();
|
||||
|
||||
$(document).on('change', 'input[name="delivery[default_payment]"]', function() {
|
||||
updateFullNameRequirement();
|
||||
});
|
||||
|
||||
$("#company_billing").change(function() {
|
||||
var word_billing = $(this).get(0).defaultValue;
|
||||
var word_delivery = $("#company_delivery").val();
|
||||
|
||||
@@ -55,16 +55,14 @@ class cvIngListener
|
||||
|
||||
$billing = $action->getRequestParameter('user_data_billing', array());
|
||||
|
||||
// Tylko dla osób prywatnych (customer_type != 2) wymagamy imienia i nazwiska
|
||||
if($billing['customer_type'] != 2) {
|
||||
if(!$billing['full_name']) {
|
||||
$i18n = $action->getContext()->getI18N();
|
||||
$action->getRequest()->setError('user_data_billing{full_name}', $i18n->__('Brak imienia i nazwiska.'));
|
||||
$ok = false;
|
||||
} elseif(!cvIngService::validateName($billing['full_name'])) {
|
||||
$action->getRequest()->setError('user_data_billing{full_name}', $validateError['full_name']);
|
||||
$ok = false;
|
||||
}
|
||||
// Imię i nazwisko wymagane dla płatności imoje/twisto (niezależnie od typu klienta)
|
||||
if(!$billing['full_name']) {
|
||||
$i18n = $action->getContext()->getI18N();
|
||||
$action->getRequest()->setError('user_data_billing{full_name}', $i18n->__('Brak imienia i nazwiska.'));
|
||||
$ok = false;
|
||||
} elseif(!cvIngService::validateName($billing['full_name'])) {
|
||||
$action->getRequest()->setError('user_data_billing{full_name}', $validateError['full_name']);
|
||||
$ok = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user