Exemple #1
0
 public static function createOrder(Order $order)
 {
     echo '以下の内容で注文データを作成しました' . PHP_EOL;
     echo "商品番号\t" . "商品名\t" . "単価\t" . "数量\t" . "金額\t" . PHP_EOL;
     foreach ($order->getItems() as $order_item) {
         echo $order_item->getItem()->getId() . "\t" . $order_item->getItem()->getName() . "\t" . $order_item->getItem()->getPrice() . "\t" . $order_item->getAmount() . "\t" . $order_item->getItem()->getPrice() * $order_item->getAmount() . PHP_EOL;
     }
 }
 /**
  * Distribute Items.
  * 
  * @param Order $order
  * @param float $maxPricePerPackage
  * 
  * @return void
  * 
  * @throws \UnexpectedValueException
  */
 public function distributeItems(Order $order, $maxPricePerPackage)
 {
     // Calculate initial number of packages
     $numPackages = ceil($order->getTotalPrice() / $maxPricePerPackage);
     if ($numPackages > count($order->getItems())) {
         throw new \UnexpectedValueException('Some items will not fit into packages.');
     }
     $this->distributeItemsIntoPackages($order, $maxPricePerPackage, $numPackages);
 }
Exemple #3
0
 public static function createOrder(Order $order)
 {
     echo "注文完了しました。\n";
     echo "商品番号\t商品名\t単価\t数量\t金額\n";
     foreach ($order->getItems() as $order_item) {
         echo $order_item->getItem()->getId() . "\t";
         echo $order_item->getItem()->getName() . "\t";
         echo $order_item->getItem()->getPrice() . "\t";
         echo $order_item->getAmount() . "\t";
         echo $order_item->getItem()->getPrice() * $order_item->getAmount();
         echo "\n";
     }
 }
 protected function setOrdersShopp()
 {
     $time = strtotime($this->date . ' UTC');
     $dateInLocal = date("Y-m-d H:i:s", $time);
     global $wpdb;
     /*$rows = $wpdb->get_results(
     		"SELECT * FROM " . $wpdb->prefix . "shopp_purchase WHERE modified > '" . $dateInLocal . "' and (txnstatus = 'authed' or txnstatus = 'captured') order by modified ASC"
     			, ARRAY_A);*/
     $rows = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "shopp_purchase WHERE modified > '" . $dateInLocal . "' order by modified ASC", ARRAY_A);
     //CREATE AN HOOK ON FUNCTION sc_orders_rows to allow customers to make changes
     $rows = apply_filters('sc_orders_rows', $rows, $this);
     foreach ($rows as $row) {
         $orderObj = new Order($this->software, $this->date, $row);
         $array = $orderObj->getItems();
         if (!empty($array)) {
             array_push($this->orders, new Order($this->software, $this->date, $row));
         }
     }
 }
function isDownloadable($software, $date, $row)
{
    $toReturn = false;
    global $wpdb;
    $table = $wpdb->prefix . "postmeta";
    $order = new Order($software, $date, $row);
    $i = 0;
    $j = 0;
    foreach ($order->getItems() as $item) {
        $i++;
        $result = $wpdb->get_row("SELECT * FROM " . $table . " WHERE post_id = " . $item->getProductID() . " and meta_key = '_downloadable'", ARRAY_A);
        if ($result['meta_value'] == "yes") {
            $toReturn = true;
            $j++;
        }
    }
    if ($i != $j) {
        $toReturn = false;
    }
    return $toReturn;
}
Exemple #6
0
 public static function order(Order $order)
 {
     $item_dao = ItemDao::getInstance();
     //1.ItemDaoインスタンスを取得し、
     foreach ($order->getItems() as $order_item) {
         //2.在庫を引き当て、
         $item_dao->setAside($order_item);
     }
     OrderDao::createOrder($order);
     //3.注文結果を表示する
 }
 protected function setNumber($date)
 {
     $time = strtotime($date . ' UTC');
     $dateInLocal = date("Y-m-d H:i:s", $time);
     global $wpdb;
     $split = explode('.', $this->software->getVersion());
     if ($this->software->isCompatible()) {
         // Cas Shopperpress
         if ('shopperpress' == $this->software->getSoftware()) {
             $orders = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "orderdata WHERE CONCAT(order_date,' ',order_time) > '" . $dateInLocal . "' order by CONCAT(order_date,' ',order_time) ASC");
             foreach ($orders as $order) {
                 $this->number++;
             }
         } else {
             if ('Shopp' == $this->software->getSoftware()) {
                 $orders = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "shopp_purchase WHERE modified > '" . $dateInLocal . "' and (txnstatus = 'authed' or txnstatus = 'captured') order by modified ASC", ARRAY_A);
                 foreach ($orders as $order) {
                     $orderObj = new Order($this->software, $date, $order);
                     $array = $orderObj->getItems();
                     $this->number++;
                 }
             } else {
                 if ('Woocommerce' == $this->software->getSoftware()) {
                     include_once PLUGIN_PATH_SHIPWORKSWORDPRESS . 'functions/woocommerce/functionsWoocommerce.php';
                     $orders = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "posts WHERE post_modified_gmt > '" . $dateInLocal . "' AND post_type = 'shop_order' order by post_modified_gmt ASC", ARRAY_A);
                     $count = 0;
                     foreach ($orders as $order) {
                         if ($count < 100) {
                             if (!isDownloadable($this->software, null, $order)) {
                                 $this->number++;
                                 $count = $count + 1;
                             }
                         } else {
                             break 1;
                         }
                     }
                 } else {
                     if ('WP eCommerce' == $this->software->getSoftware()) {
                         $orders = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "wpsc_purchase_logs WHERE date > '" . $time . "' order by date ASC", ARRAY_A);
                         foreach ($orders as $order) {
                             $this->number++;
                         }
                     } else {
                         if ('Cart66 Lite' == $this->software->getSoftware()) {
                             $orders = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "cart66_orders WHERE ordered_on > '" . $dateInLocal . "' order by ordered_on ASC", ARRAY_A);
                             foreach ($orders as $order) {
                                 $this->number++;
                             }
                         } else {
                             if ('Cart66 Pro' == $this->software->getSoftware()) {
                                 $orders = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "cart66_orders WHERE ordered_on > '" . $dateInLocal . "' order by ordered_on ASC", ARRAY_A);
                                 foreach ($orders as $order) {
                                     $this->number++;
                                 }
                             } else {
                                 if ('Jigoshop' == $this->software->getSoftware()) {
                                     include_once PLUGIN_PATH_SHIPWORKSWORDPRESS . 'functions/jigoshop/functionsJigoshop.php';
                                     $orders = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "posts WHERE post_modified_gmt > '" . $dateInLocal . "' AND post_type = 'shop_order' order by post_modified_gmt ASC", ARRAY_A);
                                     foreach ($orders as $order) {
                                         $this->number++;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 private function mapToDTO(Order $order)
 {
     return ['number' => $order->getNumber(), 'customer' => $order->getCustomer(), 'items' => array_map(function (OrderItem $item) {
         return ['productName' => $item->getProductName(), 'price' => ['amount' => $item->getPrice()->getAmount(), 'currency' => $item->getPrice()->getCurrency()], 'quantity' => $item->getQuantity()];
     }, $order->getItems())];
 }