VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: webe on September 13, 2012, 10:25:34 AM

Title: Payment method for a specific shipping method in vm2
Post by: webe on September 13, 2012, 10:25:34 AM
Hello to the community.
Back in vm1 was this (http://forum.virtuemart.net/index.php?topic=47830.0) script to bind a payment method with a shipping method.
Is there any solution (commercial or free) in vm2??
Title: Re: Payment method for a specific shipping method in vm2
Post by: klevyke on November 26, 2012, 13:36:42 PM
Anyone?? Some idea? It would be usefull...
Title: Re: Payment method for a specific shipping method in vm2
Post by: klevyke on November 27, 2012, 12:44:16 PM
I've done a little trick here... I used Javascript instead of changing the virtuemarts php...
I set a cookie, with the value of shipping id. I added this in select_shipping.php:
<script type="text/javascript">
function SetCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString()+"; path=/";
//document.cookie = "mycookiename=value; expires=some gmt date time; path=thepath; domain=the domain";
}
function setShippigMethodCookie() {
var checked = false, radios = document.getElementsByName('virtuemart_shipmentmethod_id');
for (var i = 0, radio; radio = radios[i]; i++) {
    if (radio.checked) {
        SetCookie("shipping_id", radio.value, 0.1);
checked = true;
        break;
    }
}
}
</script>

Then I retrive the cookie in the payment selection page and disable the unavaible methods...
Added this code at the en of the file select_payment.php
<script type="text/javascript">
function ReadCookie(cookieName) {
var theCookie=" "+document.cookie;
var ind=theCookie.indexOf(" "+cookieName+"=");
if (ind==-1) ind=theCookie.indexOf(";"+cookieName+"=");
if (ind==-1 || cookieName=="") return "";
var ind1=theCookie.indexOf(";",ind+1);
if (ind1==-1) ind1=theCookie.length;
return unescape(theCookie.substring(ind+cookieName.length+2,ind1));
}
function hideDisabled() {
shipping_id = ReadCookie("shipping_id");
if ([i]condition[/i]) {
document.getElementById('payment_id_2').disabled = 'disabled';
  }
}
hideDisabled();
</script>


I hope it will help somebody...
Title: Re: Payment method for a specific shipping method in vm2
Post by: Hy3n4 on January 14, 2013, 11:37:52 AM
Hi klevyke, can you please describe more in detail how to get this work?
Thank you.
Title: Re: Payment method for a specific shipping method in vm2
Post by: borro on August 07, 2013, 08:56:40 AM
Quote from: klevyke on November 27, 2012, 12:44:16 PM
I set a cookie, with the value of shipping id. I added this in select_shipping.php:
...
Added this code at the en of the file select_payment.php
...

Hello, mister enthusiast!

I can't find any of these files. I'm using VM 2.0.18a. May be they were renamed. Do you have any ideas where to add your code now?
I think i've found one. But it's called sitename\components\com_virtuemart\views\cart\tmpl\select_shipment.php now. And select_payment.php is there also. I'll try
Title: Re: Payment method for a specific shipping method in vm2
Post by: big2000 on October 29, 2013, 20:38:14 PM
I have made this in post: http://forum.virtuemart.net/index.php?topic=115560.msg408254#msg408254
Title: Re: Payment method for a specific shipping method in vm2
Post by: nerfmarius on April 13, 2014, 15:13:17 PM
There is an extension now specifically for this case.

http://joomwebsites.com/extensions