• Resolved hcordero1218

    (@hcordero1218)


    Hello! I am making a php script with the Woocommerce API that through the SKU I want to filter the products in the first instance it works and brings me the first 100 products.

    $products = $woocommerce->get(‘products’,array(‘per_page’ => 100,’page’ =>1, ‘sku’ => $param_sku));

    Then I want to see the next 100 products on page 2 but it doesn’t work, this code used to work very well but today it gives me this error. I have 338 products page 1 and 4 work well but 2 and 3 give me an error.

    $products = $woocommerce->get(‘products’,array(‘per_page’ => 100,’page’ =>2, ‘sku’ => $param_sku));

    Fatal error: Uncaught Automattic\WooCommerce\HttpClient\HttpClientException: JSON ERROR: Syntax error in /home/customer/www/miweb.com/public_html/rest/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php:378 Stack trace: #0 /home/customer/www/miweb.com/public_html/rest/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php(422): Automattic\WooCommerce\HttpClient\HttpClient->processResponse() #1 /home/customer/www/miweb.com/public_html/rest/vendor/automattic/woocommerce/src/WooCommerce/Client.php(82): Automattic\WooCommerce\HttpClient\HttpClient->request(‘products’, ‘GET’, Array, Array) #2 /home/customer/www/miweb.com/public_html/rest/index2.php(33): Automattic\WooCommerce\Client->get(‘products’, Array) #3 {main} thrown in /home/customer/www/miweb.com/public_html/rest/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php on line 378

Viewing 1 replies (of 1 total)
  • Hi @hcordero1218

    Thanks for reaching out!

    I understand that you are building a PHP script with the WooCommerce API to filter the products on your site, however, you are receiving the fatal error logs above.

    This is a bit of a complicated topic that would need some customization to address. Unfortunately, custom coding is not something we can assist with directly. However, I’ll keep this thread open for a bit to see if anyone from the community can lend a hand.

    If you have any other questions related to development or custom coding, don’t hesitate to reach out to some of the great resources we have available for support. The WooCommerce community is filled with talented open-source developers, and many of them are active on the channels listed below:

    Hope this helps!

Viewing 1 replies (of 1 total)
  • The topic ‘JSON Error try get products API’ is closed to new replies.