Resolve Cart
curl --request POST \
--url https://api.centralcart.io/v1/webstore/cart \
--header 'Content-Type: application/json' \
--header 'x-store-domain: <x-store-domain>' \
--data '
{
"items": [
{
"id": 1,
"quantity": 2
},
{
"id": 7,
"quantity": 1,
"is_upsell": true,
"upsell_trigger_id": 1
}
]
}
'import requests
url = "https://api.centralcart.io/v1/webstore/cart"
payload = { "items": [
{
"id": 1,
"quantity": 2
},
{
"id": 7,
"quantity": 1,
"is_upsell": True,
"upsell_trigger_id": 1
}
] }
headers = {
"x-store-domain": "<x-store-domain>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-store-domain': '<x-store-domain>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{id: 1, quantity: 2},
{id: 7, quantity: 1, is_upsell: true, upsell_trigger_id: 1}
]
})
};
fetch('https://api.centralcart.io/v1/webstore/cart', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.centralcart.io/v1/webstore/cart",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'id' => 1,
'quantity' => 2
],
[
'id' => 7,
'quantity' => 1,
'is_upsell' => true,
'upsell_trigger_id' => 1
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-store-domain: <x-store-domain>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.centralcart.io/v1/webstore/cart"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": 1,\n \"quantity\": 2\n },\n {\n \"id\": 7,\n \"quantity\": 1,\n \"is_upsell\": true,\n \"upsell_trigger_id\": 1\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-store-domain", "<x-store-domain>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.centralcart.io/v1/webstore/cart")
.header("x-store-domain", "<x-store-domain>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"id\": 1,\n \"quantity\": 2\n },\n {\n \"id\": 7,\n \"quantity\": 1,\n \"is_upsell\": true,\n \"upsell_trigger_id\": 1\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.centralcart.io/v1/webstore/cart")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-store-domain"] = '<x-store-domain>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"id\": 1,\n \"quantity\": 2\n },\n {\n \"id\": 7,\n \"quantity\": 1,\n \"is_upsell\": true,\n \"upsell_trigger_id\": 1\n }\n ]\n}"
response = http.request(request)
puts response.read_body[
{
"id": 1,
"name": "VIP Inicial",
"slug": "vip-inicial",
"pricing": {
"price": 10,
"compare_at": 20,
"percent_discount": -50
},
"stock": {
"quantity": 100,
"available": true,
"min_amount": 1
}
},
{
"id": 7,
"name": "Chave Bônus",
"slug": "chave-bonus",
"is_upsell": true,
"upsell_trigger_id": 1,
"pricing": {
"price": 5,
"compare_at": 15,
"percent_discount": -66.67
},
"stock": {
"quantity": null,
"available": true,
"min_amount": 1
}
}
]{
"errors": [
{
"message": "Store not found."
}
]
}Checkout
Resolve Cart
Recebe os IDs dos itens do carrinho e devolve os produtos com o preço resolvido no servidor.
O carrinho vive no navegador, então o preço guardado lá não é confiável. Exiba o total sempre com base nesta resposta, e guarde apenas IDs e quantidades no seu front.
Para itens marcados como upsell, o preço de oferta é reavaliado contra a regra e o gatilho. Se a oferta não valer para aquele carrinho, o preço cheio prevalece. O
POST /webstore/checkout refaz essa mesma conta por conta própria.POST
/
webstore
/
cart
Resolve Cart
curl --request POST \
--url https://api.centralcart.io/v1/webstore/cart \
--header 'Content-Type: application/json' \
--header 'x-store-domain: <x-store-domain>' \
--data '
{
"items": [
{
"id": 1,
"quantity": 2
},
{
"id": 7,
"quantity": 1,
"is_upsell": true,
"upsell_trigger_id": 1
}
]
}
'import requests
url = "https://api.centralcart.io/v1/webstore/cart"
payload = { "items": [
{
"id": 1,
"quantity": 2
},
{
"id": 7,
"quantity": 1,
"is_upsell": True,
"upsell_trigger_id": 1
}
] }
headers = {
"x-store-domain": "<x-store-domain>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-store-domain': '<x-store-domain>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{id: 1, quantity: 2},
{id: 7, quantity: 1, is_upsell: true, upsell_trigger_id: 1}
]
})
};
fetch('https://api.centralcart.io/v1/webstore/cart', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.centralcart.io/v1/webstore/cart",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'id' => 1,
'quantity' => 2
],
[
'id' => 7,
'quantity' => 1,
'is_upsell' => true,
'upsell_trigger_id' => 1
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-store-domain: <x-store-domain>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.centralcart.io/v1/webstore/cart"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": 1,\n \"quantity\": 2\n },\n {\n \"id\": 7,\n \"quantity\": 1,\n \"is_upsell\": true,\n \"upsell_trigger_id\": 1\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-store-domain", "<x-store-domain>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.centralcart.io/v1/webstore/cart")
.header("x-store-domain", "<x-store-domain>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"id\": 1,\n \"quantity\": 2\n },\n {\n \"id\": 7,\n \"quantity\": 1,\n \"is_upsell\": true,\n \"upsell_trigger_id\": 1\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.centralcart.io/v1/webstore/cart")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-store-domain"] = '<x-store-domain>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"id\": 1,\n \"quantity\": 2\n },\n {\n \"id\": 7,\n \"quantity\": 1,\n \"is_upsell\": true,\n \"upsell_trigger_id\": 1\n }\n ]\n}"
response = http.request(request)
puts response.read_body[
{
"id": 1,
"name": "VIP Inicial",
"slug": "vip-inicial",
"pricing": {
"price": 10,
"compare_at": 20,
"percent_discount": -50
},
"stock": {
"quantity": 100,
"available": true,
"min_amount": 1
}
},
{
"id": 7,
"name": "Chave Bônus",
"slug": "chave-bonus",
"is_upsell": true,
"upsell_trigger_id": 1,
"pricing": {
"price": 5,
"compare_at": 15,
"percent_discount": -66.67
},
"stock": {
"quantity": null,
"available": true,
"min_amount": 1
}
}
]{
"errors": [
{
"message": "Store not found."
}
]
}Cabeçalhos
Domínio da sua loja (ex: sualoja.centralcart.ai)
Corpo
application/json
Show child attributes
Show child attributes
⌘I