VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: kostianev on April 24, 2019, 11:19:13 AM

Title: How to add additional Field in checkout page, if different Delivery method
Post by: kostianev on April 24, 2019, 11:19:13 AM
Dear Friends, we have this issue, if client choose Delivery to the Courier office, we need to display additional field, where to type the Office address and name. How can we achieve this?

So, for example, we have 2 Delivery methods - 1. To the Client address, where everything is okay because they fill out their address, 2. Method to the Office - where the client need to fill out the Office address, or Name
Title: Re: How to add additional Field in checkout page, if different Delivery method
Post by: Jörgen on April 24, 2019, 12:38:32 PM
Let the customer register a second shipping address. You can store as many adresses as You like.

Jörgen @ Kreativ Fotografi
Title: Re: How to add additional Field in checkout page, if different Delivery method
Post by: kostianev on April 24, 2019, 12:51:36 PM
No, I don`t want to ask them for second address, I just need 1 input field.
Title: Re: How to add additional Field in checkout page, if different Delivery method
Post by: Jörgen on April 24, 2019, 14:21:54 PM
??? Then use the input field You have if You do not need any extra address.

I would use the native shipping address.

Jörgen @ Kreativ Fotografi
Title: Re: How to add additional Field in checkout page, if different Delivery method
Post by: GJC Web Design on April 26, 2019, 12:01:06 PM
hide/show field by JS depending on the shipping method chosen

you can also set if required by JS -- something like


<script>
jQuery(document).ready(function($){
<?php if(//detect the shipping id == 2) { ?>
                                $('#company_field').show().addClass('required').attr('required', 'required').attr('aria-required', 'true');

<?php }else{ ?>
                              $('#company_field').hide().removeClass('required').removeAttr('required aria-required').val('');
<?php ?>
});
</script>


prob need to hide the surrounding div/row as well