2017 © Pedro Peláez
 

craft-plugin oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

image

onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  • Tuesday, July 24, 2018
  • by onedesign
  • Repository
  • 7 Watchers
  • 1 Stars
  • 157 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 35 Versions
  • 1021 % Grown

The README.md

One ShipStation

Integrates Craft Commerce with ShipStation using the Custom Store Integration., (*1)

Installation

Note: This plugin is written for Craft 2.x. It may not work in Craft 3+., (*2)

Use composer to install this package:, (*3)

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., (*4)

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., (*5)

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:, (*6)

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., (*7)

"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., (*8)

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"., (*9)

For example, if your actionTrigger is set to "actions", the URL you prove to ShipStation should be:, (*10)

https://{yourdomain.com}/actions/oneShipStation/orders/process

If your actionTrigger is set to "myCustomActionTrigger", it would be:, (*11)

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., (*12)

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"., (*13)

Authentication

Once you have configured your Craft application's OneShipStation, you will need to complete the process by configuring your ShipStation "Custom Store" integration., (*14)

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., (*15)

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., (*16)

{% 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., (*17)

You can populate these fields by "latching on" to a Craft hook in your custom site plugin., (*18)

Your plugin should return a callback that takes a single parameter $order, which is the order instance. It should return a single value., (*19)

In this example, the plugin MyPlugin will send the value my custom value to all orders in the customField1 param to ShipStation:, (*20)

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., (*21)

For internal notes, if a plugin responds to the hook at all, the key will be added. Respond as:, (*22)

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., (*23)

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:, (*24)

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., (*25)

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:, (*26)

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:, (*27)

$ 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:, (*28)

# .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., (*29)

Contributing

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. 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!, (*30)

The Versions

24/07 2018

dev-master

9999999-dev https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

plugin craft shipstation

24/07 2018

0.2.27

0.2.27.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

plugin craft shipstation

24/07 2018

dev-bugfix/100-char-limit

dev-bugfix/100-char-limit https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

plugin craft shipstation

28/02 2018

0.2.26

0.2.26.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

plugin craft shipstation

27/02 2018

0.2.25

0.2.25.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

09/11 2017

0.2.24

0.2.24.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

09/11 2017

dev-feature/weight-units

dev-feature/weight-units https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

07/09 2017

0.2.23

0.2.23.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

19/06 2017

0.2.22

0.2.22.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

30/05 2017

0.2.21

0.2.21.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

08/05 2017

0.2.20

0.2.20.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

08/05 2017

0.2.19

0.2.19.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

22/02 2017

0.2.18

0.2.18.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

02/11 2016

0.2.17

0.2.17.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

16/06 2016

0.2.16

0.2.16.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

15/06 2016

0.2.15

0.2.15.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

10/06 2016

0.2.14

0.2.14.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

09/06 2016

0.2.13

0.2.13.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

01/06 2016

0.2.12

0.2.12.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

05/05 2016

0.2.11

0.2.11.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

28/04 2016

0.2.10

0.2.10.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

28/04 2016

0.2.9

0.2.9.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

26/04 2016

0.2.8

0.2.8.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

22/04 2016

0.2.7

0.2.7.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

22/04 2016

0.2.6

0.2.6.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

20/04 2016

0.2.5

0.2.5.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

20/04 2016

0.2.4

0.2.4.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

07/04 2016

0.2.3

0.2.3.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

23/02 2016

0.2.2

0.2.2.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

16/02 2016

0.2.1

0.2.1.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

16/02 2016

dev-clean-up-default-billto-20160216-pc

dev-clean-up-default-billto-20160216-pc https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

16/02 2016

0.2

0.2.0.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

20/01 2016

0.1.1

0.1.1.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

19/01 2016

0.1.0

0.1.0.0 https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin craft

17/12 2015

dev-orders-controller-skeleton-with-routing-defined-20151217-pc

dev-orders-controller-skeleton-with-routing-defined-20151217-pc https://github.com/onedesign/oneshipstation

A Craft CMS plugin for integrating Craft Commerce with ShipStation

  Sources   Download

MIT

The Requires

 

plugin craft