Code Monkey home page Code Monkey logo

shipstation-connect's Introduction

Header

ShipStation Connect for Craft CMS 4 and Commerce 4

A plugin for Craft Commerce that integrates with a ShipStation Custom Store.

Requirements

This plugin requires Craft CMS 4 and Commerce 4 or later

Installation

Install ShipStation Connect from the Plugin Store or with Composer

From the Plugin Store

Go to the Plugin Store in your project’s Control Panel and search for “ShipStation Connect.” Click on the “Install” button in its modal window.

With Composer

Open your terminal (command line) and run the following commands:

# go to the project directory
cd /path/to/my-project

# tell Composer to load the plugin
composer require fostercommerce/shipstationconnect

# tell Craft to install the plugin
./craft install/plugin shipstationconnect

After installing, go to the Craft control panel plugin settings page to configure the settings for the plugin.

Custom Store Configuration

Configure your connection in ShipStation following these instructions: ShipStation "Custom Store" integration.

Connect Your Craft Store to ShipStation

The "URL to Custom XML Page" is shown in the ShipStation Connect settings view in Craft.

Username/Password

ShipStation allows you to set a custom username and password combination for a connected store. This combination should match the values stored in the ShipStation Connnect settings view in your Craft control panel.

Note: These are not your ShipStation credentials, nor your Craft user credentials.

As of version 1.2.4, these values can be set with environment variables. Username/Password variables

Using Craft's Basic Authentication

As of Craft 3.5.0 basic authentication headers can be used to authenticate users in Craft by setting the enableBasicHttpAuth config setting to true.

If basic authentication is enabled for your site, ShipStation Connect will assume that requests to it have already been authenticated and continue processing. Using this feature removes the requirement to set a username/password in the settings and instead it is recommended to create a dedicated user with the shipstationconnect-processOrders permission for accessing ShipStation Connect.

When enableBasicHttpAuth is false, the plugin will read the auth header and validate against the username/password configured in ShipStation Connect's settings.

Debugging Apache Authentication Errors

The remote server returned an error

If you are seeing a 400 error (401 or 404 notably) and you're running on Apache. Try adding the following to your apache config.

CGIPassAuth On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

Order Statuses

Ensure your shipping statuses in Craft Commerce and ShipStation match. You edit each platform to use custom statuses and ShipStation can match multiple Craft statuses to a single ShipStation status, when needed.

Commerce Integration

Matrix Field

ShipStation Connect requires a Matrix Field for storing shipping information.

The matrix field should have a block type with text fields for the following:

  • Carrier
  • Service
  • Tracking Number

Matrix Field configuration

In the ShipStation Connnect settings, select the matrix field, and enter the handles for the block type and text fields. Shipping Info Matrix Field

When a shipping notification is received for an order from ShipStation, the plugin will add the shipping information to the Shipping Information field on the order and set the order to the Craft status paired with your ShipStation stores Shipped status.

Adding phone numbers to addresses sent to Shipstation

Addresses are now part of Craft rather than Commerce, and the Phone number field was dropped from the address model. It is now necessary to add a custom field to the Address fields to store phone numbers.

The plugin setting gives you the option to set the field handle that you are using for phone numbers. The contents of this field will then be sent to Shipstation within the address portions of the order data.

Custom Fields

You can customize the data that is sent to ShipStation by listening to the OrderFieldEvent event in a custom module or plugin, and set the values that you want per field, like in the following example:

use yii\base\Event;
use fostercommerce\shipstationconnect\services\Xml;
use fostercommerce\shipstationconnect\events\OrderFieldEvent;

Event::on(
    Xml::class,
    Xml::ORDER_FIELD_EVENT,
    function (OrderFieldEvent $e) {
        $fieldName = $e->field;
        $order = $e->order;

        if ($fieldName === OrderFieldEvent::FIELD_ORDER_NUMBER) {
            // Set ShipStation's order number to the order ID, instead of the default reference number
            $e->value = $order->id;
        } elseif ($fieldName === OrderFieldEvent::FIELD_CUSTOM_FIELD_1) {
            // Store the reference number in a custom field
            $e->value = 'Order Reference: ' . $order->reference;
        }
    }
);

