Post by bartek2334 » Wed Oct 19, 2016 6:36 pm

Hi Everyone

I want to hide specific payment method (cash on delivery) if specific shipping method selected before. For example, if I check shipping method A , then in the next step, payment methods I have only one method to check ( other methods disabled or unable to check). I try to edit and add some code to payment_method.php and shipping_method.php file in controller/checkout directory, but so far I havent' find the solution.

I tried to get shipping method name/code and build a conditional statement in payments, but I don't know exactly how to deal with it.

Any other ideas how to solve this issue ?

Best

Bartosz

Newbie

Posts

Joined
Wed Oct 19, 2016 6:24 pm

Post by Johnathan » Wed Oct 19, 2016 10:31 pm

Restrict Payment Methods can do this. You'd set it up like this:

------------------------------------------------------------------------------
RESTRICTION #1
Name: Enable COD if not Shipping Method A
Payment Methods: COD
Rule: Shipping Method is not Shipping Method A
------------------------------------------------------------------------------

Feel free to take a look at the screenshots and demo site, and if you're interested let me know at www.getclearthinking.com/contact if you have any further questions.

Image
Image Image Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by openmandrake » Mon Dec 19, 2016 6:14 pm

Inside the checkout process shipping method is selected and stored inside the session.

The respective code is found here:
https://github.com/opencart/opencart/bl ... d.php#L125

Inside the model of the respective payment method you could add the if statement. If the model don't return the $method_data, the payment method is not available for checkout. E.g.
https://github.com/opencart/opencart/bl ... cod.php#L8

Something like this needs to be done:

Code: Select all

if (isset($this->session->data['shipping_method']) && $this->session->data['shipping_method'] == 'something_you_want_to_disallow') {
   $status = false;
}

Checkout our extensions, or our open source projects


Newbie

Posts

Joined
Wed Oct 31, 2012 3:05 am
Who is online

Users browsing this forum: No registered users and 17 guests