Closed nathannerdymind closed 3 years ago
We saw this same issue. We were able to put a temporary fix in place (see https://github.com/FosterCommerce/shipstation-connect/issues/19 for the fix for updating the services/Xml.php
to hardcode the country code to US). We have not yet identified what is causing the issue as our site only allows orders for the US and we have not found any order data that is incorrect.
Hey @nathannerdymind and @andrewcgregory, thanks for pointing this out. Somehow it slipped by our radar. We'll review and get back to you.
@nathannerdymind @andrewcgregory could you show us what an order with test data looks like which causes this error? Specifically the billing address and the shipping address.
@johnnynotsolucky I'm actually not sure what order is causing the issue. When it first showed up there was a large number of new orders in this store. We had checked through the order data and were not able to find any that stood out with abnormal billing or shipping info. Any recommendations on a way to find what order is actually triggering the issue?
@johnnynotsolucky We have the same temporary fix in place #19 . It was on every order with test shipping address info like: Shipping Address Nerdy Mind Testing street 80521 Fort Collins United States Colorado 0000000000
I've created a branch to try help debug.
If you could install the bugfix/address
branch of the plugin and run the export again on your test install that would be great!
composer require fostercommerce/shipstationconnect:dev-bugfix/address
When there's an error it'll just spit out a JSON object with the order ID and its shipping and billing info. The address data should include the countryIso
property.
@johnnynotsolucky I tried this on our staging environment.
Here are the steps/results:
composer require fostercommerce/shipstationconnect:dev-bugfix/country
, but I think that was your intention). Here is a screenshot of the error from within ShipStation:
Just to be clear, the error we receive (with this test and previously) is in ShipStation itself, not within Craft.
Apologies @andrewcgregory, I thought you were testing the export locally by calling the endpoint directly. On your staging environment the error log should be available in your logs.
You can search for "Error processing action": https://github.com/FosterCommerce/shipstation-connect/blob/b618ac7e370f0780802085c181f2450d1e37449f/src/controllers/OrdersController.php#L82
Just to be clear, the error we receive (with this test and previously) is in ShipStation itself, not within Craft.
Got it. It seems that for some reason the country ISO isn't being sent to ShipStation from the plugin. I'm not sure why that is, and I'm hoping the log data will point us in the right direction to resolve this.
@johnnynotsolucky No problem. I pulled the logs and was able to find this error. I don't want to share all of the logs here, but I cleared out the personal info and I'll share what I can below. I can send you a link to full copy through an email or DM if you're in the Craft Discord channel if needed.
Partial log: error-log.txt
Address looks fine in the control panel:
I did some more digging into the actual database tables today and it looks like we had one old customer that somehow did have addresses with a countryId = null
and when they placed a recent order that pulled in this address it caused the syncing issue. We were able to get this address updated to include the country as it should have previously, and everything appears to be working correctly.
Thank you for the logs @andrewcgregory. @nathannerdymind were you able to confirm whether the country is not set on some orders?
You can use this query to see which orders don't have a country set in either shipping or billing address:
SELECT
orders.id
FROM commerce_orders orders
JOIN commerce_addresses shippingAddresses ON orders.shippingAddressId = shippingAddresses.id
JOIN commerce_addresses billingAddresses ON orders.billingAddressId = billingAddresses.id
WHERE (
shippingAddresses.countryId IS NULL
OR billingAddresses.countryId IS NULL
)
;
We have an internal task to overhaul the code which validates orders and generates the XML for ShipStation. Part of that work would be to include better validation on the data so that these errors can be caught and easily resolved without much hassle.
Closing for inactivity. @nathannerdymind, feel free to reopen if you are still experiencing this issue after checking that you don’t have any order where countryId = null
.
We are getting this same error, but in our case it is happening with orders that don't have an address at all.
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