OrderFieldEvent properties:

  • field - The custom field name, one of the following:
    PHP Constant Value
    OrderFieldEvent::FIELD_ORDER_NUMBER 'OrderNumber'
    OrderFieldEvent::FIELD_SHIPPING_METHOD 'ShippingMethod'
    OrderFieldEvent::FIELD_CUSTOM_FIELD_1 'CustomField1'
    OrderFieldEvent::FIELD_CUSTOM_FIELD_2 'CustomField2'
    OrderFieldEvent::FIELD_CUSTOM_FIELD_3 'CustomField3'
    OrderFieldEvent::FIELD_INTERNAL_NOTES 'InternalNotes'
    OrderFieldEvent::FIELD_CUSTOMER_NOTES 'CustomerNotes'
    OrderFieldEvent::FIELD_GIFT 'Gift'
    OrderFieldEvent::FIELD_GIFT_MESSAGE 'GiftMessage'
  • order - Current order data.
  • value - The data to set on this field.
  • cdata - Whether or not to wrap the value in a CDATA block.

If you've changed the OrderFieldEvent::FIELD_ORDER_NUMBER field to be anything other than the order's reference number, you'll need to listen to the OrdersController::FIND_ORDER_EVENT to use your own query to fetch the order. In the example above, we're changing it to be the order's ID, so we would need to fetch the order by ID:

use yii\base\Event;
use fostercommerce\shipstationconnect\controllers\OrdersController;
use fostercommerce\shipstationconnect\events\FindOrderEvent;

Event::on(
    OrdersController::class,
    OrdersController::FIND_ORDER_EVENT,
    function (FindOrderEvent $e) {
        $order = Order::find()->id($e->orderNumber)->one();

        if ($order) {
            $e->order = $order;
        }
    }
);

FindOrderEvent properties:

  • orderNumber - The order number sent by ShipStation.
  • order - The order that will be updated with shipping information.

shipstation-connect's People

Contributors

bakusedu avatar benface avatar cimocimocimo avatar johnnynotsolucky avatar michaelramuta avatar peteeveleigh avatar sjcallender avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shipstation-connect's Issues

Errors when syncing orders without Country Code

Hi y'all. After updating to version 1.3.2 of the plugin we're now seeing errors in the XML feed when syncing orders in ShipStation.

The issue seems to be related to the fact that we're passing orders to ShipStation that don't have any address info associated with them (our client pivoted to a curbside pickup model when COVID hit).

Obviously these curbside pickup orders don't need to be passed to ShipStation to begin with, but as far as I can tell there isn't a way to configure the plugin to send some orders to ShipStation, but not others. If that's possible and I'm missing something, let me know.

