Jump to content

Display custom payment method only if a specific custom carrier is selected.


Recommended Posts

Hello!

I have built a custom carrier module and a custom payment module as well.

Is there a way to "link" them together in a way that the payment method will only be displayed if the specific carrier is selected?

It would be great if this could be done within any of these two modules so the user won't have to install a third module.

Thank you!

Link to comment
Share on other sites

In Prestashop 1.7 admin panel, at Payment -> Preferences, at the bottom of the page, you can make payment restrictions for payment methods related to carriers (and also with countries, customer groups and currency). It doesn't depends of custom modules, it's a Prestashop feature, but I think it can helps you.

Link to comment
Share on other sites

Thank you @ftardio! This is useful indeed but I was looking for a solution for prestashop 1.6.

Fortunately I have found one!

I am getting the selected carrier in my payment module (in hookDisplayPayment method) and only display the payment method if my custom carrier is selected.

Here it is in case someone else is looking for this:

        $carrier = new Carrier($this->context->cart->id_carrier);
        if ($carrier->external_module_name != 'my_custom_carrier_module_name') {
            return;
        }

My problem now is how to hide the other payment methods when my custom carrier is selected... Any ideas?

Edited by spyrosel (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Hi Spyrosel, have you found solution?

I have same need.

Thanks in advanced

Donato

 

On 4/6/2019 at 11:33 AM, spyrosel said:

Thank you @ftardio! This is useful indeed but I was looking for a solution for prestashop 1.6.

Fortunately I have found one!

I am getting the selected carrier in my payment module (in hookDisplayPayment method) and only display the payment method if my custom carrier is selected.

Here it is in case someone else is looking for this:


        $carrier = new Carrier($this->context->cart->id_carrier);
        if ($carrier->external_module_name != 'my_custom_carrier_module_name') {
            return;
        }

My problem now is how to hide the other payment methods when my custom carrier is selected... Any ideas?

 

Link to comment
Share on other sites

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...