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
- Custom rest fields not loaded in rest api cpt response
- Retrieve multiple values passed to a single attribute in a shortcode
- How to change date language without changing the entire site language?
- Using Cookie Data For WP_Query Loop
- Why when I instantiate wp_error in a validation method my user registration method stops working?
- Using Font Awesome as post thumbnail
- admin-ajax.php responding with 0
- custom shortcode will not display the wrapped content
- How to prevent those PHP variables from being cached on WordPress?
- How to restrict wp generate attachment metadata() to certain intermediate image sizes
- Setting All Drafts to ‘exclude-from-catalog’ in WooCommerce
- Common abstract class for plugins
- Make the first item as default on Woocommerce product category items list
- Same log message keeps on printing to debug.log file thousand of times
- Is there an equivalent to WP_Error object I can return in the case of a successful REST request?
- dividing sub-categories by parent category – WordPress
- Execute long and heavy processes
- Delete taxonomy and delete all post related it
- Usage of call back function of add_meta_box()
- How to set a template with wp_insert_post
- Seo Friendly Filter URLs
- How to Schedule Cronjobs for start of every month and year
- how can i add class or span tag at sprintf?
- Have Woocommerce show product price if id, when not logged in
- How can I get plugin meta data without knowing the plugin folder?
- calling admin-ajax.php from admin-ajax.php
- How to add a shortcode which runs a .php file for the current post
- How can I change the background color of divs dynamically (depending on an order-status in woocommerce)?
- How to get content on a blank basket/cart page in a custom theme with woocommerce
- Submit remote form to wordpress REST API and save data to custom post type
- Foreach Loop Of Post Types With Nested If Else If Not Completing Process
- In a foreach loop, how can I add a meta value if it doesn’t exist?
- Adding product permalink on admin order page throwing error
- Need help with format of nested array in MySQL
- Get all woocommerce product names with price and show using core php
- How to add delete, approve, spam Links to Comments
- How can i put php code on the wordpress page?
- Problem with conditional woocommerce custom checkout field
- Setting at job with shortcode not working
- How do I prevent a folder from reappearing in my home directory?
- PHP: Why does my code work in index.php but not a widget?
- jQuery doesn’t work in my php snippet
- Accessing Variables Used In a Plugin Using PHPStorm + XDebug
- How to add custom checkout field in user details mail template
- Display Sale Price Before Regular Price (WooCommerce)
- I’m not able to get access $wpdb in my php file in wordpress
- rest_cannot_create_user – Sorry, you are not allowed to create new users. CURL WORDPRESS REST API
- Show button in header when product custom field is not empty
- How to change shipping method title based on cart amount?
- Redirect posts to post editor page based on query string
- Issue with WordPress Plugin Activation Hook and Table Creation
- Too few arguments – wp_login action
- What is different about using admin-ajax.php in an endpoint and just submitting a form from the front end?