| @@ -138,8 +138,11 @@ | ||
| 138 | 138 | if (!WooMailerLiteCache::get('table_check')) { |
| 139 | 139 | WooMailerLiteMigration::migrate(); |
| 140 | 140 | WooMailerLiteCache::set('table_check', true, 86400); |
| 141 | 141 | } |
| 142 | + WooMailerLiteMigration::addCartsCreatedAtIndex(); | |
| 143 | + $this->loader->add_action('init', $this, 'scheduleCartCleanupJob'); | |
| 144 | + $this->loader->add_action('init', WooMailerLiteAdmin::instance(), 'migrateProductVariantsOrIgnore'); | |
| 142 | 145 | $jobsDirectory = __DIR__ . '/./jobs'; |
| 143 | 146 | $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($jobsDirectory)); |
| 144 | 147 | foreach ($iterator as $job) { |
| 145 | 148 | if ($job->isFile() && $job->getExtension() === 'php') { |
| @@ -153,8 +156,23 @@ | ||
| 153 | 156 | } |
| 154 | 157 | } |
| 155 | 158 | } |
| 156 | 159 | |
| 160 | + public function scheduleCartCleanupJob() | |
| 161 | + { | |
| 162 | + if (WooMailerLiteCache::get('cart_cleanup_scheduled')) { | |
| 163 | + return; | |
| 164 | + } | |
| 165 | + if (!function_exists('as_next_scheduled_action') || !function_exists('as_schedule_recurring_action')) { | |
| 166 | + return; | |
| 167 | + } | |
| 168 | + | |
| 169 | + if (!as_next_scheduled_action(WooMailerLiteCartCleanupJob::class)) { | |
| 170 | + as_schedule_recurring_action(time(), DAY_IN_SECONDS, WooMailerLiteCartCleanupJob::class); | |
| 171 | + } | |
| 172 | + WooMailerLiteCache::set('cart_cleanup_scheduled', true, 86400); | |
| 173 | + } | |
| 174 | + | |
| 157 | 175 | /** |
| 158 | 176 | * Register all of the hooks related to the public-facing functionality |
| 159 | 177 | * of the plugin. |
| 160 | 178 | * |
| @@ -183,8 +201,10 @@ | ||
| 183 | 201 | $this->loader->add_action('woocommerce_cart_item_set_quantity', $service, 'handleCartUpdated'); |
| 184 | 202 | $this->loader->add_action('woocommerce_add_to_cart', $service, 'handleCartUpdated'); |
| 185 | 203 | $this->loader->add_action('woocommerce_cart_item_removed', $service, 'handleCartUpdated'); |
| 186 | 204 | $this->loader->add_action('woocommerce_before_checkout_form', $service, 'handleCheckoutPage'); |
| 205 | + $this->loader->add_action('woocommerce_checkout_create_order', WooMailerLiteOrderController::instance(), 'persistLanguageForOrder'); | |
| 206 | + $this->loader->add_action('woocommerce_store_api_checkout_update_order_from_request', WooMailerLiteOrderController::instance(), 'persistLanguageForOrder'); | |
| 187 | 207 | $this->loader->add_action('woocommerce_order_status_changed', WooMailerLiteOrderController::instance(), 'handleOrderStatusChanged'); |
| 188 | 208 | $this->loader->add_action('woocommerce_saved_order_items', WooMailerLiteOrderController::instance(), 'handleOrderStatusChanged'); |
| 189 | 209 | $this->loader->add_action('woocommerce_order_status_completed', WooMailerLiteOrderController::instance(), 'handleOrderStatusChanged'); |
| 190 | 210 | $this->loader->add_action('wp_ajax_woo_mailerlite_set_cart_email', $service, 'setCartEmail'); |