Closed Alexis09af closed 1 year ago
This doesn't look like an error message, can you show your full code?
Thanks, there's no error, the application ends without any error, but when i make a Get request from postman.
First i get products from woocommerce, then i get products from erp and i compare them. The application enters in this if without any problem if(v.Sku == "VA07400-108-0")
Product and variation Exists,
This put request works https://url/wp-json/wc/v3/products/5837/variations/8113
{ "stock_quantity": 10 }
RestAPI rest = new RestAPI("url", "key", "key");
WCObject wc = new WCObject(rest);
//This works (just one for test)
var products = Task.Run(async() => await wc.Product.GetAll(new Dictionary<string, string>() { { "per_page", "1" } })).Result;
//Foreach product i get variants
//i get products from ERP with context
wc_variations = getFromErp();
foreach (var item in our_erp){
//We make sku Just like this VA074800-108-0 ID-COLOR-SIZE
var sku_erp = item.id+"-"+item.color+"-"+item.size;
VariationSku v = wc_variations.FirstOrDefault(x => x.Sku == sku_erp); //wc_variations it's an array of our erp skus +stock
if (v != null){
var stock_erp = (int)item.stock;
if(v.Sku == "VA07400-108-0"){
//This if v.Sku is just for test
if(stock_erp != v.Stock){
//Only run when stocks are different in erp and in woocommerce
//Stock in Woocomerce = 22, Stock in erp = 11
//Those are 3 test that does not work, but when i make PUT from postman, works properly
var res = Task.Run(async() => await wc.Product.Variations.UpdateWithNull(v.Id_variation, v.Id_product, new { stock_quantity = stock_iggnova }));
updateProduct(wc,v.Id_product,v.Id_variation, stock_erp); //This one does not work
var results = await wc.Product.Variations.Update(v.Id_variation, new Variation { stock_quantity = stock_erp}, v.Id_product);
}
}
}
}
Can you update any other resources with the application?
Helllo.
I'm getting a list of products to make an erp connection. I need to update stock of variation.
i can list all products, but when i try to update variation with new stock, it says WaitingForActivation (see attached file). i tried a lot of examples.
When i update using Postman works!!
But those examples does not work
var res = Task.Run(async() => await wc.Product.Variations.UpdateWithNull(v.Id_variation, v.Id_product, new { stock_quantity = new_stock}));
updateProduct(wc,v.Id_product,v.Id_variation, stock_iggnova);
var results = await wc.Product.Variations.Update(v.Id_variation, new Variation { stock_quantity = stock_iggnova }, v.Id_product);
Neither this
Thanks.