Title: Retrieving Models &#8211; Building Queries
Last modified: June 10, 2024

---

# Retrieving Models – Building Queries

 *  Resolved [mattap](https://wordpress.org/support/users/mattap/)
 * (@mattap)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/retrieving-models-building-queries/)
 * Hey!
 * I’m trying to use the php models to retreive products, purchases, checkouts, 
   subscriptions, etc.
 * The models ‘all’ method seems to work perfectly fine. However, when attempting
   to query using the ‘where’ method the result is still every object (i.e. it’s
   not queried and filtered).
 * The only query that does in fact work as far as I can see is the example provided
   in your documentation (product – archived – true/false).
 * I can’t determine what I’m doing wrong if I am.
 * I’ve considered that potentially not everything in the object is querable so 
   I checked your REST API reference and used only the query params set out (e.g.
   checkout – cutomer_ids). In that example I tried both customer and customer_ids
   as the key, both of which didn’t filter the output.
 * I know I can filter the output after the fact to get what I need, but it would
   be great if I could get this working so I don’t have to retreive all objects 
   as this could be quite a large number when, after it’s filtered, might only result
   in 1 or 2 entries.
 * Thanks
   Matt

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [mattap](https://wordpress.org/support/users/mattap/)
 * (@mattap)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/retrieving-models-building-queries/#post-17814293)
 * did some digging into the RequestService class and saw the api url that’s created
   and immediately saw what I was missing.
 * I was trying ‘customer’ and ‘customer_ids’ as the key. Meaning I was missing 
   off the [] at the end of the customer_ids.
 * Long story short, I tried ‘customer_ids[]’ as the key and it worked as expected.
 *  Plugin Support [Ivan C.](https://wordpress.org/support/users/ivanbsf/)
 * (@ivanbsf)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/retrieving-models-building-queries/#post-17816237)
 * Hello [@mattap](https://wordpress.org/support/users/mattap/)
 * It’s fantastic to hear that you have found a solution!
 * Also, If you have any questions or issues, please feel free to contact us through
   the contact page on the SureCart website.
 * Best,

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Retrieving Models – Building Queries’ is closed to new replies.

 * ![](https://ps.w.org/surecart/assets/icon-256x256.gif?rev=3285224)
 * [SureCart - Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments](https://wordpress.org/plugins/surecart/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/surecart/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/surecart/)
 * [Active Topics](https://wordpress.org/support/plugin/surecart/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/surecart/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/surecart/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Ivan C.](https://wordpress.org/support/users/ivanbsf/)
 * Last activity: [1 year, 11 months ago](https://wordpress.org/support/topic/retrieving-models-building-queries/#post-17816237)
 * Status: resolved