403Webshell
Server IP : 104.21.14.103  /  Your IP : 18.218.132.6
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/home/giankuin/thietke365.net/wp-content/plugins/mailpoet/lib/Cron/Workers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/home/giankuin/thietke365.net/wp-content/plugins/mailpoet/lib/Cron/Workers//WooCommerceSync.php
<?php declare(strict_types = 1);

namespace MailPoet\Cron\Workers;

if (!defined('ABSPATH')) exit;


use MailPoet\Entities\ScheduledTaskEntity;
use MailPoet\Segments\WooCommerce as WooCommerceSegment;
use MailPoet\WooCommerce\Helper as WooCommerceHelper;

class WooCommerceSync extends SimpleWorker {
  const TASK_TYPE = 'woocommerce_sync';
  const SUPPORT_MULTIPLE_INSTANCES = false;
  const AUTOMATIC_SCHEDULING = false;
  const BATCH_SIZE = 1000;

  /** @var WooCommerceSegment */
  private $woocommerceSegment;

  /** @var WooCommerceHelper */
  private $woocommerceHelper;

  public function __construct(
    WooCommerceSegment $woocommerceSegment,
    WooCommerceHelper $woocommerceHelper
  ) {
    $this->woocommerceSegment = $woocommerceSegment;
    $this->woocommerceHelper = $woocommerceHelper;
    parent::__construct();
  }

  public function checkProcessingRequirements() {
    return $this->woocommerceHelper->isWooCommerceActive();
  }

  public function processTaskStrategy(ScheduledTaskEntity $task, $timer) {
    $meta = $task->getMeta();
    $highestOrderId = $this->getHighestOrderId();

    if (!isset($meta['last_checked_order_id'])) {
      $meta['last_checked_order_id'] = 0;
    }

    do {
      $this->cronHelper->enforceExecutionLimit($timer);
      $meta['last_checked_order_id'] = $this->woocommerceSegment->synchronizeCustomers(
        $meta['last_checked_order_id'],
        $highestOrderId,
        self::BATCH_SIZE
      );
      $task->setMeta($meta);
      $this->scheduledTasksRepository->persist($task);
      $this->scheduledTasksRepository->flush();
    } while ($meta['last_checked_order_id'] < $highestOrderId);

    return true;
  }

  private function getHighestOrderId(): int {
    $orders = $this->woocommerceHelper->wcGetOrders(
      [
        'status' => 'all',
        'type' => 'shop_order',
        'limit' => 1,
        'orderby' => 'ID',
        'order' => 'DESC',
        'return' => 'ids',
      ]
    );

    return (!empty($orders)) ? $orders[0] : 0;
  }
}

Youez - 2016 - github.com/yon3zu
LinuXploit