Update product variants
curl --request PATCH \
--url http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e \
--header 'Content-Type: application/json' \
--data '
{
"attributes": [
{
"name": {
"_id": "620230bd0d148855678615c3",
"name": "Color"
},
"options": [
{
"id": "633595a632a48354241eedee",
"label": "Color",
"name": "Space grey"
},
{
"id": "63359d60cfce8ece38311278",
"label": "Color",
"name": "Black"
}
]
}
],
"price": 21000000,
"sale_price": 19000000,
"typeAttributes": {
"packaging": {
"height": 115.24,
"length": 145.72,
"weight": 4500,
"width": 135.56
}
},
"variants": [
{
"_id": "63ec9527e29310243b665e9c",
"alwaysInStock": false,
"costPrice": null,
"dimension": {
"height": 7,
"length": 30,
"unit": "m",
"width": 50
},
"isActive": true,
"options": [
{
"id": "63359d60cfce8ece38311278",
"label": "Color",
"name": "Black"
}
],
"price": 3000000,
"sale_price": null,
"sku": "toyota-corolla-black-65e9b",
"stock": 15,
"weight": {
"base": {
"unit": null,
"value": null
},
"unit": "kg",
"value": 20000
}
}
],
"variantsInheritPrice": true
}
'import requests
url = "http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e"
payload = {
"attributes": [
{
"name": {
"_id": "620230bd0d148855678615c3",
"name": "Color"
},
"options": [
{
"id": "633595a632a48354241eedee",
"label": "Color",
"name": "Space grey"
},
{
"id": "63359d60cfce8ece38311278",
"label": "Color",
"name": "Black"
}
]
}
],
"price": 21000000,
"sale_price": 19000000,
"typeAttributes": { "packaging": {
"height": 115.24,
"length": 145.72,
"weight": 4500,
"width": 135.56
} },
"variants": [
{
"_id": "63ec9527e29310243b665e9c",
"alwaysInStock": False,
"costPrice": None,
"dimension": {
"height": 7,
"length": 30,
"unit": "m",
"width": 50
},
"isActive": True,
"options": [
{
"id": "63359d60cfce8ece38311278",
"label": "Color",
"name": "Black"
}
],
"price": 3000000,
"sale_price": None,
"sku": "toyota-corolla-black-65e9b",
"stock": 15,
"weight": {
"base": {
"unit": None,
"value": None
},
"unit": "kg",
"value": 20000
}
}
],
"variantsInheritPrice": True
}
headers = {"Content-Type": "application/json"}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
attributes: [
{
name: {_id: '620230bd0d148855678615c3', name: 'Color'},
options: [
{id: '633595a632a48354241eedee', label: 'Color', name: 'Space grey'},
{id: '63359d60cfce8ece38311278', label: 'Color', name: 'Black'}
]
}
],
price: 21000000,
sale_price: 19000000,
typeAttributes: {packaging: {height: 115.24, length: 145.72, weight: 4500, width: 135.56}},
variants: [
{
_id: '63ec9527e29310243b665e9c',
alwaysInStock: false,
costPrice: null,
dimension: {height: 7, length: 30, unit: 'm', width: 50},
isActive: true,
options: [{id: '63359d60cfce8ece38311278', label: 'Color', name: 'Black'}],
price: 3000000,
sale_price: null,
sku: 'toyota-corolla-black-65e9b',
stock: 15,
weight: {base: {unit: null, value: null}, unit: 'kg', value: 20000}
}
],
variantsInheritPrice: true
})
};
fetch('http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e', 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 => "http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'attributes' => [
[
'name' => [
'_id' => '620230bd0d148855678615c3',
'name' => 'Color'
],
'options' => [
[
'id' => '633595a632a48354241eedee',
'label' => 'Color',
'name' => 'Space grey'
],
[
'id' => '63359d60cfce8ece38311278',
'label' => 'Color',
'name' => 'Black'
]
]
]
],
'price' => 21000000,
'sale_price' => 19000000,
'typeAttributes' => [
'packaging' => [
'height' => 115.24,
'length' => 145.72,
'weight' => 4500,
'width' => 135.56
]
],
'variants' => [
[
'_id' => '63ec9527e29310243b665e9c',
'alwaysInStock' => false,
'costPrice' => null,
'dimension' => [
'height' => 7,
'length' => 30,
'unit' => 'm',
'width' => 50
],
'isActive' => true,
'options' => [
[
'id' => '63359d60cfce8ece38311278',
'label' => 'Color',
'name' => 'Black'
]
],
'price' => 3000000,
'sale_price' => null,
'sku' => 'toyota-corolla-black-65e9b',
'stock' => 15,
'weight' => [
'base' => [
'unit' => null,
'value' => null
],
'unit' => 'kg',
'value' => 20000
]
]
],
'variantsInheritPrice' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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 := "http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e"
payload := strings.NewReader("{\n \"attributes\": [\n {\n \"name\": {\n \"_id\": \"620230bd0d148855678615c3\",\n \"name\": \"Color\"\n },\n \"options\": [\n {\n \"id\": \"633595a632a48354241eedee\",\n \"label\": \"Color\",\n \"name\": \"Space grey\"\n },\n {\n \"id\": \"63359d60cfce8ece38311278\",\n \"label\": \"Color\",\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"price\": 21000000,\n \"sale_price\": 19000000,\n \"typeAttributes\": {\n \"packaging\": {\n \"height\": 115.24,\n \"length\": 145.72,\n \"weight\": 4500,\n \"width\": 135.56\n }\n },\n \"variants\": [\n {\n \"_id\": \"63ec9527e29310243b665e9c\",\n \"alwaysInStock\": false,\n \"costPrice\": null,\n \"dimension\": {\n \"height\": 7,\n \"length\": 30,\n \"unit\": \"m\",\n \"width\": 50\n },\n \"isActive\": true,\n \"options\": [\n {\n \"id\": \"63359d60cfce8ece38311278\",\n \"label\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"price\": 3000000,\n \"sale_price\": null,\n \"sku\": \"toyota-corolla-black-65e9b\",\n \"stock\": 15,\n \"weight\": {\n \"base\": {\n \"unit\": null,\n \"value\": null\n },\n \"unit\": \"kg\",\n \"value\": 20000\n }\n }\n ],\n \"variantsInheritPrice\": true\n}")
req, _ := http.NewRequest("PATCH", url, payload)
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.patch("http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e")
.header("Content-Type", "application/json")
.body("{\n \"attributes\": [\n {\n \"name\": {\n \"_id\": \"620230bd0d148855678615c3\",\n \"name\": \"Color\"\n },\n \"options\": [\n {\n \"id\": \"633595a632a48354241eedee\",\n \"label\": \"Color\",\n \"name\": \"Space grey\"\n },\n {\n \"id\": \"63359d60cfce8ece38311278\",\n \"label\": \"Color\",\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"price\": 21000000,\n \"sale_price\": 19000000,\n \"typeAttributes\": {\n \"packaging\": {\n \"height\": 115.24,\n \"length\": 145.72,\n \"weight\": 4500,\n \"width\": 135.56\n }\n },\n \"variants\": [\n {\n \"_id\": \"63ec9527e29310243b665e9c\",\n \"alwaysInStock\": false,\n \"costPrice\": null,\n \"dimension\": {\n \"height\": 7,\n \"length\": 30,\n \"unit\": \"m\",\n \"width\": 50\n },\n \"isActive\": true,\n \"options\": [\n {\n \"id\": \"63359d60cfce8ece38311278\",\n \"label\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"price\": 3000000,\n \"sale_price\": null,\n \"sku\": \"toyota-corolla-black-65e9b\",\n \"stock\": 15,\n \"weight\": {\n \"base\": {\n \"unit\": null,\n \"value\": null\n },\n \"unit\": \"kg\",\n \"value\": 20000\n }\n }\n ],\n \"variantsInheritPrice\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"attributes\": [\n {\n \"name\": {\n \"_id\": \"620230bd0d148855678615c3\",\n \"name\": \"Color\"\n },\n \"options\": [\n {\n \"id\": \"633595a632a48354241eedee\",\n \"label\": \"Color\",\n \"name\": \"Space grey\"\n },\n {\n \"id\": \"63359d60cfce8ece38311278\",\n \"label\": \"Color\",\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"price\": 21000000,\n \"sale_price\": 19000000,\n \"typeAttributes\": {\n \"packaging\": {\n \"height\": 115.24,\n \"length\": 145.72,\n \"weight\": 4500,\n \"width\": 135.56\n }\n },\n \"variants\": [\n {\n \"_id\": \"63ec9527e29310243b665e9c\",\n \"alwaysInStock\": false,\n \"costPrice\": null,\n \"dimension\": {\n \"height\": 7,\n \"length\": 30,\n \"unit\": \"m\",\n \"width\": 50\n },\n \"isActive\": true,\n \"options\": [\n {\n \"id\": \"63359d60cfce8ece38311278\",\n \"label\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"price\": 3000000,\n \"sale_price\": null,\n \"sku\": \"toyota-corolla-black-65e9b\",\n \"stock\": 15,\n \"weight\": {\n \"base\": {\n \"unit\": null,\n \"value\": null\n },\n \"unit\": \"kg\",\n \"value\": 20000\n }\n }\n ],\n \"variantsInheritPrice\": true\n}"
response = http.request(request)
puts response.read_bodyProducts
Update product variants
PATCH
/
{shopId}
/
products
/
63ec9527e29310243b665e9e
Update product variants
curl --request PATCH \
--url http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e \
--header 'Content-Type: application/json' \
--data '
{
"attributes": [
{
"name": {
"_id": "620230bd0d148855678615c3",
"name": "Color"
},
"options": [
{
"id": "633595a632a48354241eedee",
"label": "Color",
"name": "Space grey"
},
{
"id": "63359d60cfce8ece38311278",
"label": "Color",
"name": "Black"
}
]
}
],
"price": 21000000,
"sale_price": 19000000,
"typeAttributes": {
"packaging": {
"height": 115.24,
"length": 145.72,
"weight": 4500,
"width": 135.56
}
},
"variants": [
{
"_id": "63ec9527e29310243b665e9c",
"alwaysInStock": false,
"costPrice": null,
"dimension": {
"height": 7,
"length": 30,
"unit": "m",
"width": 50
},
"isActive": true,
"options": [
{
"id": "63359d60cfce8ece38311278",
"label": "Color",
"name": "Black"
}
],
"price": 3000000,
"sale_price": null,
"sku": "toyota-corolla-black-65e9b",
"stock": 15,
"weight": {
"base": {
"unit": null,
"value": null
},
"unit": "kg",
"value": 20000
}
}
],
"variantsInheritPrice": true
}
'import requests
url = "http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e"
payload = {
"attributes": [
{
"name": {
"_id": "620230bd0d148855678615c3",
"name": "Color"
},
"options": [
{
"id": "633595a632a48354241eedee",
"label": "Color",
"name": "Space grey"
},
{
"id": "63359d60cfce8ece38311278",
"label": "Color",
"name": "Black"
}
]
}
],
"price": 21000000,
"sale_price": 19000000,
"typeAttributes": { "packaging": {
"height": 115.24,
"length": 145.72,
"weight": 4500,
"width": 135.56
} },
"variants": [
{
"_id": "63ec9527e29310243b665e9c",
"alwaysInStock": False,
"costPrice": None,
"dimension": {
"height": 7,
"length": 30,
"unit": "m",
"width": 50
},
"isActive": True,
"options": [
{
"id": "63359d60cfce8ece38311278",
"label": "Color",
"name": "Black"
}
],
"price": 3000000,
"sale_price": None,
"sku": "toyota-corolla-black-65e9b",
"stock": 15,
"weight": {
"base": {
"unit": None,
"value": None
},
"unit": "kg",
"value": 20000
}
}
],
"variantsInheritPrice": True
}
headers = {"Content-Type": "application/json"}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
attributes: [
{
name: {_id: '620230bd0d148855678615c3', name: 'Color'},
options: [
{id: '633595a632a48354241eedee', label: 'Color', name: 'Space grey'},
{id: '63359d60cfce8ece38311278', label: 'Color', name: 'Black'}
]
}
],
price: 21000000,
sale_price: 19000000,
typeAttributes: {packaging: {height: 115.24, length: 145.72, weight: 4500, width: 135.56}},
variants: [
{
_id: '63ec9527e29310243b665e9c',
alwaysInStock: false,
costPrice: null,
dimension: {height: 7, length: 30, unit: 'm', width: 50},
isActive: true,
options: [{id: '63359d60cfce8ece38311278', label: 'Color', name: 'Black'}],
price: 3000000,
sale_price: null,
sku: 'toyota-corolla-black-65e9b',
stock: 15,
weight: {base: {unit: null, value: null}, unit: 'kg', value: 20000}
}
],
variantsInheritPrice: true
})
};
fetch('http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e', 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 => "http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'attributes' => [
[
'name' => [
'_id' => '620230bd0d148855678615c3',
'name' => 'Color'
],
'options' => [
[
'id' => '633595a632a48354241eedee',
'label' => 'Color',
'name' => 'Space grey'
],
[
'id' => '63359d60cfce8ece38311278',
'label' => 'Color',
'name' => 'Black'
]
]
]
],
'price' => 21000000,
'sale_price' => 19000000,
'typeAttributes' => [
'packaging' => [
'height' => 115.24,
'length' => 145.72,
'weight' => 4500,
'width' => 135.56
]
],
'variants' => [
[
'_id' => '63ec9527e29310243b665e9c',
'alwaysInStock' => false,
'costPrice' => null,
'dimension' => [
'height' => 7,
'length' => 30,
'unit' => 'm',
'width' => 50
],
'isActive' => true,
'options' => [
[
'id' => '63359d60cfce8ece38311278',
'label' => 'Color',
'name' => 'Black'
]
],
'price' => 3000000,
'sale_price' => null,
'sku' => 'toyota-corolla-black-65e9b',
'stock' => 15,
'weight' => [
'base' => [
'unit' => null,
'value' => null
],
'unit' => 'kg',
'value' => 20000
]
]
],
'variantsInheritPrice' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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 := "http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e"
payload := strings.NewReader("{\n \"attributes\": [\n {\n \"name\": {\n \"_id\": \"620230bd0d148855678615c3\",\n \"name\": \"Color\"\n },\n \"options\": [\n {\n \"id\": \"633595a632a48354241eedee\",\n \"label\": \"Color\",\n \"name\": \"Space grey\"\n },\n {\n \"id\": \"63359d60cfce8ece38311278\",\n \"label\": \"Color\",\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"price\": 21000000,\n \"sale_price\": 19000000,\n \"typeAttributes\": {\n \"packaging\": {\n \"height\": 115.24,\n \"length\": 145.72,\n \"weight\": 4500,\n \"width\": 135.56\n }\n },\n \"variants\": [\n {\n \"_id\": \"63ec9527e29310243b665e9c\",\n \"alwaysInStock\": false,\n \"costPrice\": null,\n \"dimension\": {\n \"height\": 7,\n \"length\": 30,\n \"unit\": \"m\",\n \"width\": 50\n },\n \"isActive\": true,\n \"options\": [\n {\n \"id\": \"63359d60cfce8ece38311278\",\n \"label\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"price\": 3000000,\n \"sale_price\": null,\n \"sku\": \"toyota-corolla-black-65e9b\",\n \"stock\": 15,\n \"weight\": {\n \"base\": {\n \"unit\": null,\n \"value\": null\n },\n \"unit\": \"kg\",\n \"value\": 20000\n }\n }\n ],\n \"variantsInheritPrice\": true\n}")
req, _ := http.NewRequest("PATCH", url, payload)
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.patch("http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e")
.header("Content-Type", "application/json")
.body("{\n \"attributes\": [\n {\n \"name\": {\n \"_id\": \"620230bd0d148855678615c3\",\n \"name\": \"Color\"\n },\n \"options\": [\n {\n \"id\": \"633595a632a48354241eedee\",\n \"label\": \"Color\",\n \"name\": \"Space grey\"\n },\n {\n \"id\": \"63359d60cfce8ece38311278\",\n \"label\": \"Color\",\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"price\": 21000000,\n \"sale_price\": 19000000,\n \"typeAttributes\": {\n \"packaging\": {\n \"height\": 115.24,\n \"length\": 145.72,\n \"weight\": 4500,\n \"width\": 135.56\n }\n },\n \"variants\": [\n {\n \"_id\": \"63ec9527e29310243b665e9c\",\n \"alwaysInStock\": false,\n \"costPrice\": null,\n \"dimension\": {\n \"height\": 7,\n \"length\": 30,\n \"unit\": \"m\",\n \"width\": 50\n },\n \"isActive\": true,\n \"options\": [\n {\n \"id\": \"63359d60cfce8ece38311278\",\n \"label\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"price\": 3000000,\n \"sale_price\": null,\n \"sku\": \"toyota-corolla-black-65e9b\",\n \"stock\": 15,\n \"weight\": {\n \"base\": {\n \"unit\": null,\n \"value\": null\n },\n \"unit\": \"kg\",\n \"value\": 20000\n }\n }\n ],\n \"variantsInheritPrice\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://staging.qshop.ng/apiv2/{shopId}/products/63ec9527e29310243b665e9e")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"attributes\": [\n {\n \"name\": {\n \"_id\": \"620230bd0d148855678615c3\",\n \"name\": \"Color\"\n },\n \"options\": [\n {\n \"id\": \"633595a632a48354241eedee\",\n \"label\": \"Color\",\n \"name\": \"Space grey\"\n },\n {\n \"id\": \"63359d60cfce8ece38311278\",\n \"label\": \"Color\",\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"price\": 21000000,\n \"sale_price\": 19000000,\n \"typeAttributes\": {\n \"packaging\": {\n \"height\": 115.24,\n \"length\": 145.72,\n \"weight\": 4500,\n \"width\": 135.56\n }\n },\n \"variants\": [\n {\n \"_id\": \"63ec9527e29310243b665e9c\",\n \"alwaysInStock\": false,\n \"costPrice\": null,\n \"dimension\": {\n \"height\": 7,\n \"length\": 30,\n \"unit\": \"m\",\n \"width\": 50\n },\n \"isActive\": true,\n \"options\": [\n {\n \"id\": \"63359d60cfce8ece38311278\",\n \"label\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"price\": 3000000,\n \"sale_price\": null,\n \"sku\": \"toyota-corolla-black-65e9b\",\n \"stock\": 15,\n \"weight\": {\n \"base\": {\n \"unit\": null,\n \"value\": null\n },\n \"unit\": \"kg\",\n \"value\": 20000\n }\n }\n ],\n \"variantsInheritPrice\": true\n}"
response = http.request(request)
puts response.read_bodyBody
application/json
Show child attributes
Show child attributes
Example:
[
{
"name": {
"_id": "620230bd0d148855678615c3",
"name": "Color"
},
"options": [
{
"id": "633595a632a48354241eedee",
"label": "Color",
"name": "Space grey"
},
{
"id": "63359d60cfce8ece38311278",
"label": "Color",
"name": "Black"
}
]
}
]
Example:
21000000
Example:
19000000
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Example:
[
{
"_id": "63ec9527e29310243b665e9c",
"alwaysInStock": false,
"costPrice": null,
"dimension": {
"height": 7,
"length": 30,
"unit": "m",
"width": 50
},
"isActive": true,
"options": [
{
"id": "63359d60cfce8ece38311278",
"label": "Color",
"name": "Black"
}
],
"price": 3000000,
"sale_price": null,
"sku": "toyota-corolla-black-65e9b",
"stock": 15,
"weight": {
"base": { "unit": null, "value": null },
"unit": "kg",
"value": 20000
}
}
]
Example:
true
Response
200 - undefined
Was this page helpful?
⌘I