VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: alegrafic on October 07, 2017, 12:29:33 PM

Title: [SOLVED] Customize client custom fields
Post by: alegrafic on October 07, 2017, 12:29:33 PM
Hello,
how can I customize client custom fields?

in particular I want to insert two radio bottons that make me appear other fields

Insert screenshots of the fields to add


how can I do?
Title: Re: Customize client custom fields
Post by: GJC Web Design on October 07, 2017, 22:08:17 PM
use a chk box but over ride the element display in the template over ride,   cart default_cartfields.php
Title: Re: Customize client custom fields
Post by: alegrafic on October 07, 2017, 23:26:57 PM
hi,

can you have a small example or guide?

thank you
Title: Re: Customize client custom fields
Post by: GJC Web Design on October 08, 2017, 00:21:53 AM
in the display loop detect "your" shopper field and render it differently

there is from memory already the T&C's field handled differently
Title: Re: Customize client custom fields
Post by: alegrafic on October 08, 2017, 00:51:05 AM
hi,
its ok...

please,
a small example of override for VirtueMart of the default_cartfields.php file

Thanks You
Title: Re: Customize client custom fields
Post by: GJC Web Design on October 08, 2017, 01:26:22 AM
<?php
      if ($field['hidden'] == true) {
         // We collect all hidden fields
         // and output them at the end
         $hiddenFields .= $field['formcode'] . "\n";
        } esleif ($field['name'] == 'yours') {
                  /* make your radios*/

      } else { ?>
            <?php echo $field['formcode'] ?>
         </div>
   <?php } ?>
Title: Re: Customize client custom fields
Post by: alegrafic on October 08, 2017, 09:00:46 AM
hi,
thanks a lot for the suggestion,
this code is to be included in the default_cartfields.php file?


thanks you
Title: Re: Customize client custom fields
Post by: GJC Web Design on October 08, 2017, 12:44:15 PM
have u even opened the file and had a look?

Be more proactive.. u can't expect free bespoke coding
Title: Re: Customize client custom fields
Post by: alegrafic on October 28, 2017, 11:03:58 AM
Problem solved..

for hidden fileds in default_shopper o default_cart add this code in foreach {
if($singlefield['name']=='company'){
                echo "<div class='opg-width-1-1' style='display:none;' id='hide1'>";
            }elseif($singlefield['name']=='CF_PIVA'){
                echo "<div class='opg-width-1-1' style='display:none;' id='hide2'>";
            }else{
               
                echo "<div class='opg-width-1-1'>";
            }


the radiobutton also

if($singlefield['type'] == "radio")
            {
                echo "Register as a Business";
}


this is jQuery function for gestions switch SHOW/HIDDEN

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
  <script type="text/javascript">
  $(document).ready(function(){
   // $(function(){
   $('input:radio[name="NAME OF RADIO BOTTON"]').change(function(){
        //$('#fatt_si_no1').on(function(){
       
        if($(this).val() == '1'){
            if( $('#hide1').css('display') == 'block' )
                $('#hide1').css('display','none');
            else
                $('#hide1').css('display','block');
           
         //return false;   
            if( $('#hide2').css('display') == 'block' )
                $('#hide2').css('display','none');
            else
                $('#hide2').css('display','block');

          //return false;
        }
        if($(this).val() == '0'){
            if( $('#hide1').css('display') == 'block' )
                $('#hide1').css('display','none');
            else
                $('#hide1').css('display','block');
       
         //return false;
           
            if( $('#hide2').css('display') == 'block' )
                $('#hide2').css('display','none');
            else
                $('#hide2').css('display','block');


         //return false;
       }
         
        });
    });
  </script>


that's all

bye