當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Shipment::import方法代碼示例

本文整理匯總了PHP中Shipment::import方法的典型用法代碼示例。如果您正苦於以下問題:PHP Shipment::import方法的具體用法?PHP Shipment::import怎麽用?PHP Shipment::import使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Shipment的用法示例。


在下文中一共展示了Shipment::import方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 public function __construct($data = [], $connection = null)
 {
     $this->connection = $connection;
     foreach (['id', 'order_reference', 'shop_system', 'customer_number', 'service_point_reference', 'weight_in_g'] as $prop) {
         if (isset($data[$prop])) {
             $this->{$prop} = $data[$prop];
         }
     }
     foreach (['recipient', 'billing_contact'] as $prop) {
         $this->{$prop} = isset($data[$prop]) ? new Address($data[$prop]) : null;
     }
     foreach (['subtotal', 'shipping_cost', 'tax_value'] as $prop) {
         $this->{$prop} = isset($data[$prop]) ? Money::import($data[$prop]) : null;
     }
     $this->product = isset($data['product']) ? new Product($data['product'], $this->connection) : null;
     if (isset($data['items'])) {
         $this->items = [];
         foreach ($data['items'] as $item_data) {
             $this->items[] = new Item($item_data);
         }
     }
     if (isset($data['shipments'])) {
         $this->shipments = [];
         foreach ($data['shipments'] as $url) {
             $this->shipments[] = Shipment::import($url, $this->connection);
         }
     }
 }
開發者ID:sendworks,項目名稱:sendworks-php,代碼行數:28,代碼來源:Order.php

示例2: save

 public function save($shipment)
 {
     if ($shipment->id) {
         $path = "shipments/" . $shipment->id;
     } else {
         $path = "shipments";
     }
     $response = $this->client()->post($path, ['json' => $shipment->toHash()]);
     if ($response->getStatusCode() == 200) {
         return Shipment::import(json_decode($response->getBody(), true), $this->connection);
     } else {
         $this->raiseError($response);
     }
 }
開發者ID:sendworks,項目名稱:sendworks-php,代碼行數:14,代碼來源:ShipmentsCollection.php


注:本文中的Shipment::import方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。