CouponBlock.php
3 months ago
CouponBlockAttributeParser.php
3 months ago
CouponBlockDetector.php
3 months ago
CouponBlockFailureTranslator.php
3 months ago
CouponBlockGenerationFailureCollector.php
3 months ago
CouponBlockGenerator.php
3 months ago
CouponBlockValidationException.php
3 months ago
CouponBlockValidator.php
3 months ago
EmailContextBuilder.php
1 month ago
index.php
3 months ago
CouponBlockFailureTranslator.php
23 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\EmailEditor\Integrations\MailPoet\Coupons; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | class CouponBlockFailureTranslator { |
| 9 | public function getFailureMessage(CouponBlockGenerationFailureCollector $failureCollector): string { |
| 10 | $failures = $failureCollector->getFailures(); |
| 11 | $firstFailure = $failures[0] ?? null; |
| 12 | if (is_array($firstFailure) && !empty($firstFailure['message']) && is_string($firstFailure['message'])) { |
| 13 | return sprintf( |
| 14 | // translators: %s is the specific coupon generation failure. |
| 15 | __('Auto-generated coupon code could not be created: %s', 'mailpoet'), |
| 16 | $firstFailure['message'] |
| 17 | ); |
| 18 | } |
| 19 | |
| 20 | return __('Auto-generated coupon codes are only supported in regular newsletters and automation emails sent to one subscriber at a time. Remove the generated coupon block or use an existing coupon before sending this email.', 'mailpoet'); |
| 21 | } |
| 22 | } |
| 23 |