Comments (6)
I have been away awhile on this project. I will have to take a look and see where that functionality is at.
from woocommerce-json-api.
I will be back with the JSON API in about a week. As far as I recall, there is some filter support for some things.
Is this what you are looking for:
if ( isset( $params['model_filters'] ) && is_array($params['model_filters']) ) {
JSONAPIHelpers::debug( "Model Filters are Present" );
JSONAPIHelpers::debug( var_export($params['model_filters'],true) );
foreach ( $params['model_filters'] as $filter_text=>$filter ) {
foreach ($filter as $key=>&$value) {
$value['name'] = substr($wpdb->prepare("%s",$value['name']),1,strlen($value['name']));
}
$callback = function ($table) use ($filter) {
return array_merge($table,$filter);
};
JSONAPIHelpers::debug( "Adding filter: " . $filter_text );
add_filter($filter_text, $callback );
}
} else {
JSONAPIHelpers::debug( "No Model Filters Present" );
}
It's in the main JSON API class. It allows you to ensure your filters are registered and therefore checked during request.
https://github.com/jasonknight/woocommerce-json-api/blob/master/tests/set_product_variation.php
Shows using it.
from woocommerce-json-api.
Thanks so much for continuing with this. I will give the above a go. I will let you know feedback asap.
from woocommerce-json-api.
I am not sure it is answering your specific situation, this model filter is used to tell the api to load a custom attribute, but that doesn't mean 3rd party plugins will necessarily know about it.
There are significant plans for expansion. Including the ability to pass logic to the call back in the form of a many language implemented in pure PHP. If you look inside the WCAPI models, you may find that there are some filters running, or you could add them, or add the ability to specify filters to run. For instance, what if you added the model_filters and after_load_filters array with a series of strings to call apply_filters with that attribute? Then all you would need to do is add in some logic at attribute load and before save to call model_filters etc. Which is somewhere in the guts already.
from woocommerce-json-api.
Unfortunately, I realize the API is rather daunting at first glance, it's a monstrous effort to compensate for some small issues I have with the internal WooCom API. It's been awhile since I worked on it(mainly it does everything I need so far) so even I am not sure what the hell it does anymore.
from woocommerce-json-api.
Can you give me a specific use case so that I can come up with something? Do you want to filter the whole product, i.e. get_product, or do you want to filter independent attributes? What filters are called? Are you using woocommerce attribute filters? The API generally circumvents WooCommerce entirely.
from woocommerce-json-api.
Related Issues (20)
- Issue With get_products HOT 1
- Issues With set_product HOT 1
- Support for delete product HOT 1
- Deleting Product Variation HOT 1
- How can I set featured image when set_products? HOT 1
- URL HOT 1
- How can i use this plugin?
- How can i use this plugin? HOT 2
- Product attribute 'attributes' is represented as array, map or string HOT 5
- invalid api user HOT 1
- Feature request: get_* include last modified time HOT 4
- Var not set HOT 2
- Issues With get_orders() and get_products
- Question regarding target url HOT 3
- Is it possible to test the plugin using cUrl method? HOT 4
- Plugin can not be activated after installation HOT 2
- TypeError HOT 2
- Create a Product and add it to a WooThemes Subscription HOT 1
- package management HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from woocommerce-json-api.