Jak uzyskać produkt według kategorii w WooCommerce za pomocą API REST
/wp-json/wc/v3/products?category=ID
Salo Hopeless
/wp-json/wc/v3/products?category=ID
$page = 1;
$products = [];
$all_products = [];
do{
try {
$products = $wc->get('products',array('per_page' => 100, 'page' => $page));
}catch(HttpClientException $e){
die("Can't get products: $e");
}
$all_products = array_merge($all_products,$products);
$page++;
} while (count($products) > 0);
# with Python
page = 0
While True:
products = wcapi.get('products', params={'per_page': 100}).json()
print(products)
# do stuff with **products**
if len(products) == 0: # no more products
break
page = page + 1