Beispiel #1
0
 private function fillProduct($order)
 {
     $productModel = new Product();
     $productModel->fillFromArray($order);
     /*
     if($this->ship_with && $productModel->product_shipping_sku)
     	$productModel->product_sku = $productModel->product_shipping_sku;
     */
     if (!$order['product_shipping_sku'] && $order['status'] == 'ok' && !$this->_isMainProduct) {
         array_unshift($this->_productModels, $productModel);
         $this->_isMainProduct = true;
     } else {
         array_push($this->_productModels, $productModel);
     }
     $this->_countProduct++;
     if ($this->_countProduct > self::$_maxCountProduct) {
         self::$_maxCountProduct = $this->_countProduct;
     }
     $shippingModel = new Shipping();
     $shippingModel->fillFromEnterArray($order);
     array_push($this->_shippingModels, $shippingModel);
 }
Beispiel #2
0
<?php

include_once '../settings/autoload.php';
$msql = SafeMySQL::getInstance();
$sql = "SELECT *\n        FROM `fulfillments` as f\n        WHERE f.`active` = 1";
$setFulfillment = $msql->getAll($sql);
if (!$setFulfillment) {
    die;
}
foreach ($setFulfillment as $fulfillment) {
    $fulfillmentModel = new Fulfillment();
    $fulfillmentModel->fillFromArray($fulfillment);
    $sql = "(\n                SELECT o.*, o.`created` as 'order_created', p.*, s.*, sc.`shipcat_code`, sc.`shipcat_name`, g.`gateway_id`, g.`alias`, opn.`card_number`, opn.`expiry_date`, `countries1`.`country_name` AS `country_name`, `countries2`.`country_name` AS `billing_country_name`, `states1`.`state_name` AS `state_name`, `states2`.`state_name` AS `billing_state_name`\n                FROM `orders` AS o\n                JOIN `campaigns` AS c ON o.`campaign_id` = c.`campaign_id`\n                JOIN `orders_pn` AS opn ON o.`order_id` = opn.`order_id`\n                JOIN `products` AS p ON o.`product_id` = p.`product_id`\n                LEFT JOIN `shipping` AS s ON o.`shipping_id` = s.`shipping_id`\n                LEFT JOIN `shipcat` AS sc ON s.`shipcat_id` = sc.`shipcat_id`\n                LEFT JOIN `gateways` AS g ON c.`gateway_id` = g.`gateway_id`\n                LEFT JOIN `countries` AS `countries1` ON o.`country_id` = `countries1`.`country_id`\n                LEFT JOIN `countries` AS `countries2` ON o.`billing_country_id` = `countries2`.`country_id`\n                LEFT JOIN `states` AS `states1` ON o.`country_id` = `states1`.`country_id` AND o.`state_id` = `states1`.`state_code`\n                LEFT JOIN `states` AS `states2` ON o.`billing_country_id` = `states2`.`country_id` AND o.`billing_state_id` = `states2`.`state_code`\n                WHERE o.`status` = 'ok' AND c.`fulfillment_id` = ?i)\n                UNION\n                (\n                    SELECT o.*, o.`created` as 'order_created', p.*, s.*, sc.`shipcat_code`, sc.`shipcat_name`, NULL, NULL, NULL, NULL, `countries1`.`country_name` AS `country_name`, `countries2`.`country_name` AS `billing_country_name`, `states1`.`state_name` AS `state_name`, `states2`.`state_name` AS `billing_state_name`\n                    FROM `orders` AS o\n                    JOIN `campaigns` AS c ON o.`campaign_id` = c.`campaign_id`\n                    JOIN `products` AS p ON o.`product_id` = p.`product_id`\n                    LEFT JOIN `shipping` AS s ON o.`shipping_id` = s.`shipping_id`\n                    LEFT JOIN `shipcat` AS sc ON s.`shipcat_id` = sc.`shipcat_id`\n                    LEFT JOIN `countries` AS `countries1` ON o.`country_id` = `countries1`.`country_id`\n                    LEFT JOIN `countries` AS `countries2` ON o.`billing_country_id` = `countries2`.`country_id`\n                    LEFT JOIN `states` AS `states1` ON o.`country_id` = `states1`.`country_id` AND o.`state_id` = `states1`.`state_code`\n                    LEFT JOIN `states` AS `states2` ON o.`billing_country_id` = `states2`.`country_id` AND o.`billing_state_id` = `states2`.`state_code`\n                    WHERE `status` = 'upsell' AND `ship_with` IN (\n                    SELECT `order_id`\n                    FROM `orders` AS o\n                    WHERE o.`status` = 'ok' AND c.`fulfillment_id` = ?i\n                )\n            )\n            ORDER BY `order_id`";
    $orders = $msql->getInd('order_id', $sql, $fulfillmentModel->fulfillment_id, $fulfillmentModel->fulfillment_id);
    if (!$orders) {
        continue;
    }
    $filePath = OrderFTP::createFtpOrders($orders, $fulfillmentModel);
    $fulfillmentModel->filePath = $filePath;
    if ($fulfillmentModel->uploadToFulfillment()) {
        $sql = "UPDATE `orders` as o\n                JOIN `campaigns` AS c ON o.`campaign_id` = c.`campaign_id`\n                JOIN `orders_pn` AS opn ON o.`order_id` = opn.`order_id`\n                JOIN `products` AS p ON o.`product_id` = p.`product_id`\n                LEFT JOIN `shipping` AS s ON o.`shipping_id` = s.`shipping_id`\n                LEFT JOIN `shipcat` AS sc ON s.`shipcat_id` = sc.`shipcat_id`\n                LEFT JOIN `gateways` AS g ON c.`gateway_id` = g.`gateway_id`\n                SET o.`status` = 'sent'\n                WHERE o.`status` = 'ok' AND o.`order_id` IN(?a)";
        $msql->query($sql, OrderFTP::$updateOrders);
        foreach (OrderFTP::$updateOrders as $orderID) {
            OrderLog::createLog(0, $orderID, 19);
        }
    }
}