0

I'm trying to create a coupon code for a customer that gets a fixed value from PHP (essentially it can be a different amount for each customer/instance of generation).

For the coupon code generation, I created a rule and used the code available here: https://mage2-blog.com/magento-1-programmatically-create-promotion-coupon-codes/

The only issue is that it seems the value must be set in the rule.

Is there a way to create coupon codes according to a rule but with different values, or do I need to create a rule as well each time I want to run this?

2

You pretty much came to the correct conclusion. If you've got different values you need separate rules.

However if you've got same amounts you can generate codes which share rules.

The way I explain it is having rules for 10 off and 20 off. Each customer you want to give 10 off you generate a 10 off code. 20 a 20 off code.

  • Alright thanks, seems wasteful to generate a rule and a code for each amount I'd want to give but I checked with one of our admins and he feels that's also the right decision. – joeybab3 Jul 12 '19 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.