Getting current Cart Id in Bigcommerce - bigcommerce

So, I am using the cart API of Bigcommerce for adding items to the cart from a different domain which is working fine. However, when I try to repeat adding other items to the same cart it does not work. So, is there a way I can get the cart ID for an instance so that I can update my items to the existing cart?

The Storefront API allows you to retrieve the current cart.
Execute this in the javascript console after adding an item to cart
fetch('/api/storefront/carts?include=',
{
'credentials':'include',
'headers':{
'Accept':'application/json',
'Content-Type': 'application/json'
}
}).then(function(response){
response.json().then(function(data) {
console.log(JSON.stringify(data, null, 3))
})
});
returns something like this
[
{
"id": "aaaaaaaa-bbbb-ccccc-dddd-eeeeeeeeeeee",
"customerId": 0,
"email": null,
"currency": {
"name": "US Dollars",
"code": "USD",
"symbol": "$",
"decimalPlaces": 2
},
"isTaxIncluded": false,
"baseAmount": 100,
"discountAmount": 0,
"cartAmount": 100,
"coupons": [],
"discounts": [
{
"id": "79f73e11-87ba-4dd1-acaf-41c0098ea6ca",
"discountedAmount": 0
}
],
"lineItems": {
"physicalItems": [
{
"id": "79f73e11-87ba-4dd1-acaf-41c0098ea6ca",
"variantId": 77,
"productId": 112,
"sku": "1111",
"name": "Physical A",
"url": "http://vanity.mybigcommerce.com/physical-a/",
"quantity": 1,
"isTaxable": true,
"imageUrl": "http://cdn8.bigcommerce.com/r-de362a881829f428d7c6c20159e24db4a9c0a751/themes/ClassicNext/images/ProductDefault.gif",
"discounts": [],
"discountAmount": 0,
"couponAmount": 0,
"listPrice": 100,
"salePrice": 100,
"extendedListPrice": 100,
"extendedSalePrice": 100,
"isShippingRequired": true,
"type": "physical",
"giftWrapping": null
}
],
"digitalItems": [],
"giftCertificates": []
},
"createdTime": "2018-05-07T19:32:19+00:00",
"updatedTime": "2018-05-07T19:33:48+00:00"
}
]

When you created your first item, the response will include Cart ID. Use this Cart ID to add more items to the same cart.

Related

Product Visibility

