Allow dynamic genration of coupon code for some newsletters
Those newsletters that allow updating their body html should persist the couponId along side the Coupon block settings so that on the next rendering attempt the same coupon code is used [MAILPOET-4763]
This commit is contained in:
@@ -38,6 +38,14 @@ class NewsletterEntity {
|
||||
const STATUS_SENDING = 'sending';
|
||||
const STATUS_SENT = 'sent';
|
||||
|
||||
/**
|
||||
* Newsletters that their body HTML can get re-generated
|
||||
* @see NewsletterSaveController::updateQueue
|
||||
*/
|
||||
const TYPES_WITH_RESETTABLE_BODY = [
|
||||
NewsletterEntity::TYPE_STANDARD,
|
||||
];
|
||||
|
||||
// automatic newsletters status
|
||||
const STATUS_ACTIVE = 'active';
|
||||
|
||||
|
@@ -155,11 +155,9 @@ class CouponPreProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* For some renders/send outs the coupon id shouldn't be persisted along the coupon block
|
||||
* This is a placeholder method and should be augmented with more newsletter types that should dynamically get coupons
|
||||
* and not have one single coupon saved along with the block's settings
|
||||
* Only emails that can have their body-HTML re-generated should persist the generated couponId
|
||||
*/
|
||||
private function shouldPersist(NewsletterEntity $newsletter): bool {
|
||||
return $newsletter->getType() !== NewsletterEntity::TYPE_AUTOMATIC;
|
||||
return in_array($newsletter->getType(), NewsletterEntity::TYPES_WITH_RESETTABLE_BODY);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user