Open S-Amin opened 8 years ago
Looking for the same...
Hi @S-Amin ,
I have managed to filter products by category like this:
$client->products->get( null, array( 'filter[category]' => category_slug_here, 'filter[limit]' => '-1' );
Use limit -1 in order to get all products.
Hi @apokyro for me doesn't work. Could you upload your full code?
Hi @rito-zainmax , check below.
$options = array(
"debug" => false,
"return_as_array" => true,
"validate_url" => false,
"timeout" => 30,
"ssl_verify" => false,
);
try {
$client = new WC_API_Client(
"http://your-store-url.com",
"ck_enter_your_consumer_key",
"cs_enter_your_consumer_secret",
$options
);
print_r($client->products->get( null, array(
"filter[category]" => "CATEGORY_SLUG_HERE",
"filter[limit]" => "-1" // -1 to display all products
)
));
} catch ( WC_API_Client_Exception $e ) {
echo $e->getMessage() . PHP_EOL;
echo $e->getCode() . PHP_EOL;
if ( $e instanceof WC_API_Client_HTTP_Exception ) {
print_r( $e->get_request() );
print_r( $e->get_response() );
}
}
Hey there has been there post in first page of issues that hasn't been solved. Is there any body to solve this??? It's really important. at least show us how to use WP_Query filter in your library