First of all it’s not clear why getting all products in one go seems to not be an option if you have control on the API
you can add a custom endpoint and write your query to get all the products ( maybe in status “publish”)
something like :
global $wpdb;
$Q="SELECT * FROM ".$wpdb->prefix."posts WHERE post_type="product" AND post_status="publish"";
$completeProductList = $wpdb->get_results($Q);
return new WP_REST_Response($completeProductList, 200);
should work.
Second : without testing your function I think that
if (count($completeProductList < 1))
should be if (count($completeProductList) < 1)
your code is counting a boolean instead of a Countable interface, maybe it’s not the final solution but this looks like a bug
Related Posts:
- Use wc_enqueue_js only on specific pages – nested add_action
- Problem with Woocommerce REST API Authentication
- wordpress custom endpoint multiple params
- Continue execution after WP REST API response
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- woocommerce subscriptions – get expiration date [closed]
- Automated Cart Update With Alert Box Each Time
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- Woocommerce hook run after an Order been created through REST API
- what is the best practice to add new field to an api route
- Woocommerce api: create product with images – bad request
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- How to auto fetch customer details in Woocommerce in checkout page
- I want to add custom add to cart link [closed]
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- Building a REST API for your web app exposes primary keys of DB records?
- Change product_base programmatically
- Can a plugin redirect product page based on IF condition?
- Cant register rest routs from class instance
- WC_Customer delete function returns error
- Validate and Sanitize WP REST API Request using WP JSON Schema?
- WordPress WP_Query without query GET parameters
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- custom post type with role Vendor
- Woocommerce custom Plugin in wordpress [closed]
- no_rest_route error on custom routes
- Add a custom WooCommerce settings tab with sections
- Flatten Responses returned via WP REST API via WP_Error for obfuscation
- Payment field disappears on custom Paypal plugin
- I am having errors with checkout on wordpress
- product_type_options get saved value [closed]
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- WooCommerce REST API AJAX Auth – 401 response
- How to import woocommerce custom fields data into another site?
- get Woocommerce product format json for WP_Query
- How do I remove an action hook inside a class that is called by another class?
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- How keep woocommerce users separeted in multisite install and keep admins on network
- Properly process a custom WP REST API request (Authenticate, Authorize + Validate)?
- Custom field fetch error on woocommerce pdf invoice
- How to pass and validate nonce in custom REST routes
- Query posts by custom taxonomy slug in WP REST API?
- oneOf JSON Schema validation not properly working for custom post meta value?
- Authenticate + Authorize WP REST API request before built-in WP JSON Schema Payload Validation?
- Woocommerce Convert existing order to the cart
- WordPress REST API – Custom field not added to pages
- How to change product SKU’s in bulk with a plugin
- Application password header not checked in REST API
- Woocommerce Payment Method Change
- Custom rest fields not loaded in rest api cpt response
- How to add a second ‘place order’ button in WooCommerce [closed]
- Instantiate class to be available to all plugin functions
- Common abstract class for plugins
- How to filter posts by post format “standard” from wp-json api?
- How to test nonce with AJAX – Plugin development
- What does $wpdb->get_row return?
- Change the URL of an image from wp_get_attachment_image_src except in the frontpage
- How do I display a user’s previous orders as a select box option on a product?
- How do you add customer capability after Woocommerce purchase?
- Setting up 2 SMTP accounts: 1 for wordpress and 1 for woocommerce
- Change sign up fee in cart for subscription products WooCommerce
- How can I use wp_query to show all product data using just the products ID?
- WP add_action factory
- wp_loaded hook block script enquequing
- write custom woocommerce templates and forms
- Why is the post meta[] empty when I make a call to the wordpress rest api?
- combine Code 1 with Code 2
- WooCommerce – Reset quantity input field when variation changes
- WP nonce invalid
- get current product name in functions.php
- Get stock by custom meta field on all Woocommerce variable products
- Make the first item as default on Woocommerce product category items list
- Custom Text in WooCommerce Order Processing Email Based on Products
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- Set a condition based on WooCommerce checkout city field while placing order
- Get WooCommerce product details and transfer them to a custom DB table
- WordPress 5 WP REST routes – No errors
- Same log message keeps on printing to debug.log file thousand of times
- tracking number field in Woocommerce order [closed]
- Is there an equivalent to WP_Error object I can return in the case of a successful REST request?
- WooCommerce Related Products by Attribute
- Adding Default Settings to Theme My Login plugin
- Image as Sales Badge
- Custom filter in admin edit custom post type responding with invalid post type?
- WordPress Scheduled Event Request Blocking
- How can i upload images in an admin page?
- Append HTML Using Shortcode
- Delete a WordPress transient from a shortcode on Page/Post update
- WooCommerce – Email admin with new user details
- Plugin CSS not enqueing
- Create onClick Event to Re-load a Widget
- Swapping wp_dropdown_categories function with wp_category_checklist
- Automatically remove a canceled order in Woocommerce
- Accessing the database from a plugin outside of action hooks
- Adding subdomain to home_url for “add_menu_page”
- How to show phpinfo() only in a new tab?
- How to find error in my code when the error message is pointing to WP core file?
- How to select the contents in the text view textrea in wp_editor?
- Call global variable array() in woocommerce child/template
- Remove price from Woocommerce variable product dropdown menu