Jump to content
pageup

Hook adding discount on payment method selection

Recommended Posts

Hi,

I am trying to create a module (or even a simple controller or an override :D (worst case senarion)), to add a discount depending on which payment method a user selected.

Is there any hook for it?

Thank you!

Share this post


Link to post
Share on other sites
On 10/25/2019 at 2:00 PM, pageup said:

Hi,

I am trying to create a module (or even a simple controller or an override :D (worst case senarion)), to add a discount depending on which payment method a user selected.

Is there any hook for it?

Thank you!

Hi,

you can use displayPaymentReturn hook or override OrderConfirmationController to check order info and payment method selected then add discount on that based of payment method by adding rule to context cart 

use cart rule or create rule dynamically 

$cart_rule_id = your rule id;

$cart_rule = new CartRule($cart_rule_id);
$values = array(
    'tax_incl' => $cart_rule->getContextualValue(true),
    'tax_excl' => $cart_rule->getContextualValue(false)
);
$this->context->cart->addCartRule($cart_rule->id, $cart_rule->name[Configuration::get('PS_LANG_DEFAULT')], $values);

Hope this help you 
let me know if any issue 

  • Like 1

Share this post


Link to post
Share on other sites

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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More