Jump to content

Hook adding discount on payment method selection


Recommended Posts

  • 2 weeks later...
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
Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...
  • 9 months later...
On 11/6/2019 at 9:20 PM, CedCommerce Team said:

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 

Hi everyone ..

How to add the cart rule i.e. $cart_rule_id?

I could only see Information, Conditions and Actions Tab in Cart rules. I'm not sure if I have hooked the discount. (here is a screenshot).

Screen Shot 2021-01-25 at 3.29.52 AM.png

Link to comment
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...