Issue
When logged in as a buyer, I am unable to see a product I should have access to. Issuing this request, /v1/me/products while passing a token for user buyer01, I see this response:
{
"Meta": {
"Facets": [],
"Page": 1,
"PageSize": 20,
"TotalCount": 0,
"TotalPages": 0,
"ItemRange": [
1,
0
],
"NextPageKey": null
},
"Items": []
}
I expect to see the product SHIRT listed in the Items array element.
Visibility rules
I've worked through the Visibility Rules Checklist and I believe all conditions have been met:
Product.Active = true
Catalog exists where:
Catalog.Active = true
Buyer is assigned via CatalogAssignment
Product is assigned via ProductCatalogAssignment
One of the following is true:
CatalogAssignment.ViewAllProducts = true
Product is active
{{baseUrl}}/v1/products returns this response:
{
"Meta": {
"Facets": [],
"Page": 1,
"PageSize": 20,
"TotalCount": 1,
"TotalPages": 1,
"ItemRange": [
1,
1
],
"NextPageKey": null
},
"Items": [
{
"OwnerID": "xxxxxxxxxxxxxxxx",
"DefaultPriceScheduleID": "SHIRT_PRICE",
"AutoForward": false,
"ID": "SHIRT",
"Name": "Cotton T-Shirt",
"Description": "A plain white, cotton shirt for everyday use.",
"QuantityMultiplier": 1,
"ShipWeight": null,
"ShipHeight": null,
"ShipWidth": null,
"ShipLength": null,
"Active": true,
"SpecCount": 0,
"VariantCount": 0,
"ShipFromAddressID": null,
"Inventory": null,
"DefaultSupplierID": null,
"AllSuppliersCanSell": false,
"Returnable": false,
"xp": null
}
]
}
Catalog is active
{{baseUrl}}/v1/catalogs returns
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 1,
"TotalPages": 1,
"ItemRange": [
1,
1
],
"NextPageKey": null
},
"Items": [
{
"ID": "BUYER_ORGANIZATION",
"OwnerID": "xxxxxxxxxxxxxxxx",
"Name": "Example Buyer",
"Description": "Default catalog for Example Buyer",
"Active": true,
"CategoryCount": 0,
"xp": null
}
]
}
Buyer is assigned
Buyer user in organization
{{baseUrl}}/v1/me (with buyer01 cookie) returns:
{
"Buyer": {
"ID": "BUYER_ORGANIZATION",
"DefaultCatalogID": "BUYER_ORGANIZATION"
},
"Supplier": null,
"Seller": {
"ID": "xxxxxxxxxxxxxxxx"
},
"ID": "BUYER_USER",
"CompanyID": "BUYER_ORGANIZATION",
"Username": "buyer01",
"Password": null,
"FirstName": "Buyer",
"LastName": "User",
"Email": "buyer#email.com",
"Phone": null,
"TermsAccepted": null,
"Active": true,
"xp": null,
"AvailableRoles": [
"MeAdmin",
"PasswordReset",
"Shopper"
],
"Locale": null,
"DateCreated": "2022-12-21T00:43:53.507+00:00",
"PasswordLastSetDate": "2022-12-21T00:43:53.543+00:00"
}
Buyer organization is assigned catalog
{{baseUrl}}/v1/catalogs/assignments returns
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 1,
"TotalPages": 1,
"ItemRange": [
1,
1
],
"NextPageKey": null
},
"Items": [
{
"CatalogID": "BUYER_ORGANIZATION",
"BuyerID": "BUYER_ORGANIZATION",
"ViewAllCategories": true,
"ViewAllProducts": true
}
]
}
Product is assigned
This may be the issue. When I make the documented assignment:
{{baseUrl}}/v1/catalogs/productassignments
{
"CatalogID": "BUYER_ORGANIZATION",
"ProductID": "SHIRT"
}
I receive a 200 response that does not show any assignment has occurred:
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 0,
"TotalPages": 0,
"ItemRange": [
1,
0
],
"NextPageKey": null
},
"Items": []
}
Note that the above request, as all other steps, is taken from the Getting Started walkthrough. This step is provided under Making Your Product Visible.
This is confirmed by this request:
{{baseUrl}}/v1/products/assignments, which returns no products.
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 0,
"TotalPages": 0,
"ItemRange": [
1,
0
],
"NextPageKey": null
},
"Items": []
}
View all products is true
{{baseUrl}}/v1/catalogs/assignments returns
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 1,
"TotalPages": 1,
"ItemRange": [
1,
1
],
"NextPageKey": null
},
"Items": [
{
"CatalogID": "BUYER_ORGANIZATION",
"BuyerID": "BUYER_ORGANIZATION",
"ViewAllCategories": true,
"ViewAllProducts": true
}
]
}
The issue was that I was making a GET request instead of a POST when doing this:
{{baseUrl}}/v1/catalogs/productassignments
When issuing a POST, the service returns a 204 No Content.
It is worth noting that the tutorial is a bit out of date--the current Product API documentation omits the above call, and instead has /products/assignments here. This method will return a 405 Method Not Allowed an error if doing a GET, which makes this issue easier to identify.
Now when I view /me/products as buyer01 I see this:
{
"Meta": {
"Facets": [],
"Page": 1,
"PageSize": 20,
"TotalCount": 1,
"TotalPages": 1,
"ItemRange": [
1,
1
],
"NextPageKey": null
},
"Items": [
{
"PriceSchedule": {
"OwnerID": "xxxxxxxxxxxxxxxx",
"ID": "SHIRT_PRICE",
"Name": "Cotton T-Shirt Price",
"ApplyTax": false,
"ApplyShipping": false,
"MinQuantity": 1,
"MaxQuantity": null,
"UseCumulativeQuantity": false,
"RestrictedQuantity": false,
"PriceBreaks": [
{
"Quantity": 1,
"Price": 10.0,
"SalePrice": null
}
],
"Currency": null,
"SaleStart": null,
"SaleEnd": null,
"IsOnSale": false,
"xp": null
},
"ID": "SHIRT",
"Name": "Cotton T-Shirt",
"Description": "A plain white, cotton shirt for everyday use.",
"QuantityMultiplier": 1,
"ShipWeight": null,
"ShipHeight": null,
"ShipWidth": null,
"ShipLength": null,
"Active": true,
"SpecCount": 0,
"VariantCount": 0,
"ShipFromAddressID": null,
"Inventory": null,
"DefaultSupplierID": null,
"AllSuppliersCanSell": false,
"Returnable": false,
"xp": null
}
]
}

