onedesign/oneshipstation
Composer 安装命令:
composer require onedesign/oneshipstation
包简介
A Craft CMS plugin for integrating Craft Commerce with ShipStation
关键字:
README 文档
README
Integrates Craft Commerce with ShipStation using the Custom Store Integration.
Installation
Note: This plugin is written for Craft 2.x. It may not work in Craft 3+.
Use composer to install this package:
composer require onedesign/oneshipstation
After installing with composer, go to the Craft control panel plugin page to install and configure the settings for the plugin.
Craft Configuration
CSRF Protection
If you have CSRF protection enabled in your app, you will need to disable it for when ShipStation POSTs shipment notifications.
In craft/config/general.php, if you have enableCsrfProtection set to true (or, in Craft 3+, if you don't have it set to false), you will need to add the following:
return array(
//...
'enableCsrfProtection' => !isset($_REQUEST['p']) || $_REQUEST['p'] != '/actions/oneShipStation/orders/process'
)
This will ensure that CSRF protection is enabled for all routes that are NOT the route ShipStation posts to.
"Action" naming collision
ShipStation and Craft have a routing collision due to their combined use of the parameter action.
ShipStation sends requests using ?action=export to read order data, and ?action=shipnotify to update shipping data.
This conflicts with Craft's reserved word action to describe an "action request",
which is designed to allow for easier routing configuration.
Because of this, the route given to ShipStation for their Custom Store integration must begin with your Craft config's "actionTrigger" (in craft/config/general.php), which defaults to the string "actions".
For example, if your actionTrigger is set to "actions", the URL you prove to ShipStation should be:
https://{yourdomain.com}/actions/oneShipStation/orders/process
If your actionTrigger is set to "myCustomActionTrigger", it would be:
https://{yourdomain.com}/myCustomActionTrigger/oneShipStation/orders/process
Note: the above URL is case sensitive! Due to Craft's segment matching, the oneShipStation segment in the URL must be oneShipStation, not oneshipstation or ONESHIPSTATION.
ShipStation Configuration
Order Statuses
When ShipStation marks an order as shipped it calls back to Craft to update the order. This plugin assumes that there is an order status defined in Craft Commerce with the handle "shipped".
Authentication
Once you have configured your Craft application's OneShipStation, you will need to complete the process by configuring your ShipStation "Custom Store" integration.
There, you will be required to provide a user name, password, and a URL that ShipStation will use to contact your application. These can be found in the plugin settings in Craft control panel.
Using OneShipStation in your Site Templates
Tracking Information
One ShipStation provides a helper method to add to your template to provide customers with a link to track their shipment.
{% for shipmentInfo in order.shippingInfo %}
{% set tracking = craft.oneShipStation.trackingNumberLinkHTML(shipmentInfo) %}
{% if tracking|length %}
Track shipment: {{ tracking|raw }}
{% endif %}
{% endfor %}
Hooks / Customizing
Custom Fields & Order Notes
Shipstation allows the adding extra data to orders. These fields appear in ShipStation as customField1, customField2, customField3, internalNotes, customerNotes, gift and giftMessage.
You can populate these fields by "latching on" to a Craft hook in your custom site plugin.
Your plugin should return a callback that takes a single parameter $order, which is the order instance. It should return a single value.
In this example, the plugin MyPlugin will send the value my custom value to all orders in the customField1 param to ShipStation:
class MyPlugin extends BasePlugin {
public function oneShipStationCustomField1() {
return function($order) {
return 'my custom value';
};
}
}
Note: OneShipStation will add a CustomFieldX child for each plugin that responds to the hook. So, to avoid overlap, be sure to only use one hook.
For internal notes, if a plugin responds to the hook at all, the key will be added. Respond as:
class MyPlugin extends BasePlugin {
public function oneShipStationInternalNotes() {
return function($order) {
return 'internal notes for this order';
};
}
}
Overriding Shipping Method
By default, One Shipstation will send the shipping method handle to Shipstation for the ShippingMethod on each order.
You can override this very much like you'd add a custom field or internal notes above. In your plugin, define a function oneShipStationShippingMethod(),
which returns a callback that takes an order and returns a string. For example, if you want the ShippingMethod to be called Ground for all customers in the US,
you could declare a method as follows:
class MyPlugin extends BasePlugin {
public function oneShipStationShippingMethod() {
return function($order) {
if ($order->getShippingAddress()->country == 'US') {
return 'Ground';
}
}
}
}
If you return null or void, OneShipstation will assign the shipping method to be the shipping method handle, as default.
Overriding Tracking URLs
Currently One ShipStation only provides links for common carriers. If your carrier is not defined, or if you want a different URL, you can override:
class MyPlugin extends BasePlugin {
public function oneShipStation_trackingURL($shippingInfo) {
return 'https://mycustomlink?tracking=' . urlencode($shippingInfo->trackingNumber);
}
}
Development
On any Craft 2.x project, navigate to craft/plugins and clone the repository:
$ cd craft/plugins
$ git clone git@github.com:onedesign/oneshipstation.git
Be sure to add craft/plugins/oneshipstation to your other project's gitignore, if applicable:
# .gitignore
craft/plugins/oneshipstation
Bugs / Issues
Submit bug reports and issues via https://github.com/onedesign/oneshipstation/issues. Please be as thorough as possible when submitting bug reports.
Contributing
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull request so that we can review your changes
NOTE: Be sure to merge the latest from "upstream" before making a pull request!
onedesign/oneshipstation 适用场景与选型建议
onedesign/oneshipstation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 246 次下载、GitHub Stars 达 4, 最近一次更新时间为 2018 年 02 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「Craft」 「shipstation」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 onedesign/oneshipstation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 onedesign/oneshipstation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 onedesign/oneshipstation 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Expand, collapse, change the status of, or delete multiple blocks in a Matrix field simultaneously.
A php wrapper for ShipStation's rest api
A php wrapper for ship station's rest api
GraphQL authentication for your headless Craft CMS applications.
A Craft CMS plugin for integrating Craft Commerce with ShipStation
统计信息
- 总下载量: 246
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-28