nBlock['productIds'] ?? [])); $coupon->set_excluded_product_ids($this->getItemIds($couponBlock['excludedProductIds'] ?? [])); $coupon->set_product_categories($this->getItemIds($couponBlock['productCategoryIds'] ?? [])); $coupon->set_excluded_product_categories($this->getItemIds($couponBlock['excludedProductCategoryIds'] ?? [])); $coupon->set_email_restrictions(explode(',', $couponBlock['emailRestrictions'] ?? '')); // usage limit $coupon->set_usage_limit($couponBlock['usageLimit'] ?? 0); $coupon->set_usage_limit_per_user($couponBlock['usageLimitPerUser'] ?? 0); return $coupon->save(); } private function getItemIds(array $items): array { if (empty($items)) { return []; } return array_map(function ($item) { return $item['id']; }, $items); } /** * Generates Coupon code for XXXX-XXXXXX-XXXX pattern */ private function generateRandomCode(): string { $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $length = strlen($chars); return sprintf( "%s-%s-%s", substr($chars, rand(0, $length - 5), 4), substr($chars, rand(0, $length - 8), 7), substr($chars, rand(0, $length - 5), 4) ); } private function shouldGenerateCoupon(array $block): bool { return empty($block['couponId']); } /** * Only emails that can have their body-HTML re-generated should persist the generated couponId */ private function shouldPersist(NewsletterEntity $newsletter): bool { return in_array($newsletter->getType(), NewsletterEntity::TYPES_WITH_RESETTABLE_BODY); } }
Fatal error: Uncaught Error: Class "MailPoet\WooCommerce\CouponPreProcessor" not found in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php:4858 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(3377): MailPoetGenerated\FreeCachedContainer->getCouponPreProcessorService() #1 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(3387): MailPoetGenerated\FreeCachedContainer->getPreprocessorService() #2 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(4374): MailPoetGenerated\FreeCachedContainer->getRenderer5Service() #3 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(4384): MailPoetGenerated\FreeCachedContainer->getConfirmationEmailCustomizerService() #4 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(4474): MailPoetGenerated\FreeCachedContainer->getConfirmationEmailMailerService() #5 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(4634): MailPoetGenerated\FreeCachedContainer->getSubscriberActionsService() #6 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2248): MailPoetGenerated\FreeCachedContainer->getCommentService() #7 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2276): MailPoetGenerated\FreeCachedContainer->getHooks2Service() #8 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getInitializerService() #9 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Config...', 1) #10 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Config...') #11 /htdocs/wp-content/plugins/mailpoet/mailpoet_initializer.php(89): MailPoet\DI\ContainerWrapper->get('MailPoet\\Config...') #12 /htdocs/wp-content/plugins/mailpoet/mailpoet.php(206): require_once('/htdocs/wp-cont...') #13 /htdocs/wp-settings.php(462): include_once('/htdocs/wp-cont...') #14 /htdocs/wp-config.php(96): require_once('/htdocs/wp-sett...') #15 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #16 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #17 /htdocs/index.php(17): require('/htdocs/wp-blog...') #18 {main} thrown in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php on line 4858