当前位置: 首页>>代码示例>>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;未经允许,请勿转载。