Here's the specific error we're seeing (that sounds similar to what's happening in #18):

An error occurred attempting to update orders: Error in XML. Reason: The 'Country' element is invalid - The value '' is invalid according to its datatype 'StringExactly2' - The actual length is less than the MinLength value.

I was able to temporarily get things back up and running by editing line 443 of the services/Xml.php file to be:

return $address->countryId ? $address->getCountry()->iso : 'US';

Obviously not a long term fix, but perhaps there's a way to pass along a default in the ternary operator that doesn't cause the feed to break.

If there's any other info I can pass along that'd be helpful let me know. And thanks in advance!

System Info

  • PHP 7.2.31
  • Craft 3.4.22.1
  • Craft Commerce 2.2.20
  • ShipStation Connect 1.3.2

Question: Shipping Providers/Prices

Will this plugin actually pass available shipping provider options/costs from ShipStation to the customer during checkout, or do I have to maintain those options manually in Craft Commerce? Wasn't seeing this anywhere in the features or documentation.

Orders do not import properly when 'Billing address same as shipping address' disabled.

Currently, orders do not import if the setting 'Billing address same as shipping address' is disabled and the order does not have a billing address.

The problem is in /services/xml.php in the shouldInclude() method (line 19) when building the orders xml object.

I assumed that disabling this setting would simply leave the billing info empty, but instead it excludes the order from the orders xml. Off the top of my head, I don't know if 'billing address' is required by ShipStation or not. If not, then this should be fixed. If billing address is required, then the plugin is behaving properly, but I would recommend adding a warning in the setting description that 'Orders that do not have billing address will not be imported'.

Thanks.

Unable to process orders from anonymous customers

We setup ShipStation with our Craft Commerce site. It was working great for several days. Then it started returning 500 errors. I confirmed there were not blocking issues from our server and re-entered the ShipStation custom store username and password in Craft. When I use "Test Connection" in ShipStation it is successful. But if I try to Connect to the store it says "Failed to Update". Here is what the logs say:

2020-05-04 08:37:35 [-][-][-][error][fostercommerce\shipstationconnect\controllers\OrdersController::logException] Error processing action export
2020-05-04 08:37:35 [-][-][-][error][yii\base\ErrorException:8] yii\base\ErrorException: Trying to get property 'firstName' of non-object in /home/wallpaper/craft3/vendor/fostercommerce/shipstationconnect/src/services/Xml.php:392
Stack trace:
#0 /home/wallpaper/craft3/vendor/craftcms/cms/src/web/ErrorHandler.php(74): yii\base\ErrorHandler->handleError(8, 'Trying to get p...', '/home/wallpaper...', 392)
#1 /home/wallpaper/craft3/vendor/fostercommerce/shipstationconnect/src/services/Xml.php(392): craft\web\ErrorHandler->handleError(8, 'Trying to get p...', '/home/wallpaper...', 392, Array)
#2 /home/wallpaper/craft3/vendor/fostercommerce/shipstationconnect/src/services/Xml.php(126): fostercommerce\shipstationconnect\services\Xml->shipTo(Object(SimpleXMLElement), Object(craft\commerce\elements\Order), Object(craft\commerce\models\Customer))
#3 /home/wallpaper/craft3/vendor/fostercommerce/shipstationconnect/src/services/Xml.php(39): fostercommerce\shipstationconnect\services\Xml->order(Object(SimpleXMLElement), Object(craft\commerce\elements\Order))

PHP Fatal error:  require(): Failed opening required '/home/user/craft3/vendor/composer/../league/csv/src/functions_include.php' (include_path='.:/opt/cpanel/ea-php73/root/usr/share/pear') in /home/user/craft3/vendor/composer/autoload_real.php on line 66

Getting 403 connecting to Custom Store on Laravel Forge

  • I've tried my luck with Shipstation support but they're insisting I'm doing it wrong.
  • Clicking the Test Connection button works, but 'Connect' returns 'Request failed with status code 403'
  • A curl with basic auth works fine.
  • Ive set up Shipping statuses and Matrix field.

As Laravel Forge runs Nginx I wonder if it's not passing the auth, so tried adding this to location in nginx conf but to no effect:

proxy_set_header Authorization $http_authorization;
proxy_pass_header  Authorization;

Orders recalculated after Shipstation update?

We have noticed that when we mark an order as shipped in Shipstation and it syncs back to Commerce, if any products in the order are no longer "available for purchase", Commerce removes these products from the order, shows "products unavailable" order notices, and marks the order as "overpaid". The order in Shipstation however still has the correct order contents.

I am not 100% it is the plugin, but it aligns with the action described above - the order is fine before that. The above can only happen if the order is recalculated rather than just updated. Could the plugin be doing this?

We will keep digging and update with more information as we have it.

screenshot_460

?action=export not returning all orders

Hello,

I'm following the instructions from here #39 to deal with addresses with no country that ShipStation is rejecting. I created a store called standard, which only contains orders with legit addresses. I'd like to view the output and I'm fetching orders via curl.

From this #36 (comment) I should be getting all orders, but I'm only getting 25 orders. Is there some parameter I'm missing to get all?

Thank you,

aeu

curl \
--silent \
--request GET 'https://my.domain.com/actions/shipstationconnect/orders/process?store=standard&action=export' \
--header 'Authorization: Basic 9s7df987sdf98adfklasklfjkalsdf='


./production_shipstation_curl.sh | tidy -xml -iq | grep OrderID | wc
line 2 column 29459 - Warning: replacing invalid character code 133
line 2 column 29870 - Warning: replacing invalid character code 133
      25      25     725

Invalid Discount price when >= $1000

Just received the following from Shipstation:

I understand you are running into an import error message:
An error occurred attempting to update orders: Error in XML. Reason: The 'UnitPrice' element is invalid - The value '-1,178.65' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:float' - The string '-1,178.65' is not a valid Single value.

We are receiving this error because the unit price for one of your products is invalid. I pulled the order feed for your custom store and found the product causing this issue:

1 -1,178.65

FR: ability to set phone for addresses

Since upgrading to Commerce 4, phone numbers are no longer automatically mapped for addresses since they were removed from the Address model. Would be nice to add a feature to set phone numbers again, either through a plugin setting allowing admins to set the field handle for phone numbers or through an OrderFieldEvent.

Shipping Method Name

I'm wondering if it would make sense to use the shipping method name instead of its handle when sent to ShipStation. The Craft 2 ShipStation plugin had a hook that allowed plugins to override the text sent to ShipStation, but since hooks have mostly been done away with in Craft 3, I don't think this is possible. As far as I can tell, the shipping method is only used by ShipStation to display what method was requested when preparing a shipment. In that case, would it make sense to use a more human readable format and send $shippingMethod->name instead?

getShippingMethod causes ErrorException

Client tried pulling an order today.

This appeared in SS:

An error occurred attempting to update orders: Invalid XML. Error: 'Data at the root level is invalid. Line 1, position 1.' We received: '{"error":"ErrorException"}'

Error with missing Country

I am getting the error on ShipStation:
An error occurred attempting to update orders: Error in XML. Reason: The 'Country' element is invalid - The value '' is invalid according to its datatype 'StringExactly2' - The actual length is less than the MinLength value.

I checked the shipping address on Craft Commerce orders and we have the country default to United States with the ISO set to US. I tried a few different options but nothing seems to work. Let me know if there is another custom setting that I need to do in order for this to work.

ShipStation Connect - 1.3.5
Craft Commerce - 3.2.3
Craft - 3.5.7

Error with orders that have no address

11/29/2021 04:47 :
An error occurred attempting to update orders: Error in XML. Reason: The 'Country' element is invalid - The value '' is invalid according to its datatype 'StringExactly2' - The actual length is less than the MinLength value.

We have orders in our system which don't have addresses but they are being sent to ShipStation which is rejecting them. The problem is that from that point onward, ShipStation stops processing and no subsequent orders are being sent.

We need a way to mark orders to not be sent to ShipStation (ref: #38)

Does XML Pagination Affect Import?

Hello.

Sometimes, orders do not get imported into ShipStation, although they are in the XML way at the end of 376 pages.
Sometimes they do, though. And I'm trying to determine why.

Would this 376 page length have an effect on the ShipStation import connection?

Why are 'shipped' orders in this XML?

Would it not make more sense to present orders from last to first?

The remote server returned an error: (404)

I'm always getting 404 errors when connecting or updating from ShipStation. When I check the server logs it's accessing the correct URLs. It's not liking the authentication for some reason.

Is there any particulars that need configuring on the server to work?

Push historic orders to shipstation

I have an issue where my commerce store was disconnected from shipstation for a few days. Is there a way to push the orders that came through during that time to shipstation?

Testing 'Custom XML Page URL' gets error

Unsure if this is related to #11, but the client had reported a 500 error when trying to import the orders from Craft. On testing this endpoint -
https://website.com/actions/shipstationconnect/orders/process?action=export

I get the following response:
{"error":"DOMDocument::createCDATASection() expects parameter 1 to be string, array given"}

I then wondered if I needed to manually set the store name in the url, but then testing
https://website.com/actions/shipstationconnect/orders/process?store=default&action=export

gets the following response:
{"error":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_' in 'where clause'\nThe SQL being executed was: SELECT COUNT(*)\nFROM (SELECT `elements`.`id` AS `elementsId`, `elements_sites`.`id` AS `elementsSitesId`, `content`.`id` AS `contentId`\nFROM `elements` `elements`\nINNER JOIN `commerce_orders` `commerce_orders` ON `commerce_orders`.`id` = `elements`.`id`\nINNER JOIN `elements_sites` `elements_sites` ON `elements_sites`.`elementId` = `elements`.`id`\nINNER JOIN `content` `content` ON (`content`.`elementId` = `elements`.`id`) AND (`content`.`siteId` = `elements_sites`.`siteId`)\nWHERE (`commerce_orders`.`isCompleted`=TRUE) AND (`field_`='default') AND (`elements_sites`.`siteId`='1') AND (`elements`.`archived`=FALSE) AND (`elements`.`dateDeleted` IS NULL) AND (`elements_sites`.`enabled`=TRUE) AND (`elements`.`draftId` IS NULL) AND (`elements`.`revisionId` IS NULL)) `subquery`\nINNER JOIN `commerce_orders` `commerce_orders` ON `commerce_orders`.`id` = `subquery`.`elementsId`\nINNER JOIN `elements` `elements` ON `elements`.`id` = `subquery`.`elementsId`\nINNER JOIN `elements_sites` `elements_sites` ON `elements_sites`.`id` = `subquery`.`elementsSitesId`\nINNER JOIN `content` `content` ON `content`.`id` = subquery`.`contentId`"}

Internal server error saving plugin settings when allowAdminChanges is false

We're using this plugin on a site where we have (on production):

  • allowAdminChanges set to false
  • projectConfig enabled

The client has gone to add their Shipstation username & password in the plugin settings and found that it errored when they clicked save. From the logs, it looks like the error is caused by the Shipstation plugin trying to (unsuccessfully) write to the project config file (project.yaml). Would it be possible to instead save these plugin settings in the DB?

Craft 4?

Any news on an update for Craft 4?

Failing. XML is invalid. User fields hidden.

Hey, should we be concerned that ShipStation user and pass fields in the CP are invisible? (Using .env variables for these, yet still, these fields should show, yes?)

Also, this link appears to be broken.
.../actions/shipstationconnect/orders/process

Yields the error: "No action set. Set the ?action= parameter as export or shipnotify."

Meanwhile, orders are stacking up. What gives?

ShipStation Connect 1.3.6
Commerce Pro 3.42
Craft Pro 3.7.8

Processing Short Numbers Only?

Hey there, we have a situation with order numbers.

82fceda3cf3b9a66d2e2d61fea858c19
82fcedad331f3468434f819d9786457d

ShipStation Connect (I think) sees these as the same number and won't process the second one. How can we get ShipStation to process these seemingly duplicate numbers.

Weird, huh?

Store Errors

Was able to connect SS to the website. Grabbing orders though is still a problem.

Getting a 500 error "trying to get property of non-object" in Shipstation. Tracked it back to the getOrders() method (I added some lines to log the exceptions so the line numbers will be off by a couple)....

From the trace:

2018-09-14 15:36:50 [34.200.1.155][-][-][warning][fostercommerce\shipstationconnect\controllers\OrdersController::actionProcess] yii\base\ErrorException Object
(
    [message:protected] => Trying to get property of non-object
    [string:Exception:private] => 
    [code:protected] => 8
    [file:protected] => /home/client/site/plugins/shipstation/src/services/Xml.php
    [line:protected] => 72
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [file] => /home/client/site/vendor/craftcms/cms/src/web/ErrorHandler.php
                    [line] => 76
                    [function] => handleError
                    [class] => yii\base\ErrorHandler
                    [type] => ->
                    [args] => Array
                        (
                            [0] => 8
                            [1] => Trying to get property of non-object
                            [2] => /home/client/site/plugins/shipstation/src/services/Xml.php
                            [3] => 72
                        )

                )

            [1] => Array
                (
                    [file] => /home/client/site/plugins/shipstation/src/services/Xml.php
                    [line] => 72
                    [function] => handleError
                    [class] => craft\web\ErrorHandler
                    [type] => ->
                    [args] => Array
                        (
                            [0] => 8
                            [1] => Trying to get property of non-object
                            [2] => /home/client/site/plugins/shipstation/src/services/Xml.php
                            [3] => 72
                            [4] => Array
                                (
                                    [xml] => SimpleXMLElement Object
                                        (
                                            [@attributes] => Array
                                                (
                                                    [pages] => 1
                                                )

                                            [Order] => SimpleXMLElement Object
                                                (
                                                    [OrderID] => SimpleXMLElement Object
                                                        (
                                                        )

                                                    [OrderNumber] => SimpleXMLElement Object
                                                        (
                                                        )

                                                    [OrderStatus] => SimpleXMLElement Object
                                                        (
                                                        )

                                                    [OrderTotal] => 16.29
                                                    [TaxAmount] => 0.3
                                                    [ShippingAmount] => 9.99
                                                    [OrderDate] => 9/14/2018 14:09
                                                    [LastModified] => 9/14/2018 15:09
                                                    [ShippingMethod] => SimpleXMLElement Object
                                                        (
                                                        )

                                                )

                                        )

                                    [order] => craft\commerce\elements\Order Object
                                        (
                                            [id] => 935
                                            [number] => 1bfa8a238ea68a766ef78af4d0b09df9
                                            [couponCode] => 
                                            [isCompleted] => 1
                                            [dateOrdered] => DateTime Object
                                                (
                                                    [date] => 2018-09-14 14:23:50.000000
                                                    [timezone_type] => 3
                                                    [timezone] => America/Chicago
                                                )

                                            [datePaid] => DateTime Object
                                                (
                                                    [date] => 2018-09-14 14:23:50.000000
                                                    [timezone_type] => 3
                                                    [timezone] => America/Chicago
                                                )

                                            [currency] => USD
                                            [gatewayId] => 
                                            [lastIp] => 72.133.50.49
                                            [orderLanguage] => en-US
                                            [message] => 
                                            [returnUrl] => customer/order?number=1bfa8a238ea68a766ef78af4d0b09df9
                                            [cancelUrl] => /shop/checkout/payment
                                            [orderStatusId] => 2
                                            [billingAddressId] => 13
                                            [shippingAddressId] => 14
                                            [makePrimaryShippingAddress] => 
                                            [makePrimaryBillingAddress] => 
                                            [shippingSameAsBilling] => 
                                            [billingSameAsShipping] => 
                                            [shippingMethodHandle] => usps
                                            [customerId] => 1
                                            [_shippingAddress:craft\commerce\elements\Order:private] => craft\commerce\models\Address Object
                                                (
....

Orders not passing to Shipstation

I've followed the setup instructions that you have provided and also can confirm that the Custom Store connection is successful, but I cannot see any of my test orders being carried across into my ShipStation account.

I've checked the logs but cannot see any errors in there.

Orders have the Shipping Info matrix block included in them with the correct fields and I've matched up the order statuses and orders, so not sure what else I could be missing??!

Any help on this would be greatly appreciated.

Failed upgrade to Craft Commerce 3

Are there plans to update this plugin for commerce 3? I tried install it on a development site I'm working on and get the following error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for fostercommerce/shipstationconnect ^1.2 -> satisfiable by fostercommerce/shipstationconnect[1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.2.7].
    - Can only install one of: craftcms/commerce[v2.x-dev, 3.0.5].
    - Can only install one of: craftcms/commerce[v2.x-dev, 3.0.5].
    - Can only install one of: craftcms/commerce[v2.x-dev, 3.0.5].
    - Conclusion: install craftcms/commerce v2.x-dev
    - Installation request for craftcms/commerce (locked at 3.0.5, required as ^3.0.0) -> satisfiable by craftcms/commerce[3.0.5].

Craft fields don't seem to be created after install

Under the documentation it says -

ShipStation Connect will create a new Matrix field called "Shipping Info" under the "ShipStation Connect" Group. It will also automatically add a new tab to the Orders layout in Craft Commerce called "ShipStation Connect" which will include the Shipping Info field.

However, post-install I can't seem to see any fields that have been added to Craft.

Consider improving 'custom fields' documentation.

Please consider improving the documentation for custom fields. It took me quite awhile to figure out how to implement this. Below are some example improvements that I think would be very helpful.

To add custom fields to the data sent to ShipStation, you will need to add some event methods to your own custom business logic plugin (example below).

The custom fields are:
CustomField1: FIELD_CUSTOM_FIELD_1
CustomField2: FIELD_CUSTOM_FIELD_2
CustomField3: FIELD_CUSTOM_FIELD_3
InternalNotes: FIELD_INTERNAL_NOTES
CustomerNotes: FIELD_INTERNAL_NOTES
Gift: FIELD_GIFT
GiftMessage: FIELD_GIFT_MESSAGE

Additionally, you can override the default data sent to ShipStation, such as the order number, shipping method, etc.

Order Number: FIELD_ORDER_NUMBER
Shipping Method: FIELD_SHIPPING_METHOD

You might also consider adding a better example, which includes all of the custom fields (and any others that are commonly overwritten).

Your custom event listeners should be placed in your plugins init() function.

    Event::on(
        Xml::class,
        Xml::ORDER_FIELD_EVENT,
        function (OrderFieldEvent $e) {
            $fieldName = $e->field;
            $order = $e->order;
            
            // set shipstation xml custom field data
            if ($fieldName === OrderFieldEvent::FIELD_ORDER_NUMBER) {
                // ex. set shipstation order number to order id, instead of default short ref number
                $e->value = $order->id;
            } elseif ($fieldName === OrderFieldEvent::FIELD_SHIPPING_METHOD) {
                // do nothing, already set by properly by shipstation-connect
            } elseif ($fieldName === OrderFieldEvent::FIELD_CUSTOM_FIELD_1) {
                // ex. store ref number
                $e->value = "Order Ref: " . $order->getShortNumber();
                $e->cdata = true;
            } elseif ($fieldName === OrderFieldEvent::FIELD_CUSTOM_FIELD_2) {
                if ($order->getShippingMethod()->handle == "useYourOwnAccount") {
                    $e->value = "Cust Shipping Method: " . $order->getFieldValue('customerShippingMethod');
                    $e->cdata = true;
                } else {
                    $e->value = "";
                    $e->cdata = true;
                }
            } elseif ($fieldName === OrderFieldEvent::FIELD_CUSTOM_FIELD_3) {
                if ($order->getShippingMethod()->handle == "useYourOwnAccount") {
                    $e->value = "Cust Shipping Account: " . $order->getFieldValue('customerShippingAccount');
                    $e->cdata = true;
                } else {
                    $e->value = "";
                    $e->cdata = true;
                }
            } elseif ($fieldName === OrderFieldEvent::FIELD_INTERNAL_NOTES) {
                $e->value = "";
                $e->cdata = true;
            } elseif ($fieldName === OrderFieldEvent::FIELD_CUSTOMER_NOTES) {
                $e->value = $order->getFieldValue('customerComments');
                $e->cdata = true;
            } elseif ($fieldName === OrderFieldEvent::FIELD_GIFT) {
                $e->value = 0;
                $e->cdata = false;
            } elseif ($fieldName === OrderFieldEvent::FIELD_GIFT_MESSAGE) {
                $e->value = "";
                $e->cdata = true;
            } else {
                // do nothing
            }
        }
    );

Information about class references would also be helpful.

In addition, depending on what you are modifying, you may need to add some of the 'shipstationconnect' class references to your primary plugin class.

use fostercommerce\shipstationconnect\controllers\OrdersController;
use fostercommerce\shipstationconnect\services\Xml;
use fostercommerce\shipstationconnect\events\OrderFieldEvent;
use fostercommerce\shipstationconnect\events\FindOrderEvent;

Just a suggestion. Thanks.

Unable to get shipstation to update order in craft

I am currently struggling to get shipstation to talk back to craft, to add info into the matrix field, and change the order status.
My web.log shows the following error:

2020-11-02 05:40:14 [-][1][-][error][fostercommerce\shipstationconnect\controllers\OrdersController::logException] Error processing action shipnotify
2020-11-02 05:40:14 [-][1][-][error][yii\base\ErrorException:1] yii\base\ErrorException: Failed to find Commerce OrderStatus 'Shipped' in /home/forge/xxx.com/vendor/yiisoft/yii2/base/ErrorException.php:43
Stack trace:
#0 /home/forge/xxx.com/vendor/fostercommerce/shipstationconnect/src/controllers/OrdersController.php(64): fostercommerce\shipstationconnect\controllers\OrdersController->postShipment()
#1 [internal function]: fostercommerce\shipstationconnect\controllers\OrdersController->actionProcess(NULL, 'shipnotify')
#2 /home/forge/xxx.com/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#3 /home/forge/xxx.com/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#4 /home/forge/xxx.com/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('process', Array)
#5 /home/forge/xxx.com/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('process', Array)
#6 /home/forge/xxx.com/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('shipstationconn...', Array)
#7 /home/forge/xxx.com/vendor/craftcms/cms/src/web/Application.php(577): craft\web\Application->runAction('shipstationconn...', Array)
#8 /home/forge/xxx.com/vendor/craftcms/cms/src/web/Application.php(253): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#9 /home/forge/xxx.com/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#10 /home/forge/xxx.com/web/index.php(22): yii\base\Application->run()
#11 {main}

I don't have a Commerce OrderStatus 'shipped', but have the following setup which matches in Craft and Shipstation:
Screenshot 2020-11-11 at 10 59 00
Screenshot 2020-11-11 at 10 58 47

Finally I have added the matrix field to the Order Fields here https://xxx.com/admin/commerce/settings/ordersettings is this correct? It isn't 100% clear if you need to do this or not.

Thanks

Subscriptions sent to shipstation

Feature Requests: It would be amazing to have the ability to send subscriptions to shipstation to help with the fulfilment of subscription-based orders.

The "Name" element is invalid - greater than the MaxLength value

It appears ShipStation has a limit of 200 characters on "Name", but Craft does not, which will result in this error:

image

This is a Craft 2/Commerce upgrade, which may be why the names are longer (with variants?).

At any rate, seems like you should truncate to avoid this error?

Open Shipstation from Craft

One of our clients came from BigCommerce and is used to being able to use it within that Control Panel. I believe a Craft integration could be as simple as puling up ShipStation in an iFrame inside Craft. It would be super handy and convenient.

Or at least give SS a menu item and link it from within the sidebar inside Craft.

bigsup

Shipped Status for GLS

Craft isn't receiving the status of Shipped back from ShipStation when an order uses GLS as the carrier. It gets the status update from other carriers.

Is this something with ShipStation not passing that info? If so, any suggestions on this?

Shipstation Connect v 1.3.6

Exported orders should respect XML Schema for Validating Order Information

We had an issue with an order containing a value for the Company field that was too long.

This issue is with the export orders endpoint : actions/shipstationconnect/orders/process?action=export

According to the Shipstation documentation, this field has a maximum of 100 characters.

https://help.shipstation.com/hc/en-us/articles/360025856192-Custom-Store-Development-Guide#UUID-1bb7ab47-6cf4-c6cd-0e5b-dec61e91201b_UUID-738eed11-ec21-be53-efb4-5fadcdde7b0f

I think it would be interesting for the plugin to manage the value of the fields to respect the documentation.

Otherwise, we have no choice but to manage field value on our side.

Cant get orders to show up in ship station

  • Connection works in ship station
  • Fields are all setup in backend
  • No error in logs
  • Curl Request from #36 successfully reproduces an xml with orders
  • Resave the order to update the dateUpdated data

I'm not sure what I am missing and how to debug from here, sorry for being a dumb dumb.

Stringy Naming Collision

Just installed Craft 3.3 and was starting to test it when I ran into a naming collision issue with Stringy. Craft 3.3 switches from danielstjules/Stringy to voku/Stringy. This wouldn't be an issue except that Craft 3.3 now uses the snakeize() method (unique to voku) for the |snake twig filter. Because composer defaults to the old danielstjules/Stringy when generating autoload files, I now get a call to undefined method error when using the snake filter. Can you switch from the danielstjules version to the voku version to avoid this collision?

No shipping info coming through shipstation connect.

Hello!
Craft 4.5 site with newest craft commerce.
Using Postie for shipping rates, which is working well (orders are able to get real time shipping rates, and the orders show up with the correct shipping in craft. see below.)
image

None of that shipping info is coming into the order in shipstation, though- the service, package type, or anything else. When i ping the Shipstation Connect XML URL through postman, the ShippingMethod block is blank. Searching the XML output for the purchased shipping method (i.e. CTRL-F, "fedex") returns no results.

   <ShippingMethod>
        <![CDATA[]]>
    </ShippingMethod>

Is this behavior expected?

Exclude Adjustments from XML

Hey there. How much trouble would it be to exclude promotions from the line items in the XML that Shipstation consumes?

Or like, if it doesn't have an SKU don't include it in the payload?

These are appearing on labels and causing some confusion.

Thanks.

Unable to connect to the marketplace! Error: Invalid XML

Hi,

I'm trying to connect a marketplace in ShipStation, but when I try to test connection I get this error:

Store Configuration
{"Message":"Unable to connect to the marketplace! Error: Invalid XML. Error: 'Data at the root level is invalid. Line 1, position 1.' We received: '������Q(K-*��ϳU2�3P����/J\n)$���*(��qf�9*'"}

I selected 'Custom Store' and I'm using the custom XML page url as shown in the Settings screen: https://mysite.com/actions/shipstationconnect/orders/process

The username and password are correct (when using known-wrong credentials I get a relevant error.)

Would appreciate any help you can give!

error when refreshing feed from shipstation

Hi,

I'm getting this error when try to refresh the feed from shipstation:

Error processing action export
DOMDocument::createCDATASection() expects parameter 1 to be string, array given in /vendor/fostercommerce/shipstationconnect/src/services/Xml.php:500

is it possible to check if its an array and if it then json_encode it perhaps?

    protected function addChildWithCDATA(&$xml, $name, $value)
    {
        $new_child = $xml->addChild($name);
        if ($new_child !== null) {
            $node = dom_import_simplexml($new_child);
            $node->appendChild($node->ownerDocument->createCDATASection(json_encode($value));
        }
        return $new_child;
    }

Craft Pro 3.1.30
Commerce: 2.1.7

Add ability to override fields, such as title or quantity

We have a particular client that would like to be able to modify the title and quantity fields that are being sent to ShipStation, as we have custom business logic that modify those values. If that is possible, that would be amazing!

Thank you!

Confirm Craft 3.5/Commerce 3.2 compatibility

I've just upgraded a site and have had the client report that that "401 unauthorized when trying to use the URL for shipstation connect"

I haven't dug in yet, but wanted to start with an issue to see if this has been tested/confirmed on 3.5/3.2.

  • Craft CMS 3.5.8
  • Craft Commerce 3.2.3
  • ShipStation Connect: 1.3.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.