Open-source hands-on guide to build real production ready cart-service using commercetools platform
ENV=dev0x yarn build
If build is packaged:
ENV=dev0x yarn deploy-package
Deploy entirely:
ENV=dev0x yarn deploy
To specify custom profile:
ENV=dev0x PROFILE=local yarn deploy
To specify another region
ENV=dev0x PROFILE=local REGION=us-west-2 yarn deploy
Replace {host}
, {env}
, {api-key}
, {cart-id}
with appropriate values
curl --location --request POST 'https://{host}/{env}/carts' \
--header 'x-api-key: {api-key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"currency": "USD",
"items": [{
"sku": "sku-123",
"quantity": 1
}]
}'
curl --location --request PATCH 'https://{host}/{env}/carts/{cart-id}/lineitems' \
--header 'x-api-key: {api-key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"items": [{
"sku": "sku-123",
"quantity": 4
}]
}'
curl --location --request POST 'https://{host}/{env}/carts/{cart-id}/discountcodes' \
--header 'x-api-key: {api-key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"discountCode": "discount123"
}'
curl --location --request POST 'https://{host}/{env}/carts/{cart-id}/shippingaddress' \
--header 'x-api-key: {api-key}' \
--header 'Content-Type: application/json' \
--data-raw '{
address" : {
"id" : "exampleAddress",
"key" : "exampleKey",
"firstName" : "Example",
"lastName" : "Person",
"streetName" : "Examplary Street",
"postalCode" : "80933",
"city" : "Exemplary City",
"region" : "Exemplary Region",
"state" : "Exemplary State",
"country" : "DE",
"building" : "Hightower 1",
"apartment" : "247",
"phone" : "+49 89 12345678",
"mobile" : "+49 171 2345678",
"email" : "[email protected]"
}
}'
curl --location --request POST 'https://{host}/{env}/carts/{cart-id}/shippingmethod' \
--header 'x-api-key: {api-key}' \
--header 'Content-Type: application/json' \
--data-raw '{
shippingMethodId" : "sm123"
}'
curl --location --request POST 'https://{host}/{env}/carts/{cart-id}/paymentmethod' \
--header 'x-api-key: {api-key}' \
--header 'Content-Type: application/json' \
--data-raw '{
paymentMethodId" : "pm123"
}'