kg-bot/laravel-webshipper

此软件包最新版本(v3.1.2)没有提供许可信息。

Laravel PHP 的 Webshipper API 包装器

v3.1.2 2019-12-17 10:48 UTC

This package is auto-updated.

Last update: 2024-09-05 17:34:56 UTC


README

本插件为 Webshipper API 提供了 Laravel 包装器。
目前 Webshipper 使用了 2 个版本的 API。V1 API 使用其自己的类,而 V2 使用不同的类
任何 API 的使用都基于您所使用的类,因此可以按需使用

laravel-webshipper v1

创建和使用 Webshipper API

为了实例化和创建 API 实例

use Webshipper\Webshipper';
$api = new Webshipper();

使用 API 创建订单

API 有一个名为 orders 的公开属性 $this->api->orders
此属性用于操作订单

创建 Webshipper 订单 $data 对象

[
        'billing_address' =>
            [
                'address_1' => 'Test Road 66',
                'address_2' => 'Test Road 120',
                'city' => 'Test City',
                'company_name' => 'webshipr Aps',
                'contact_name' => 'mathias',
                'country_code' => 'DK',
                'email' => 'info@webshipr.com',
                'phone' => '66666666',
                'phone_area' => '+45',
                'zip' => '8230',
            ],
        'delivery_address' =>
            [
                'address_1' => 'Test Road 66',
                'address_2' => 'Test Road 120',
                'city' => 'Test City',
                'company_name' => 'webshipr Aps',
                'contact_name' => 'mathias',
                'country_code' => 'DK',
                'email' => 'info@webshipr.com',
                'phone' => '66666666',
                'phone_area' => '+45',
                'zip' => '8230',
            ],
        'dynamic_address' =>
            [
                'address_1' => 'GLS Pakkeshop XX',
                'address_2' => '',
                'city' => 'Åbyhøj',
                'company_name' => 'GLS Pakkeshop XX',
                'contact_name' => '',
                'country_code' => 'DK',
                'email' => 'info@webshipr.com',
                'phone' => '',
                'phone_area' => '',
                'zip' => '8230',
            ],
        'custom_pickup_identifier' => '341',
        'items' =>
            [
                [
                    'description' => 'Testdesc1',
                    'product_name' => 'TestName1',
                    'product_no' => 12,
                    'quantity' => 45,
                    'uom' => 'pcs',
                    'weight' => 500,
                    'location' => 'EP432S2',
                    'sub_total_price' => 50,
                    'total_price' => 60,
                    'currency' => 'EUR',
                    'tarif_number' => '1234',
                    'origin_country_code' => 'NO',
                    'ext_ref' => 'myitemref1',
                ],
                [
                    'description' => 'Testdesc1',
                    'product_name' => 'TestName1',
                    'product_no' => 12,
                    'quantity' => 45,
                    'uom' => 'pcs',
                    'weight' => 500,
                    'location' => 'EP432S2',
                    'sub_total_price' => 50,
                    'total_price' => 60,
                    'currency' => 'EUR',
                    'tarif_number' => '1234',
                    'origin_country_code' => 'NO',
                    'ext_ref' => 'myitemref2',
                ],
            ],
        'webshop_id' => 3752,
        'ext_ref' => '00929812',
        'shipping_rate_id' => 983,
        'user_id' => 123,
        'comment' => 'Sample Comment',
    ]

完整的创建订单过程如下

$this->api->orders->create(
    [
            'billing_address' =>
                [
                    'address_1' => 'Test Road 66',
                    'address_2' => 'Test Road 120',
                    'city' => 'Test City',
                    'company_name' => 'webshipr Aps',
                    'contact_name' => 'mathias',
                    'country_code' => 'DK',
                    'email' => 'info@webshipr.com',
                    'phone' => '66666666',
                    'phone_area' => '+45',
                    'zip' => '8230',
                ],
            'delivery_address' =>
                [
                    'address_1' => 'Test Road 66',
                    'address_2' => 'Test Road 120',
                    'city' => 'Test City',
                    'company_name' => 'webshipr Aps',
                    'contact_name' => 'mathias',
                    'country_code' => 'DK',
                    'email' => 'info@webshipr.com',
                    'phone' => '66666666',
                    'phone_area' => '+45',
                    'zip' => '8230',
                ],
            'dynamic_address' =>
                [
                    'address_1' => 'GLS Pakkeshop XX',
                    'address_2' => '',
                    'city' => 'Åbyhøj',
                    'company_name' => 'GLS Pakkeshop XX',
                    'contact_name' => '',
                    'country_code' => 'DK',
                    'email' => 'info@webshipr.com',
                    'phone' => '',
                    'phone_area' => '',
                    'zip' => '8230',
                ],
            'custom_pickup_identifier' => '341',
            'items' =>
                [
                    [
                        'description' => 'Testdesc1',
                        'product_name' => 'TestName1',
                        'product_no' => 12,
                        'quantity' => 45,
                        'uom' => 'pcs',
                        'weight' => 500,
                        'location' => 'EP432S2',
                        'sub_total_price' => 50,
                        'total_price' => 60,
                        'currency' => 'EUR',
                        'tarif_number' => '1234',
                        'origin_country_code' => 'NO',
                        'ext_ref' => 'myitemref1',
                    ],
                    [
                        'description' => 'Testdesc1',
                        'product_name' => 'TestName1',
                        'product_no' => 12,
                        'quantity' => 45,
                        'uom' => 'pcs',
                        'weight' => 500,
                        'location' => 'EP432S2',
                        'sub_total_price' => 50,
                        'total_price' => 60,
                        'currency' => 'EUR',
                        'tarif_number' => '1234',
                        'origin_country_code' => 'NO',
                        'ext_ref' => 'myitemref2',
                    ],
                ],
            'webshop_id' => 3752,
            'ext_ref' => '00929812',
            'shipping_rate_id' => 983,
            'user_id' => 123,
            'comment' => 'Sample Comment',
        ]
)

更新订单是通过以下代码完成的

$this->api->orders->update($id, $data)

更新中的 $data 与创建中相同

查找订单是通过以下代码完成的

$this->api->orders-find($id)

删除订单是通过以下代码完成的

$this->api->orders-delete($id)

laravel-webshipper v2