AdvancedCustomFields / AdvancedCustomFields/acf
REST API 5.11 Support For WooCommerce Products, Orders, Coupons
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 945
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
Add ability to customize supported routes, object_type, and object_child_type in the ACF_Rest_Request.
Currently, there is no out-of-the-box support for updating custom fields via the REST API on WooCommerce custom post types.
Would be good if these are either supported out of the box or have the ability to update the ACF_Rest_Request supported routes as well as object_type and object_child_type via filters so that we can do this ourselves.
Example code that I've whipped up that adds support via filters.
Line 145: add ability to update supported routes
$this->supported_routes = apply_filters('acf/rest_request_supported_routes', $this->supported_routes);
Line 206: add ability to update object_type and object_sub_type
$this->object_type = apply_filters('acf/rest_request_object_type', $this->object_type, $base, $child_base);
$this->object_sub_type = apply_filters('acf/rest_request_child_object_type', $this->object_sub_type, $base, $child_base);
Example filters to add support for WooCommerce Products
add_filter('acf/rest_request_supported_routes', function($supported_routes) {
$supported_routes[] = '/wc/v3/(?P<rest_base>products)/(?P<id>[\d]+)';
return $supported_routes;
});
add_filter('acf/rest_child_object_type', function($object_type, $base) {
if(!$object_type && $base === 'products') {
return 'product';
}
return $object_type;
}, 2, 10);
add_filter('acf/rest_request_object_type', function($object_type, $base) {
if(!$object_type && $base === 'products') {
return 'product';
}
return $object_type;
}, 2, 10);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating ACF_Rest_Request and reviewing the logic around the referenced lines 145 and 206, including how REST routes and object types are determined. Compare that behavior with WooCommerce product, order, and coupon routes; done means those values can be customized through filters or are supported out of the box as specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100