Jump to content

Creating a cart rule programmatically for specific customer group


Recommended Posts

HI there, 

I'm creating a module to handle promotion through customer group and I need to create cart rule for each group to let them having free delivery. I've created cart rule and specified group restriction but I'm unable to specify the concerned group id. Any idea ? 

$rule = new CartRule();

$rule->name =  array (Configuration::get('PS_LANG_DEFAULT') => "Free liv for newbies"); 
$rule->date_from = "2019-12-12";
$rule->date_to = "2025-12-12";
$rule->quantity = 1000;
$rule->minimum_amount = 250; 
$rule->free_shipping = 1;
$rule->group_restriction = 1; // How to specify the concerned group id ?
$rule->add();

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
×
×
  • Create New...

Important Information

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