Shopware 6 API / Product Listing / How to add available color variants for each product on the response

API Request
/store-api/product-listing/{categoryId}
I want each product in the API response to have available color variants. Because I want to show color variants on the product list page. But currently this data is not provided by the shopware 6 api.
I've tried to add this data by using associations but it didnt help.
Request Body
{
"includes": {
"product": ["id", "productNumber", "cover", "options"]
},
"associations": {
"options": {
"media": []
}
}
}
The request body looks to be correct. If the product is a variant then it should have content for options.
To verify try the following request body:
{
"limit": 1,
"includes": {
"product": ["id", "productNumber", "options"],
"property_group_option": ["name", "group"],
"property_group": ["name"]
},
"associations": {
"options": {
"associations": {
"group": []
}
}
},
"filters": [
{
"type": "not",
"operator": "and",
"queries": [
{
"type": "equals",
"field": "parentId",
"value": null
}
]
}
]
}
This should yield a single variant.
Response should look similar to this:
{
"entity": "product",
"total": 1,
"aggregations": [],
"page": 1,
"limit": 1,
"elements": [
{
"productNumber": "10042.1",
"options": [
{
"name": "linen",
"group": {
"name": "textile",
"apiAlias": "property_group"
},
"apiAlias": "property_group_option"
},
{
"name": "35",
"group": {
"name": "size",
"apiAlias": "property_group"
},
"apiAlias": "property_group_option"
},
{
"name": "chartreuse",
"group": {
"name": "shirt-color",
"apiAlias": "property_group"
},
"apiAlias": "property_group_option"
}
],
"id": "0002ea44c49c41ecb91c43e7e49e422d",
"apiAlias": "product"
}
],
"states": [],
"apiAlias": "dal_entity_search_result"
}

How to create complex-rules for modifier of product in bigcommerce

I am new in bigcommerce and type to added complex-rules for Modifier of product. below provide the URL of API URL and JSON.
every time give error "The rule must contain multiple modifier conditions with unique modifier ids or a variant condition and modifier condition"
https://api.bigcommerce.com/stores/{$$.env.store_hash}/v3/catalog/products/{product_id}/complex-rules
Please help where I wrong in send Complex Rule request JSON.
Modifier:
{
"data": {
"config": [],
"display_name": "Donation",
"id": 188,
"name": "Donation1645178599-166",
"option_values": [
{
"adjusters": {
"image_url": "",
"price": null,
"purchasing_disabled": {
"message": "",
"status": false
},
"weight": null
},
"id": 352,
"is_default": true,
"label": "$5 Donation",
"option_id": 188,
"sort_order": 0,
"value_data": null
},
{
"adjusters": {
"image_url": "",
"price": null,
"purchasing_disabled": {
"message": "",
"status": false
},
"weight": null
},
"id": 353,
"is_default": false,
"label": "$10 Donation",
"option_id": 188,
"sort_order": 0,
"value_data": null
}
],
"product_id": 166,
"required": false,
"sort_order": 0,
"type": "dropdown"
},
"meta": {}
}
Complex Rule request JSON:
{
"product_id": 166,
"sort_order": 0,
"enabled": true,
"stop": false,
"purchasing_disabled": false,
"purchasing_hidden": false,
"price_adjuster": {
"adjuster": "relative",
"adjuster_value": 6
},
"weight_adjuster": {
"adjuster": "relative",
"adjuster_value": 6
},
"conditions": [
{
"id": 5,
"rule_id": 5,
"modifier_id": 189,
"modifier_value_id": 352
}
]
}
Error output:
{
"status": 422,
"title": "The rule must contain multiple modifier conditions with unique modifier ids or a variant condition and modifier condition",
"type": "https://developer.bigcommerce.com/api-docs/getting-started/api-status-codes"
}

