定制 ray-nl/sendcloud-for-simple-commerce 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-09-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固