Skip to content

rmddx/shipstation-note-parser

Repository files navigation

ShipStation Note Parser

When orders are synced from Shopify to Shipstation,
order notes and order attributes are merged into a single field.

This unmerges them.

Uses Shipstation webhook to process orders as they are imported.
Parses order note and saves to "Note from Buyer".
Copies orignal note to "Custom Field 1".

Before:

Note From Buyer: Special Note 4 U<br\> internal-track-data: 123abc

After:

Note From Buyer: Special Note 4 U
Custom Field 1: Special Note 4 U<br\> internal-track-data: 123abc

Tech

  • Google Cloud Functions
  • Google Secret Manager
  • ShipStation Webhooks
  • ShipStation API

Prereqs

Setup

  1. Clone repo
  2. Generate ShipStation API key
  3. Create new Google Secret to store ShipStation API key (secret format: key:secret)
gcloud secrets create shipstation-key \
--replication-policy="automatic"

echo -n "KEY:SECRET" | \
gcloud secrets versions add secret-id --data-file=-
  1. Rename config.template.ini -> config.ini
  2. Update config.ini with project_id, secret_name, version
  3. Update config.ini with ShipStation base URL
  4. Deploy cloud function (replace PROJECT, REGION)
gcloud functions deploy shipstation-note-parser \
--gen2 \
--project PROJECT \
--region REGION \
--runtime php82 \
--trigger-http \
--entry-point run 
  1. Get Cloud Function URL (either cloudfunctions.net or run.app)
  2. Create ShipStation webhook (On New Orders) with Cloud Function URL.

Tests

composer test

Dev

Run Functions Framework
https://cloud.google.com/functions/docs/running/function-frameworks

composer start

Call function
(Use a service like https://webhook.site to capture webhook POST data to test with)

curl -X POST \
-H "Content-Type: application/json" \
-d '{"resource_url":"URL","resource_type":"ORDER_NOTIFY"}' \
http://localhost:8080

About

unmerges notes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages