Jump to content
mantas393

How to apply cart rule programmatically? [SOLVED]

Recommended Posts

Posted (edited)

What I tried:

  • I created a discount coupon in back office. Coupon ID is 54
  • A hook calls a module when Cart page is loaded.
  • In my module i wrote:
$cart_rule = new CartRule(54);
$cart_rule->add();

 

Edited by mantas393

Share this post


Link to post
Share on other sites

Hi..

use this and see result i hope this help for you

$this->context->cart->addCartRule($id_cart_rule);

Thanks

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, Nishith said:

Hi..

use this and see result i hope this help for you

$this->context->cart->addCartRule($id_cart_rule);

Thanks

This worked! Thanks!

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

×

Important Information

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