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
gcloud
cli: https://cloud.google.com/sdk/gcloudkey:secret
)
gcloud secrets create shipstation-key \
--replication-policy="automatic"
echo -n "KEY:SECRET" | \ gcloud secrets versions add secret-id --data-file=-
4. Rename `config.template.ini` -> `config.ini`
5. Update `config.ini` with project_id, secret_name, version
6. Update `config.ini` with ShipStation base URL
7. Deploy cloud function (replace PROJECT, REGION)
```shell
gcloud functions deploy shipstation-note-parser \
--gen2 \
--project PROJECT \
--region REGION \
--runtime php82 \
--trigger-http \
--entry-point run
composer test
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