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??
Anyone?? Some idea? It would be usefull...
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...
Hi klevyke, can you please describe more in detail how to get this work?
Thank you.
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
I have made this in post: http://forum.virtuemart.net/index.php?topic=115560.msg408254#msg408254
There is an extension now specifically for this case.
http://joomwebsites.com/extensions