Calculate Cart
code examples curl request post \\ \ url https //app sparklayer io/api/v1/carts/{id}/calculate \\ \ header 'accept application/json' \\ \ header 'site id jones climbing'var myheaders = new headers(); myheaders append("accept", "application/json"); myheaders append("content type", "application/json"); myheaders append("site id", "jones climbing"); var requestoptions = { method 'post', headers myheaders, redirect 'follow' }; fetch("https //app sparklayer io/api/v1/carts/{id}/calculate", requestoptions) then(response => response text()) then(result => console log(result)) catch(error => console log('error', error));require "uri" require "json" require "net/http" url = uri("https //app sparklayer io/api/v1/carts/{id}/calculate") https = net http new(url host, url port) https use ssl = true request = net http post new(url) request\["accept"] = "application/json" request\["content type"] = "application/json" request\["site id"] = "jones climbing" response = https request(request) puts response read body import requests import json url = "https //app sparklayer io/api/v1/carts/{id}/calculate" payload = {} headers = { 'accept' 'application/json', 'content type' 'application/json', 'site id' 'jones climbing' } response = requests request("post", url, headers=headers, data=payload) print(response text) responses // successful response { "totals" { "total" { "pre discount" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" }, "discount" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" }, "charge" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" } }, "shipping" { "pre discount" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" }, "discount" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" }, "charge" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" } }, "sub total" { "pre discount" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" }, "discount" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" }, "charge" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" } } }, "discounts" \[ {} ], "shipping methods" \[ { "title" "", "description" "", "price v2" { "net" "", "gross" "", "tax rate" "", "currency code" "" }, "price v2 pre discount" {}, "handle" "", "cost type" "", "cost language string" "" } ], "allowed payment methods" { "payment by invoice" "", "payment on account" "", "upfront payment" "", "quote" "" }, "selected shipping rate handle" "", "selected payment method" "" }// cart not found // unprocessable entity {}// error response