コード例 #1
0
ファイル: ExpressCheckout.php プロジェクト: saiber/www
 public function deleteInstancesByOrder(CustomerOrder $order)
 {
     // remove other ExpressCheckout instances for this order
     $f = new ARDeleteFilter();
     $f->setCondition(new EqualsCond(new ARFieldHandle('ExpressCheckout', 'orderID'), $order->getID()));
     ActiveRecordModel::deleteRecordSet('ExpressCheckout', $f);
 }
コード例 #2
0
ファイル: OrderLog.php プロジェクト: saiber/www
 public static function getRecordSetByOrder(CustomerOrder $order, ARSelectFilter $filter = null, $loadReferencedRecords = false)
 {
     if (!$filter) {
         $filter = new ARSelectFilter();
     }
     $filter->mergeCondition(new EqualsCond(new ARFieldHandle(__CLASS__, 'orderID'), $order->getID()));
     $filter->setOrder(new ARFieldHandle(__CLASS__, 'time'), ARSelectFilter::ORDER_DESC);
     return self::getRecordSet($filter, $loadReferencedRecords);
 }
コード例 #3
0
ファイル: OrderController.php プロジェクト: saiber/www
 public function setSingleAddress()
 {
     $f = new ARUpdateFilter(new EqualsCond(new ARFieldHandle('OrderedItem', 'customerOrderID'), $this->order->getID()));
     $f->addModifier('OrderedItem.shipmentID', new ARExpressionHandle('NULL'));
     ActiveRecordModel::updateRecordSet('OrderedItem', $f);
     $this->order->isMultiAddress->set(false);
     $this->order->loadAll();
     $this->order->mergeItems();
     $this->order->resetShipments();
     SessionOrder::save($this->order);
     $this->order->deleteRelatedRecordSet('Shipment');
     return new ActionRedirectResponse('order', 'index');
 }
コード例 #4
0
ファイル: OrderHistory.php プロジェクト: saiber/www
 private function serializeToArray(CustomerOrder $order)
 {
     $array = array();
     $array['ID'] = $order->getID();
     $array['totalAmount'] = $order->totalAmount->get();
     $array['isCancelled'] = (int) $order->isCancelled->get();
     $array['status'] = (int) $order->status->get();
     $array['shipments'] = array();
     foreach ($order->getShipments() as $shipment) {
         $shippingServiceArray = null;
         if ($shipment->shippingService->get() && (int) $shipment->shippingService->get()->getID()) {
             $shippingServiceArray = $shipment->shippingService->get()->toArray();
         } else {
             $shippingService = unserialize($shipment->shippingServiceData->get());
             $shippingServiceArray = null;
             if (is_object($shippingService)) {
                 $shippingService->setApplication($order->getApplication());
                 $shippingServiceArray = $shippingService->toArray();
             }
         }
         $array['shipments'][$shipment->getID()] = array('ID' => $shipment->getID(), 'status' => (int) $shipment->status->get(), 'ShippingService' => $shippingServiceArray);
     }
     $array['items'] = array();
     foreach ($order->getOrderedItems() as $item) {
         $array['items'][$item->getID()] = array('ID' => $item->getID(), 'shipmentID' => $item->shipment->get() ? $item->shipment->get()->getID() : null, 'count' => (int) $item->count->get(), 'price' => $item->price->get(), 'Product' => array('ID' => (int) $item->getProduct()->getID(), 'sku' => $item->getProduct()->sku->get(), 'name' => $item->getProduct()->getName($order->getApplication()->getDefaultLanguageCode()), 'isDownloadable' => (int) $item->getProduct()->isDownloadable()), 'Shipment' => $item->shipment->get() && isset($array['shipments'][$item->shipment->get()->getID()]) ? $array['shipments'][$item->shipment->get()->getID()] : array('ID' => 0));
     }
     // @todo: dirty fix
     if ($order->shippingAddress->get()) {
         if ($order->shippingAddress->get()->state->get()) {
             $order->shippingAddress->get()->state->get()->load();
         }
         $array['ShippingAddress'] = $order->shippingAddress->get()->toArray();
     } else {
         $array['ShippingAddress'] = array();
     }
     if ($order->billingAddress->get()) {
         if ($order->billingAddress->get()->state->get()) {
             $order->billingAddress->get()->state->get()->load();
         }
         $array['BillingAddress'] = $order->billingAddress->get()->toArray();
     } else {
         $array['BillingAddress'] = array();
     }
     return $array;
 }
コード例 #5
0
ファイル: SessionOrder.php プロジェクト: GregerA/livecart
 public static function setOrder(CustomerOrder $order)
 {
     $session = new Session();
     $session->set('CustomerOrder', $order->getID());
     $currency = $order->getCurrency();
     $currID = $currency->getID();
     $total = $order->getTotal();
     $orderArray = array('total' => array($currID => $total));
     $orderArray['formattedTotal'] = array($currID => $currency->getFormattedPrice($orderArray['total'][$currID]));
     $orderArray['basketCount'] = $order->getShoppingCartItemCount();
     $orderArray['currencyID'] = $currID;
     $isOrderable = $order->isOrderable();
     $orderArray['isOrderable'] = is_bool($isOrderable) ? $isOrderable : false;
     $items = array();
     foreach ($order->getPurchasedItems() as $item) {
         $items[] = $item->toArray();
     }
     $orderArray['items'] = new RuleOrderContainer($items);
     $orderArray['items']->setCoupons($order->getCoupons());
     $orderArray['items']->setTotal($total);
     $session->set('orderData', $orderArray);
 }
