Author Topic: How to add additional Field in checkout page, if different Delivery method  (Read 362 times)

kostianev

  • Jr. Member
  • **
  • Posts: 70
  • Web Developer
    • MOON.bg
  • Skype Name: moonbgltd
  • VirtueMart Version: 3.x
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

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 2179
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Let the customer register a second shipping address. You can store as many adresses as You like.

Jörgen @ Kreativ Fotografi
Joomla 3.9.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)

kostianev

  • Jr. Member
  • **
  • Posts: 70
  • Web Developer
    • MOON.bg
  • Skype Name: moonbgltd
  • VirtueMart Version: 3.x
No, I don`t want to ask them for second address, I just need 1 input field.

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 2179
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
??? 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
Joomla 3.9.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8892
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
hide/show field by JS depending on the shipping method chosen

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

Code: [Select]
<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
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation