ray-nl/sendcloud-for-simple-commerce
最新稳定版本:v1.0.0
Composer 安装命令:
composer require ray-nl/sendcloud-for-simple-commerce
包简介
README 文档
README
Add the possibility to create shipments with Sendcloud directly from Statamic with Simple Commerce. You can directly download the label and mark the order as shipped.
Get shipping methods
First you have to select the shipping methods to be used in your webshop from Sendcloud. Just run the following command to choose.
php artisan sendcloud:generate-shipping-methods
Add action to CP
If you want to create a label and marked an order as shipped add the following action to your application:
<?php namespace App\Actions; use DoubleThreeDigital\SimpleCommerce\Facades\Order; use Illuminate\Support\Facades\Storage; use RayNl\SendcloudForSimpleCommerce\Services\SendcloudService; use Statamic\Actions\Action; use Statamic\Contracts\Entries\Entry; class DownloadLabel extends Action { public function visibleTo($item) { if ($item instanceof Entry) { return $item->collection->handle === 'orders'; } return false; } public function visibleToBulk($items) { return false; } public function download($items, $values) { foreach ($items as $item) { $shippingMethod = new ($item->shipping_method->first())(); if ($shippingMethod->getSendCloudId() !== null) { if (!Storage::exists("labels/{$item->order_number}/label-{$item->order_number}.pdf")) { if ($item->sendcloud_id !== null) { $sendcloud = new SendcloudService(); $sendcloud->getParcelFromId($item->sendcloud_id); $sendcloud->createLabel($shippingMethod->getSendCloudId()); Storage::put('labels/' . $item->order_number . '/label-' . $item->order_number . '.pdf', $sendcloud->createLabelPdf()); } } Order::find($item->id)->markAsShipped(); return storage_path("app/labels/{$item->order_number}/label-{$item->order_number}.pdf"); } } } }
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2022-09-13