News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

payment method depending from shipping method

Started by bobchain, May 13, 2013, 11:29:14 AM

Previous topic - Next topic

bobchain

Hello everyone,
is there a way to set up methods of payment based on the shipping method chosen?

if not possible directly with virtuemart, you know of a plugin that provides this functionality?


Thanks all for your help.

J: 2.5.8
VM 2.0.20a

rido21


illusiondrmr

Hi there,

There have been plenty topics regarding this feature but unfortunately there is nothing like this until now.
I've even posted in the "commercial jobs" section about it, but got no response :
http://forum.virtuemart.net/index.php?topic=115143.msg387872#msg387872

It would be nice if something like this comes up in the next update or even a commercial plugin ..


big2000

#3
Hello, Right now I'll show how to make this work. I have three shipping methods and two payment methods. When you select shipment_id_1 or shipment_id_3 it will leave only payment_id_1 and when shipment_id_2 is selected only payment_id_2 will stay.
First you will have to make backup of your page.
Next step: Go to index.php of you template and in <head> section put this code (best just above </head>):


<script type="text/javascript">

var now = false;

function show(id, event)
{
hide();
document.getElementById(id).style.display = 'block';
id = now;
}

var tag;

function hide()
{
  if(now)
  {
  document.getElementById(now).style.display = 'none';
  }
}


jQuery(document).ready(function(){


if(localStorage.getItem("odb") == "no") {
   if (localStorage.getItem("click") == "yes") {
     jQuery('#payment_id_1').click()
     localStorage.setItem("click", "no"); 
   }else{
    localStorage.setItem("click", "no"); 
   }
        jQuery("label[for='payment_id_2']").hide()
            jQuery('#payment_id_2').hide()
        jQuery("label[for='payment_id_1']").show()
            jQuery('#payment_id_1').show()
          }else{
           if (localStorage.getItem("click") == "yes") {
     jQuery('#payment_id_2').click()
     localStorage.setItem("click", "no"); 
   }else{
    localStorage.setItem("click", "no"); 
   }
           
           jQuery('#payment_id_2').show()
        jQuery("label[for='payment_id_2']").show()
          jQuery('#payment_id_1').hide()
        jQuery("label[for='payment_id_1']").hide()
          }


  jQuery('#shipment_id_1').click(function(){
localStorage.setItem("click", "yes"); 
   localStorage.setItem("show", "yes");
localStorage.setItem("odb", "no"); 

    });
 
      jQuery('#shipment_id_2').click(function(){
localStorage.setItem("click", "yes"); 
   localStorage.setItem("show", "yes");
localStorage.setItem("odb", "yes"); 

    });
       jQuery('#shipment_id_3').click(function(){
localStorage.setItem("click", "yes"); 
   localStorage.setItem("show", "yes");
localStorage.setItem("odb", "no"); 

    });
 
  });


     
 
</script>


There are some extra lines in code and I will try to add some features in my next post.
I hope it will help. If you have any questions plz mail me on km@viktoria.com.pl
KrzysztofM
viktoria.com.pl
alelek.pl

illusiondrmr

Thanks for sharing ! I will give it a try in my next project for sure !