Extend REST API to access also hidden order item meta
This commit is contained in:
parent
b2b6bcf2f4
commit
f960cb6b01
|
@ -119,9 +119,10 @@ class WC_API_Orders extends WC_API_Resource {
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
* @param int $id the order ID
|
* @param int $id the order ID
|
||||||
* @param array $fields
|
* @param array $fields
|
||||||
|
* @param string $meta_hideprefix
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_order( $id, $fields = null ) {
|
public function get_order( $id, $fields = null, $meta_hideprefix = '_' ) {
|
||||||
|
|
||||||
// ensure order ID is valid & user has permission to read
|
// ensure order ID is valid & user has permission to read
|
||||||
$id = $this->validate_request( $id, 'shop_order', 'read' );
|
$id = $this->validate_request( $id, 'shop_order', 'read' );
|
||||||
|
@ -202,7 +203,7 @@ class WC_API_Orders extends WC_API_Resource {
|
||||||
|
|
||||||
$item_meta = array();
|
$item_meta = array();
|
||||||
|
|
||||||
foreach ( $meta->get_formatted() as $meta_key => $formatted_meta ) {
|
foreach ( $meta->get_formatted($meta_hideprefix) as $meta_key => $formatted_meta ) {
|
||||||
$item_meta[] = array(
|
$item_meta[] = array(
|
||||||
'key' => $meta_key,
|
'key' => $meta_key,
|
||||||
'label' => $formatted_meta['label'],
|
'label' => $formatted_meta['label'],
|
||||||
|
|
Loading…
Reference in New Issue