image Url of the last item in my db table get changed to "data:image/jpeg;base64,..." when i console.log it when running my app built with expo

I am fetching a list of items stored in my database, when i console the items all other items shows the document url address but the last one always shows "data:image/jpeg;base64,...(truncated to the first 10000 characters)"
If i delete the last item, the second to last changes to show the same thing
/****************************************************************
Routing and posting functions after button has been pressed
*****************************************************************/
let url = 'https://myserver/viewProduct';
axios
.get(url,{
headers:{
'Accept': 'application/json',
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true,
'Access-Control-Allow-Headers':'Content-Type, Accept, Access-Control-Allow-Origin'
}
})
.then(res => {
setData(res.data.doc);
setIsLoading(false);
setProduct(true);
// setAddButton(true);
// setList(true)
console.log(res.data.doc)
return;
// }
})
.catch((err) => {
console.log(err)
setNetworkErr(true);
setIsLoading(false);
return;
})
};```
**Object {
"__v": 0,
"_id": "61b9c93efa2822c52c8bc52e",
"category": "Electronics",
"condition": "New",
"imgUrl": "https://nigeriantech.com.ng/wp-content/uploads/2020/01/Home-Theatre-Review-Prices-in-Nigeria-nigeriantech.com_.ng_.jpg",
"itemName": "Home Theater",
"productID": "1m7zw9otu7i",
"quantity": "5",
"totalCost": 250000,
},
Object {
"__v": 0,
"_id": "61b9c96bfa2822c52c8bc530",
"category": "Electronics",
"condition": "Refurbished",
"imgUrl": "https://ae01.alicdn.com/kf/HTB14IPRMVXXXXbFaXXXq6xXFXXXe/Music-Angel-JH-MD06BT2-Speaker-Bluetooth-Portable-TF-slot-mp3-blue-tooth-speakers-Mini-Music-Sound.jpg_Q90.jpg_.webp",
"itemName": "Mp3 Player",
"productID": "tj6qtz68vvx",
"quantity": "6",
"totalCost": 6699,
},
Object {
"__v": 0,
"_id": "61b9c9a1fa2822c52c8bc533",
"category": "Mobile Devices",
"condition": "Old",
"imgUrl": "data:image/jpeg;base64,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ACjEbBBkxvD1aSDtUjUPEuVA8AB84q2pOltdnDugM5JO27j6TmU8D6QESSdyHgfSdyHhADqMRsnruauNFOli6pdVq9WyUhcBmZmYdkb7WUzyS0yTYbToBpNjklKOW1WpUpuGIGWnTqLbTaC6m9yZnlipRafYqLado+k1MTTrYnB2ZMiU6uKft..(truncated to the first 10000 characters)**
can anybody help me out with how to avoid this?

Cart API: cart.data.data.cart_amount is not calculated correctly.... I think

added a product to cart using API price was $29
GET /v3/carts/cartId saw cart_amount was correct
changed product price to $100
GET /v3/carts/cartId saw cart_amount was wrong — it did not see that the product price had changed.
Am i doing something wrong. Do you need more info to help me?
bc.add_to_cart = (data,next) => {
let payload = {
line_items: data.line_items,
option_selections: data.option_selections,
gift_certificatesL: null
}
return bc_v3.post(`/carts/${data.cartId}/items`, payload).then(data => {
return data; // data only show initial product cost
}).catch(next);
};
EDIT
below i am posting the results of GET carts/id u will see that the lineItem (id: 125) shows the original price, 29.95. Immediately after getting the cart I did a request to GET /catalog/products/125 — that one shows the updated price.
GET: carts/${cartId}
{
"data": {
"id": "15219c6d-51a8-4267-a38c-29fe62a49182",
"customer_id": 0,
"email": "",
"currency": {
"code": "USD"
},
"tax_included": false,
"base_amount": 409.7,
"discount_amount": 0,
"cart_amount": 409.7,
"coupons": [],
"line_items": {
"physical_items": [
{
"id": "d755137f-b09c-4a02-9da6-cab8da1ae332",
"parent_id": null,
"variant_id": 89,
"product_id": 124,
"sku": "test_config",
"name": "Test Configurable item",
"url": "http://fornida.mybigcommerce.com/test-configurable-item/",
"quantity": 2,
"taxable": true,
"image_url": "https://cdn7.bigcommerce.com/s-2bihpr2wvz/products/124/images/389/overview-3-lg-c__55453.1534430965.220.290.jpg?c=2",
"discounts": [],
"coupons": [],
"discount_amount": 0,
"coupon_amount": 0,
"list_price": 115,
"sale_price": 115,
"extended_list_price": 230,
"extended_sale_price": 230,
"is_require_shipping": true
},
{
"id": "eb5695d6-85e5-4b58-891b-a4bd8b48c56e",
"parent_id": null,
"variant_id": 90,
"product_id": 125,
"sku": "test_compt_1",
"name": "test component 1",
"url": "http://fornida.mybigcommerce.com/test-component-1/",
"quantity": 6,
"taxable": true,
"image_url": "https://cdn7.bigcommerce.com/r-03b8fdf5d1037c0feebbcedfd701c709422a962e/themes/ClassicNext/images/ProductDefault.gif",
"discounts": [],
"coupons": [],
"discount_amount": 0,
"coupon_amount": 0,
"list_price": 29.95,
"sale_price": 29.95,
"extended_list_price": 179.7,
"extended_sale_price": 179.7,
"is_require_shipping": true
}
],
"digital_items": [],
"gift_certificates": []
},
"created_time": "2018-08-23T15:41:10+00:00",
"updated_time": "2018-08-23T18:57:55+00:00"
},
"meta": {}
}
GET /catalog/products/125
{
"data": {
"id": 125,
"name": "test component 1",
"type": "physical",
"sku": "test_compt_1",
"description": "<p>Type a description for this product here...</p>",
"weight": 2,
"width": 0,
"depth": 0,
"height": 0,
"price": 125,
"cost_price": 0,
"retail_price": 0,
"sale_price": 0,
"map_price": 0,
"tax_class_id": 0,
"product_tax_code": "",
"calculated_price": 125,
"categories": [
23,
18
],
"brand_id": 0,
"option_set_id": 38,
"option_set_display": "right",
"inventory_level": 0,
"inventory_warning_level": 0,
"inventory_tracking": "none",
"reviews_rating_sum": 0,
"reviews_count": 0,
"total_sold": 0,
"fixed_cost_shipping_price": 0,
"is_free_shipping": false,
"is_visible": true,
"is_featured": false,
"related_products": [
-1
],
"warranty": "",
"bin_picking_number": "",
"layout_file": "product.html",
"upc": "",
"mpn": "",
"gtin": "",
"search_keywords": "",
"availability": "available",
"availability_description": "",
"gift_wrapping_options_type": "any",
"gift_wrapping_options_list": [],
"sort_order": 0,
"condition": "New",
"is_condition_shown": false,
"order_quantity_minimum": 0,
"order_quantity_maximum": 0,
"page_title": "",
"meta_keywords": [],
"meta_description": "",
"date_created": "2018-08-15T13:46:57+00:00",
"date_modified": "2018-08-23T18:22:52+00:00",
"view_count": 7,
"preorder_release_date": null,
"preorder_message": "",
"is_preorder_only": false,
"is_price_hidden": false,
"price_hidden_label": "",
"custom_url": {
"url": "/test-component-1/",
"is_customized": false
},
"base_variant_id": 90,
"open_graph_type": "product",
"open_graph_title": "",
"open_graph_description": "",
"open_graph_use_meta_description": true,
"open_graph_use_product_name": true,
"open_graph_use_image": true
},
"meta": {}
}
Updating the price of an item in the control panel or using the API will not change the price in an existing cart. If you create a new cart then the price will reflect the changes that were made.
The original cart where line_item is $25 dollars and tax is included as well to give a cart_amount of 29.12
{
"data": {
"id": "3a4c8e16-e279-4c30-83df-0010f6d54fba",
"customer_id": 0,
"email": "",
"currency": {
"code": "USD"
},
"tax_included": false,
"base_amount": 25,
"discount_amount": 0,
"cart_amount": 29.12,
"coupons": [],
"line_items": {
"physical_items": [
{
"id": "1e08875e-bf6f-4f1f-b8ba-b2e3cee10394",
"parent_id": null,
"variant_id": 363,
"product_id": 192,
"sku": "",
"name": "Smith Journal 13",
"url": "http://{store_hash}}.mybigcommerce.com/all/smith-journal-13/",
"quantity": 1,
"taxable": true,
"image_url": "https://cdn8.bigcommerce.com/s-{{store_hash}}/products/192/images/480/smithjournal1_1024x1024__85081__38998.1534344545.330.500.jpg?c=2",
"discounts": [],
"coupons": [],
"discount_amount": 0,
"coupon_amount": 0,
"list_price": 25,
"sale_price": 25,
"extended_list_price": 25,
"extended_sale_price": 25,
"is_require_shipping": true
}
],
"digital_items": [],
"gift_certificates": []
},
"created_time": "2018-08-24T14:41:17+00:00",
"updated_time": "2018-08-24T14:41:17+00:00"
},
"meta": {}
}
Update the line_item price /{store_hash}/v3/carts/{cartId}/items/{itemId}
{
"line_item":
{
"list_price": 30,
"quantity": 1,
"product_id": 192
}
}
Response - base_amount is now 30, and cart_amount is also updated to 34.96. This only changes the price for the cart and not the product
{
"data": {
"id": "3a4c8e16-e279-4c30-83df-0010f6d54fba",
"customer_id": 0,
"email": "",
"currency": {
"code": "USD"
},
"tax_included": false,
"base_amount": 30,
"discount_amount": 0,
"cart_amount": 34.96,
"coupons": [],
"line_items": {
"physical_items": [
{
"id": "1e08875e-bf6f-4f1f-b8ba-b2e3cee10394",
"parent_id": null,
"variant_id": 363,
"product_id": 192,
"sku": "",
"name": "Smith Journal 13",
"url": "http://{store_hash}.mybigcommerce.com/all/smith-journal-13/",
"quantity": 1,
"taxable": true,
"image_url": "https://cdn8.bigcommerce.com/s-{store_hash}/products/192/images/480/smithjournal1_1024x1024__85081__38998.1534344545.330.500.jpg?c=2",
"discounts": [],
"coupons": [],
"discount_amount": 0,
"coupon_amount": 0,
"list_price": 30,
"sale_price": 30,
"extended_list_price": 30,
"extended_sale_price": 30,
"is_require_shipping": true
}
],
"digital_items": [],
"gift_certificates": []
},
"created_time": "2018-08-24T14:41:17+00:00",
"updated_time": "2018-08-24T14:41:17+00:00"
},
"meta": {}
}