laravel-woocommerce icon indicating copy to clipboard operation
laravel-woocommerce copied to clipboard

Total Products

Open piloufaces opened this issue 5 years ago • 1 comments

Hi,

How receives the total of products ? (curl https://example.com/wc-api/v3/products/count )

Thanks

piloufaces avatar Apr 27 '20 20:04 piloufaces

Hello @piloufaces

Thanks for your comment. I think wc-api/v3/products/count isn't a valid endpoint for the latest rest-api version. Please follow the latest official http://woocommerce.github.io/woocommerce-rest-api-docs doc.

Don't worry you can do it by this package. You can do it in two ways

The first one direct call count method.

$totalResult = Product::count();

The second one using the WooCommerce Facade. In this way, you must request an endpoint.

$products = Product::all();
$totalResults = WooCommerce::countResults()

Note: Make sure the package version is 2.4 or greater. Always use the latest version.

Best regards, Md Abu Ahsan Basir

maab16 avatar Apr 28 '20 08:04 maab16