woocommerce_rest_cart_invalid_key : Cart item does not exist - php

I'm implementing WooCommerce on App through StoreApi https://developer.woocommerce.com/2022/03/25/store-api-is-now-considered-stable/. I can easily access Cart against logged in user through JWT. I believe there is some issue with /wp-json/wc/store/v1/cart/update-item where I'm using the item key from "items": [ { "key": "b5d5251068629b801eb58fcc745120db", "id": 55774, "quantity": 2, "quantity_limits": { "minimum": 1, "maximum": 45, "multiple_of": 1, "editable": true }] which is response got from /wp-json/wc/store/v1/cart/. but I'm receiving cart item does not exist which in fact exist. from Browser I can update item with no issue.

Related

Not able to post some fields using createDraftListing API

We have implemented the createDraftListing API using this documentation to create new listing on etsy.
But we are not able to post below field using above API because in documentation request parameter this field are not present.
Also we have added the item weight, item length, item width and item height in request feed and posting this value to above api call but still showing blank on products.
Request feed:
{
"title": "this is my title",
"description": "this is my description",
"quantity": "100",
"state": "active",
"price": 44.55,
"who_made": "collective",
"when_made": "2020_2022",
"listing_type": "physical",
"shipping_profile_id": 12345678,
"processing_min": 1,
"processing_max": 1,
"item_weight": "0.71",
"item_weight_unit": "lb",
"item_length": 5.5,
"item_width": "7.5",
"item_height": 0.75,
"item_dimensions_unit": "in",
"has_variations": false,
"language": "en-US",
"is_taxable": true,
"should_auto_renew": true,
"is_customizable": true,
"is_personalizable": true,
"personalization_is_required": true,
"personalization_char_count_max": 1,
"personalization_instructions": "",
"taxonomy_id": 2279
}
So please let us know any api to post above fields to etsy?
Thanks.
first you can get id shipping profile id in get shipping profile api. I try and success

How to update base price of product by store id using magento 2 rest api?

I am trying to update base price of product by store id and product SKU using POSTMAN. But, getting error Invalid Attribute. Sometimes it works fine. I tried to change product attributes to if it cause to this issue but it didn't resolved the issue.
Request URL -
{{url}}/V1/products/base-prices
Request Body -
{
"prices": [
{
"price": 38,
"store_id": 4,
"sku": "WEBPRICETEST"
}
]
}
Response -
[
{
"message": "Invalid attribute %fieldName = %fieldValue.",
"parameters": [
"SKU",
"WEBPRICETEST"
]
}
]
There is no any traces in error log.
This error could appear if you try to use the wrong type of a request.
Try this
POST(not PUT or any other): <domain>/rest/V1/products/base-prices
OR (for async request): POST <domain>/rest/async/V1/products/base-prices
Body
{
"prices": [
{
"price": 222,
"store_id": 2,
"sku": "SKU-1"
},
{
"price": 333,
"store_id": 2,
"sku": "SKU-2"
}
]
}
Don't forget to set headers:
Content-Type : application/json
Authorization: Bearer <Your Access Token>
So basically if both success and error request payload are some and it gives error with few of SKUs then it may be the type of product which is causing error. The endpoint you are using will only update below types of product base price.
Simple,
Virtual,
Downloadable,
Bundle (fixed price type only).
https://devdocs.magento.com/guides/v2.4/rest/modules/catalog-pricing.html#set-base-prices
Magento already supports getting prices by store. You just need to add store_code and URL: {{url}}/{store code}/V1/products/base-prices

WooCommerce product WPML translation inserted by REST API doesn't include variations of original product

Unfortunately I'm working with wordpress and woocommerce, what I'm trying to accomplish is to insert products and relative translations using the woocommerce REST API, here's the scenario:
First, i create a simple product
{
"name": "Dummy",
"type": "variable",
"attributes": [
{
"id": 2,
"name": "Color",
"position": 1,
"variation": "true",
"options": [
"Bianco",
"Nero"
]
},
{
"id": 3,
"name": "Size",
"position": 2,
"variation": "true",
"options": [
"A",
"B",
"C"
]
}
]
}
This is a variable product, so I need to create its variations as well
The product created return its id, let's say 10
Then I create several product variations like this:
{
"regular_price": "10.10",
"stock_quantity": 10,
"attributes": [
{
"id": 2,
"name": "Color",
"option": "Bianco"
},
{
"id": 3,
"name": "Size",
"option": "A"
}
]
}
So I have a product with variations, now i want to create a translation of the product with wpml, according to wmpl rest api specifications, I create a product translation like this:
{
"name": "Dummy en",
"type": "variable",
"lang": "en",
"translation_of": 10
}
I specified the language en, the main language is it
I included translation_of with the id of the original product
What happens is that the english product is created, but without variations
What I have tried:
Several issues similar to this are solved by the troubleshooting page of wpml, where I can generate missing variations but I need this to be done automatically, products are created automatically, so relative translations too must be
If I enter product page from wordpress back end and I press the update button, variations are created and adjusted, this word for the original product and the variation, but again, I need this to be done automatically
I tried to modify and insert the translation in almost all ways, adding/removing sku, id, attributes, categories ecc.
Any hints? Thanks

Woocommerce Rest API issue with stock quantity

I create Woocommerce products in my ionic app. I would like also to push the stock quantity when I create the product. However, the stock always is with NULL stored in my MYSQL DB. Here is the JSON feed
{
"product": {
"title": "test stock",
"stock_quantity": "35",
"images": [],
"post_author": 88,
"type": "simple",
"categories": []
}
}:
And here the piece of code from the app
var productInfo = {
title: this.productName,
regular_price: this.productPrice,
sale_price: this.productDiscount,
stock_quantity: this.productStock,
description: this.productDesc,
images: new Array<any>(),
post_author: this.userService.id,
type: this.productType,
categories: new Array<any>()
};
I tried different tags for stock_quantity like only "stock" and tried to push the variable with "" and without it. But I'm facing still the same issue.
Your JSON syntax is correct. Also, you are passing the correct parameter for the stock as stock_quantity and as I reviewed your JSON request you have not passed the manage_stock parameter as true by default that considers as false. so, you need to pass that parameter also.
You can try the following code.
{
"product": {
"title": "test stock",
"stock_quantity": "35",
"manage_stock": true,
"images": [],
"post_author": 88,
"type": "simple",
"categories": []
}
}:
you can refere the WooCommerce REST API Product Properties for create products

Podio PHP: category is empty when no value for item

We are using the Podio PHP library to create forms for our users. These forms load their data from Podio trough the Podio PHP library. A form is linked to a specific Podio Item ID for this.
With this ID we get the fields and their possible values. Most of them are Category fields. We get the values for this trough:
<?php
$item_data = PodioItem::get_basic( $podio_item_id );
$car_types = $item_data->fields["car-type"]->config['settings']['options'];
var_dump( $car_types );
?>
But the curious thing is, if the item in Podio has no value selected for this category, getting the options fail. It's empty. It doesn't exists.
How do we populate a form with values even if the item has no options selected for it?
Podio doesn't store empty value, it's empty, it doesn't exist, so there is nothing to store. In fact, what you are probably looking for is Application definition, which has list fields. Then category field has config with list of possible values and id's and colors.
Like this:
"fields": [
{
"status": "active",
"type": "category",
"field_id": 81772,
"label": "Status",
"config": {
"required": true,
"label": "Status",
.....some other config values .....
"settings": {
"multiple": false,
"options": [
{
"status": "deleted", <= example of deleted category option
"text": "Not groomed",
"id": 13,
"color": "DCEBD8"
},
{
"status": "active", <= example of active category option
"text": "Open",
"id": 1,
"color": "FFD5C2"
},
.... <= other category options goes here
You can read more about Apps here: https://developers.podio.com/doc/applications/get-app-22349

Categories