コード例 #6
0
 public function __construct(CustomerOrder $order, Currency $currency)
 {
     parent::__construct();
     $this->order = $order;
     $order->loadAll();
     // billing address
     if ($address = $order->billingAddress->get()) {
         $fields = array('firstName', 'lastName', 'companyName', 'phone', 'city', 'postalCode', 'countryID' => 'country');
         foreach ($fields as $key => $field) {
             $addressField = is_numeric($key) ? $field : $key;
             $this->{$field}->set($address->{$addressField}->get());
         }
         $this->state->set($this->getStateValue($address));
         $this->address->set($address->address1->get() . ' ' . $address->address2->get());
     }
     // shipping address
     $address = $order->shippingAddress->get();
     if (!$address) {
         $address = $order->billingAddress->get();
     }
     if ($address) {
         foreach ($fields as $key => $field) {
             $addressField = is_numeric($key) ? $field : $key;
             $field = 'shipping' . ucfirst($field);
             $this->{$field}->set($address->{$addressField}->get());
         }
         $this->shippingState->set($this->getStateValue($address));
         $this->shippingAddress->set($address->address1->get() . ' ' . $address->address2->get());
     }
     // amount
     $order->currency->set($currency);
     $this->amount->set(round($order->getDueAmount(), 2));
     $this->currency->set($currency->getID());
     // transaction identification
     $this->invoiceID->set($order->getID());
     if (isset($_SERVER['REMOTE_ADDR'])) {
         $this->ipAddress->set($_SERVER['REMOTE_ADDR']);
     }
     // customer identification
     if ($order->user->get()) {
         $order->user->get()->load();
         $this->shippingEmail->set($order->user->get()->email->get());
         $this->email->set($order->user->get()->email->get());
         $this->clientID->set($order->user->get()->getID());
     }
     // order details
     // load variation data
     $variations = new ProductSet();
     foreach ($order->getShoppingCartItems() as $item) {
         if ($item->product->get() && $item->product->get()->parent->get()) {
             $variations->unshift($item->product->get());
         }
     }
     if ($variations->size()) {
         $variations->loadVariations();
     }
     foreach ($order->getShoppingCartItems() as $item) {
         $product = $item->getProduct();
         $variations = array();
         foreach ($product->getRegisteredVariations() as $variation) {
             $variations[] = $variation->getValueByLang('name');
         }
         $ri = RecurringItem::getInstanceByOrderedItem($item);
         if ($ri && $ri->isExistingRecord()) {
             $ri->load();
         } else {
             $ri = null;
         }
         $this->addLineItem($product->getName() . ($variations ? ' (' . implode(' / ', $variations) . ')' : ''), $item->getPrice(false), $item->count->get(), $product->sku->get(), $ri);
     }
     if ($discount = $order->getFixedDiscountAmount()) {
         $this->addLineItem(CustomerOrder::getApplication()->translate('_discount'), $discount * -1, 1, 'discount');
     }
     foreach ($order->getShipments() as $shipment) {
         if ($rate = $shipment->getSelectedRate()) {
             $rate = $rate->toArray();
             $name = empty($rate['ShippingService']['name_lang']) ? $rate['serviceName'] : $rate['ShippingService']['name_lang'];
             $this->addLineItem($name, $shipment->getShippingTotalBeforeTax(), 1, 'shipping');
         }
     }
     if ($taxes = $order->getTaxBreakdown()) {
         foreach ($taxes as $id => $amount) {
             $tax = Tax::getInstanceById($id, true);
             $this->addLineItem($tax->getValueByLang('name', null), $amount, 1, 'tax');
         }
     }
 }
コード例 #7
0
ファイル: CustomerOrder.php プロジェクト: GregerA/livecart
    public function updateStartAndEndDates(CustomerOrder $previousOrder, $recurringItems)
    {
        // calling this more than once for same record will end with catastrophe.
        // echo "\n--------------------------\n";
        foreach ($recurringItems as $recurringItem) {
            $recurringItemID = $recurringItem->getID();
            // anyone should work, because $recurringItems should be grouped by type and length. ID is required for getting period length in calendar days (done with sql).
            break;
            // echo $recurringItem->getID(), "\n";
        }
        // find end date (first order does not have endDate)
        //    add one day = start date,
        // find 2 end date periods
        //    new end date.
        $data = ActiveRecordModel::getDataBySql('SELECT
			TIMESTAMP(DATE( /*remove hh:mm:ss */
				ADDDATE(
					IF(TO_DAYS(co.endDate) IS NULL,' . self::sqlForEndDate('co.startDate') . ',
						co.endDate
					),
				INTERVAL 1 DAY)
			)) AS startDate,
			' . self::sqlForEndDate('co.startDate', 2) . ' as endDate
			FROM
				CustomerOrder co
				INNER JOIN RecurringItem ri ON ri.ID=' . $recurringItemID . '
			WHERE
				co.ID = ' . $previousOrder->getID());
        //
        if ($data && count($data) == 1) {
            $data = array_shift($data);
            $this->startDate->set($data['startDate']);
            $this->endDate->set($data['endDate']);
            return true;
        }
        return false;
    }
コード例 #8
0
 public static function registerLastViewedOrder(CustomerOrder $order)
 {
     self::registerLastViewed(array('orderID' => $order->getID(), 'instance' => $order));
 }