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

Disable a Payment method based on selected Shipping?

Started by peebee, March 15, 2013, 05:18:32 AM

Previous topic - Next topic

peebee

A thorough browse of the forum reveals this question has been asked several times before but I can't seem to find a definitive answer?

We have several shipping methods available.  Shipping options in the cart are mainly based around weight/dimensions.  All works great.  Thanks. 

We have several payment options available, including "Cash on Collection", "Bank Deposit" & PayPal.  Also works great. 

What I need to do however, is disable (not display in the cart) the PayPal payment option depending on the shipping type available.

Example: One of the shipping options is for "hazardous materials" which means we need to work out the cost and supply the purchaser with a quotation before they pay the final price - including shipping. 

For these type of purchases, we need the shopper to have the option to select ONLY "Cash on Collection" or "Bank Deposit" - NOT PayPal as their payment option, otherwise payment will be processed there and then and we will be required to ask them to pay more $$'s afterwards.

Is there a way in which I can disable (not display in the cart) PayPal as a payment option when the shipping method available is "hazardous materials"?

I hope that makes sense.  Any solutions or suggestions gratefully appreciated.  Thanks.

Joomla 2.5.9 & VM 2.0.18a
Also using Linelab.org One Page Checkout (http://forum.virtuemart.net/index.php?topic=99418.0) if that makes a difference.

illusiondrmr

Oh that would be so nice..

Any VM developer is up for this task ? Anyone maybe could provide us with a plugin or something ?

THIS IS A MUST HAVE..

rubold

I agree! This is very basic requirement...

The only solution I found so far, is Rupostel's One Page Checkout.

This extension has options to disable payment method/shipping method or disable shipping method/payment method.

I managed to do the task, but I have to tell: I can not recommend this extension from my heart.

But most cases it works, and you will have a single page checkout as well ;)

webe

Hello!

i m using the linelab onepage checkout plugin also and i m trying to hide/show payments with jquery based on the shipping radio buttons
but the onclick="update_form(); event  breaks the jquery after choosing shipping ....

my jquery code works but only untill the form update



jQuery(document).ready(function(){

                jQuery('#payment_id_5').hide();
jQuery("label[for='payment_id_5']").hide();

jQuery('#payment_id_2').hide();
jQuery("label[for='payment_id_2']").hide();


jQuery('input:radio[name=virtuemart_shipmentmethod_id]').click(function(){
if (jQuery('#shipment_id_31').prop('checked') == true) {
jQuery('#payment_id_2').show()
jQuery("label[for='payment_id_2']").show()
} else {
jQuery('#payment_id_2').hide();
jQuery("label[for='payment_id_2']").hide();
}
});




});





any idea how to make it work??


PRO



in  paypal.php

this might work, I tested and tried it real quick
You have to change the "Shipping Name"

edit checkConditions function



protected function checkConditions ($cart, $method, $cart_prices) {

      $this->convert ($method);

      $address = (($cart->ST == 0) ? $cart->BT : $cart->ST);

      $amount = $cart_prices['salesPrice'];
      $amount_cond = ($amount >= $method->min_amount AND $amount <= $method->max_amount
         OR
         ($method->min_amount <= $amount AND ($method->max_amount == 0)));

      $countries = array();
      if (!empty($method->countries)) {
         if (!is_array ($method->countries)) {
            $countries[0] = $method->countries;
         } else {
            $countries = $method->countries;
         }
      }
      // probably did not gave his BT:ST address
      if (!is_array ($address)) {
         $address = array();
         $address['virtuemart_country_id'] = 0;
      }

      if (!isset($address['virtuemart_country_id'])) {
         $address['virtuemart_country_id'] = 0;
      }
      if (in_array ($address['virtuemart_country_id'], $countries) || count ($countries) == 0) {
         if ($amount_cond ) {
                       // @Pro HERE IS THE IF
         if ($cart->shipmentName!=SHIPPING-NAME-HERE){
            return TRUE;
         }
// @Pro and the closing tag
}
      }

      return FALSE;
   }



patben

that solution works? not for paypal the other. And in where i have to add this code?


nerfmarius