当前位置: 首页>>代码示例>>PHP>>正文


PHP Shipment::getInstanceByID方法代码示例

本文整理汇总了PHP中Shipment::getInstanceByID方法的典型用法代码示例。如果您正苦于以下问题:PHP Shipment::getInstanceByID方法的具体用法?PHP Shipment::getInstanceByID怎么用?PHP Shipment::getInstanceByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Shipment的用法示例。


在下文中一共展示了Shipment::getInstanceByID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete

 /**
  * @role update
  */
 public function delete()
 {
     $shipment = Shipment::getInstanceByID('Shipment', (int) $this->request->get('id'), true, array('Order' => 'CustomerOrder'));
     $shipment->order->get()->loadAll();
     $history = new OrderHistory($shipment->order->get(), $this->user);
     $shipment->delete();
     $shipment->order->get()->updateStatusFromShipments();
     $shipment->order->get()->save();
     $history->saveLog();
     return new JSONResponse(array('deleted' => true), 'success');
 }
开发者ID:saiber,项目名称:www,代码行数:14,代码来源:ShipmentController.php

示例2: changeShipment

 /**
  * @role update
  */
 public function changeShipment()
 {
     if (($id = (int) $this->request->get("id", false)) && ($fromID = (int) $this->request->get("from", false)) && ($toID = (int) $this->request->get("to", false))) {
         $item = OrderedItem::getInstanceByID('OrderedItem', $id, true, array('Product'));
         $oldShipment = Shipment::getInstanceByID('Shipment', $fromID, true, array('Order' => 'CustomerOrder', 'ShippingAddress' => 'UserAddress', 'Currency'));
         $newShipment = Shipment::getInstanceByID('Shipment', $toID, true, array('Order' => 'CustomerOrder', 'ShippingAddress' => 'UserAddress', 'Currency'));
         $history = new OrderHistory($oldShipment->order->get(), $this->user);
         $zone = $oldShipment->getDeliveryZone();
         if ($oldShipment !== $newShipment) {
             $oldShipment->loadItems();
             $oldShipment->removeItem($item);
             $newShipment->loadItems();
             $newShipment->addItem($item);
             if ($oldShipment->getShippingService()) {
                 $shipmentRates = $zone->getShippingRates($oldShipment);
                 $oldShipment->setAvailableRates($shipmentRates);
                 $oldShipment->setRateId($oldShipment->getShippingService()->getID());
                 $oldShipment->save();
             }
             if ($newShipment->getShippingService()) {
                 $shipmentRates = $zone->getShippingRates($newShipment);
                 $newShipment->setAvailableRates($shipmentRates);
                 $newShipment->setRateId($newShipment->getShippingService()->getID());
                 $newShipment->save();
             }
             $item->save();
             if ($newShipment->getSelectedRate() || !$newShipment->getShippingService() || !is_int($newShipment->getShippingService()->getID())) {
                 $item->save();
                 $oldShipment->recalculateAmounts();
                 $newShipment->recalculateAmounts();
                 $oldShipment->save();
                 $newShipment->save();
                 $history->saveLog();
                 return new JSONResponse(array('oldShipment' => array('ID' => $oldShipment->getID(), 'amount' => $oldShipment->amount->get(), 'shippingAmount' => $oldShipment->shippingAmount->get(), 'taxAmount' => $oldShipment->taxAmount->get(), 'total' => (double) $oldShipment->shippingAmount->get() + (double) $oldShipment->amount->get() + (double) $oldShipment->taxAmount->get(), 'prefix' => $oldShipment->getCurrency()->pricePrefix->get(), 'suffix' => $oldShipment->getCurrency()->priceSuffix->get()), 'newShipment' => array('ID' => $newShipment->getID(), 'amount' => $newShipment->amount->get(), 'shippingAmount' => $newShipment->shippingAmount->get(), 'taxAmount' => $newShipment->taxAmount->get(), 'total' => (double) $newShipment->shippingAmount->get() + (double) $newShipment->amount->get() + (double) $newShipment->taxAmount->get(), 'prefix' => $newShipment->getCurrency()->pricePrefix->get(), 'suffix' => $newShipment->getCurrency()->priceSuffix->get(), 'Order' => $newShipment->order->get()->toFlatArray())), 'success', $this->translate('_ordered_item_was_successfully_moved'));
             } else {
                 return new JSONResponse(array('oldShipment' => array('ID' => $fromID), 'newShipment' => array('ID' => $toID)), 'failure', $this->translate('_this_shipping_service_has_no_available_rates'));
             }
         }
     } else {
         return new JSONResponse(array('status' => 'failure'));
     }
 }
开发者ID:GregerA,项目名称:livecart,代码行数:45,代码来源:OrderedItemController.php


注:本文中的Shipment::getInstanceByID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。