able { $wpdb = $this->wordPress->getWpdb(); $sorting = $fetchFirst ? 'ASC' : 'DESC'; $statuses = array_map(function (string $status) { return "wc-$status"; }, $this->wooCommerce->wcGetIsPaidStatuses()); $statusesPlaceholder = implode(',', array_fill(0, count($statuses), '%s')); if ($this->wooCommerce->isWooCommerceCustomOrdersTableEnabled()) { $statement = (string)$wpdb->prepare(" SELECT o.date_created_gmt FROM {$wpdb->prefix}wc_orders o WHERE o.customer_id = %d AND o.status IN ($statusesPlaceholder) AND o.total_amount > 0 ORDER BY o.date_created_gmt {$sorting} LIMIT 1 ", array_merge([$customer->get_id()], $statuses)); } else { $statement = (string)$wpdb->prepare(" SELECT p.post_date_gmt FROM {$wpdb->prefix}posts p LEFT JOIN {$wpdb->prefix}postmeta pm_total ON p.ID = pm_total.post_id AND pm_total.meta_key = '_order_total' LEFT JOIN {$wpdb->prefix}postmeta pm_user ON p.ID = pm_user.post_id AND pm_user.meta_key = '_customer_user' WHERE p.post_type = 'shop_order' AND p.post_status IN ($statusesPlaceholder) AND pm_user.meta_value = %d AND pm_total.meta_value > 0 ORDER BY p.post_date_gmt {$sorting} LIMIT 1 ", array_merge($statuses, [$customer->get_id()])); } $date = $wpdb->get_var($statement); return $date ? new DateTimeImmutable($date, new DateTimeZone('GMT')) : null; } private function getOrderProductTermIds(WC_Customer $customer, string $taxonomy): array { $wpdb = $this->wordPress->getWpdb(); $statuses = array_map(function (string $status) { return "wc-$status"; }, $this->wooCommerce->wcGetIsPaidStatuses()); $statusesPlaceholder = implode(',', array_fill(0, count($statuses), '%s')); // get all product categories that the customer has purchased if ($this->wooCommerce->isWooCommerceCustomOrdersTableEnabled()) { $orderIdsSubquery = " SELECT o.id FROM {$wpdb->prefix}wc_orders o WHERE o.status IN ($statusesPlaceholder) AND o.customer_id = %d "; } else { $orderIdsSubquery = " SELECT p.ID FROM {$wpdb->prefix}posts p LEFT JOIN {$wpdb->prefix}postmeta pm_user ON p.ID = pm_user.post_id AND pm_user.meta_key = '_customer_user' WHERE p.post_type = 'shop_order' AND p.post_status IN ($statusesPlaceholder) AND pm_user.meta_value = %d "; } $statement = (string)$wpdb->prepare(" SELECT DISTINCT tt.term_id FROM {$wpdb->prefix}term_taxonomy tt JOIN {$wpdb->prefix}woocommerce_order_items AS oi ON oi.order_id IN ($orderIdsSubquery) AND oi.order_item_type = 'line_item' JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS pid ON oi.order_item_id = pid.order_item_id AND pid.meta_key = '_product_id' JOIN {$wpdb->prefix}posts p ON pid.meta_value = p.ID JOIN {$wpdb->prefix}term_relationships tr ON IF(p.post_type = 'product_variation', p.post_parent, p.ID) = tr.object_id AND tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = %s ORDER BY tt.term_id ASC ", array_merge($statuses, [$customer->get_id(), $taxonomy])); return array_map('intval', $wpdb->get_col($statement)); } }
Fatal error: Uncaught Error: Class "MailPoet\Automation\Integrations\WooCommerce\Fields\CustomerOrderFieldsFactory" not found in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php:2018 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2008): MailPoetGenerated\FreeCachedContainer->getCustomerOrderFieldsFactoryService() #1 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2164): MailPoetGenerated\FreeCachedContainer->getCustomerFieldsFactoryService() #2 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2276): MailPoetGenerated\FreeCachedContainer->getWooCommerceIntegrationService() #3 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getInitializerService() #4 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Config...', 1) #5 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Config...') #6 /htdocs/wp-content/plugins/mailpoet/mailpoet_initializer.php(89): MailPoet\DI\ContainerWrapper->get('MailPoet\\Config...') #7 /htdocs/wp-content/plugins/mailpoet/mailpoet.php(206): require_once('/htdocs/wp-cont...') #8 /htdocs/wp-settings.php(462): include_once('/htdocs/wp-cont...') #9 /htdocs/wp-config.php(96): require_once('/htdocs/wp-sett...') #10 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #11 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #12 /htdocs/index.php(17): require('/htdocs/wp-blog...') #13 {main} thrown in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php on line 2018