Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with Commerce 5 coupon codes #501

Open
bartrylant opened this issue Oct 7, 2024 · 1 comment
Open

Integration with Commerce 5 coupon codes #501

bartrylant opened this issue Oct 7, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@bartrylant
Copy link

Feature Request

In Commerce 5 you can bulk create coupon codes. It would be very nice if there was a way to send individual coupon codes to every mailing list subscriber, so every coupon code can only be used by the person who received the mail (instead of sending out generic coupon codes). So the FR is: make an integration with Commerce 5 coupon codes.

Plugin Version

3.5.2

@bartrylant bartrylant added the enhancement New feature or request label Oct 7, 2024
@bencroker
Copy link
Collaborator

This should be relatively straightforward to achieve via a custom plugin/module by listening to one of the events triggered before sending an email. In this example, you would use __COUPON_CODE__ in your campaign template and replace it with a newly created discount code.

use putyourlightson\campaign\events\SendoutEmailEvent;
use putyourlightson\campaign\services\SendoutsService;
use yii\base\Event;

Event::on(SendoutsService::class, SendoutsService::EVENT_BEFORE_SEND_EMAIL,
    function(SendoutEmailEvent $event) {
        $couponCode = $this->createDiscountCode();
        $event->message = str_replace('__COUPON_CODE__', $couponCode, $event->message);
    }
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants