Open lucasaacosta1995 opened 2 years ago
hi!
when querying a product, it will always bring you all the information of the product as an object, what you can do is that when you get this information, go to the property that you require for example:
$product = $this->woocommerce->get('products/.$id_product');
get the product type: $product->type;
get the stock of the product: $product->stock_quantity;
but if you need to use the sku instead of the product id, this type of query will return the information as an array of objects, for instance
$product = $this->woocommerce->get('products', array('sku'=>$sku));
get the product type: $product[0]->type;
get the stock of the product: $product[0]->stock_quantity;
there is something weird in how woocommerce builds its api.
I hope it helps.
Hi, I can't specify which fields I want to bring.
I cannot specify which fields I want to bring. I use the following to search by sku, $this->woocommerce->get('products', array('sku'=>$sku));, but I only want to bring one or x fields, not all fields, could something be done with that?
Greetings.