Skip to content

Commit b487931

Browse files
committed
Order connection permission check updated
1 parent 678fe49 commit b487931

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

includes/data/connection/class-order-connection-resolver.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@ public function __construct( $source, $args, $context, $info ) {
4848
}
4949

5050
/**
51-
* Confirms the uses has the privileges to query Orders
51+
* Checks if user is authorized to query orders
5252
*
5353
* @return bool
5454
*/
5555
public function should_execute() {
56-
$post_type_obj = get_post_type_object( 'shop_order' );
57-
switch ( true ) {
58-
case current_user_can( $post_type_obj->cap->edit_posts ):
59-
case is_a( $this->source, Customer::class )
60-
&& 'orders' === $this->info->fieldName
61-
&& get_current_user_id() === $this->source->ID:
62-
return true;
63-
default:
64-
return false;
56+
$post_type_obj = get_post_type_object( $this->post_type );
57+
if ( current_user_can( $post_type_obj->cap->edit_posts ) ) {
58+
return true;
6559
}
60+
61+
if ( is_a( $this->source, Customer::class ) ) {
62+
return 'orders' === $this->info->fieldName && get_current_user_id() === $this->source->ID;
63+
}
64+
65+
return false;
6666
}
6767

6868
/**

includes/model/class-order.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ public function __construct( $id ) {
3737
'isPublic',
3838
'id',
3939
'orderId',
40+
'orderNumber',
41+
'date',
42+
'modified',
43+
'datePaid',
44+
'dateCompleted',
45+
'paymentMethodTitle',
46+
'customerNote',
47+
'billing',
48+
'shipping',
49+
'discountTotal',
50+
'discountTax',
51+
'shippingTotal',
52+
'shippingTax',
53+
'cartTax',
54+
'subtotal',
55+
'total',
56+
'totalTax',
57+
'isDownloadPermitted',
58+
'shippingAddressMapUrl',
59+
'needsShippingAddress',
60+
'needsPayment',
61+
'needsProcessing',
62+
'hasDownloadableItem',
63+
'downloadableItems',
4064
);
4165

4266
parent::__construct( $allowed_restricted_fields, 'shop_order', $id );

0 commit comments

Comments
 (0)