Last active
April 8, 2020 18:28
-
-
Save acafourek/bd7af622ada13a0bb436a72b0a1e7276 to your computer and use it in GitHub Desktop.
Add modified to list of acceptable options for orderby param for the WooCommerce API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ * | |
Add modified to list of acceptable options for orderby param | |
Allows you to fetch orders at /wp-json/wc/v3/orders/?orderby=modified&order=desc|asc | |
*/ | |
add_filter( "rest_shop_order_collection_params", 'air_add_modified_to_param_validation',10); | |
function air_add_modified_to_param_validation($params){ | |
if(isset($params['orderby']) && isset($params['orderby']['enum']) && is_array($params['orderby']['enum'])) | |
$params['orderby']['enum'][] = "modified"; | |
return $params; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment