MasEir Posted October 25, 2019 Share Posted October 25, 2019 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! Link to comment Share on other sites More sharing options...
CedCommerce Team Posted November 6, 2019 Share Posted November 6, 2019 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 (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 1 Link to comment Share on other sites More sharing options...
MasEir Posted November 14, 2019 Author Share Posted November 14, 2019 Thank you so much!! I will give it a try and let you know !! Link to comment Share on other sites More sharing options...
Surffari Posted March 31, 2020 Share Posted March 31, 2020 How did this work? Link to comment Share on other sites More sharing options...
Jessicakoh Posted January 24, 2021 Share Posted January 24, 2021 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). Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now