Skip to content

Commit 0a54ce9

Browse files
authored
feat: Auth no longer needed for the raw order totals (#700)
1 parent 30b34aa commit 0a54ce9

File tree

1 file changed

+24
-48
lines changed

1 file changed

+24
-48
lines changed

includes/model/class-order.php

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -219,82 +219,58 @@ protected function init() {
219219
$price = ! empty( $this->wc_data->get_discount_total() ) ? $this->wc_data->get_discount_total() : 0;
220220
return \wc_graphql_price( $price, [ 'currency' => $this->wc_data->get_currency() ] );
221221
},
222-
'discountTotalRaw' => [
223-
'callback' => function() {
224-
return ! empty( $this->wc_data->get_discount_total() ) ? $this->wc_data->get_discount_total() : 0;
225-
},
226-
'capability' => $this->post_type_object->cap->edit_posts,
227-
],
222+
'discountTotalRaw' => function() {
223+
return ! empty( $this->wc_data->get_discount_total() ) ? $this->wc_data->get_discount_total() : 0;
224+
},
228225
'discountTax' => function() {
229226
$price = ! empty( $this->wc_data->get_discount_tax() ) ? $this->wc_data->get_discount_tax() : 0;
230227
return \wc_graphql_price( $price, [ 'currency' => $this->wc_data->get_currency() ] );
231228
},
232-
'discountTaxRaw' => [
233-
'callback' => function() {
234-
return ! empty( $this->wc_data->get_discount_tax() ) ? $this->wc_data->get_discount_tax() : 0;
235-
},
236-
'capability' => $this->post_type_object->cap->edit_posts,
237-
],
229+
'discountTaxRaw' => function() {
230+
return ! empty( $this->wc_data->get_discount_tax() ) ? $this->wc_data->get_discount_tax() : 0;
231+
},
238232
'shippingTotal' => function() {
239233
$price = ! empty( $this->wc_data->get_shipping_total() ) ? $this->wc_data->get_shipping_total() : 0;
240234
return \wc_graphql_price( $price, [ 'currency' => $this->wc_data->get_currency() ] );
241235
},
242-
'shippingTotalRaw' => [
243-
'callback' => function() {
244-
return ! empty( $this->wc_data->get_shipping_total() ) ? $this->wc_data->get_shipping_total() : 0;
245-
},
246-
'capability' => $this->post_type_object->cap->edit_posts,
247-
],
236+
'shippingTotalRaw' => function() {
237+
return ! empty( $this->wc_data->get_shipping_total() ) ? $this->wc_data->get_shipping_total() : 0;
238+
},
248239
'shippingTax' => function() {
249240
$price = ! empty( $this->wc_data->get_shipping_tax() ) ? $this->wc_data->get_shipping_tax() : 0;
250241
return \wc_graphql_price( $price, [ 'currency' => $this->wc_data->get_currency() ] );
251242
},
252-
'shippingTaxRaw' => [
253-
'callback' => function() {
254-
return ! empty( $this->wc_data->get_shipping_tax() ) ? $this->wc_data->get_shipping_tax() : 0;
255-
},
256-
'capability' => $this->post_type_object->cap->edit_posts,
257-
],
243+
'shippingTaxRaw' => function() {
244+
return ! empty( $this->wc_data->get_shipping_tax() ) ? $this->wc_data->get_shipping_tax() : 0;
245+
},
258246
'cartTax' => function() {
259247
$price = ! empty( $this->wc_data->get_cart_tax() ) ? $this->wc_data->get_cart_tax() : 0;
260248
return \wc_graphql_price( $price, [ 'currency' => $this->wc_data->get_currency() ] );
261249
},
262-
'cartTaxRaw' => [
263-
'callback' => function() {
264-
return ! empty( $this->wc_data->get_cart_tax() ) ? $this->wc_data->get_cart_tax() : 0;
265-
},
266-
'capability' => $this->post_type_object->cap->edit_posts,
267-
],
250+
'cartTaxRaw' => function() {
251+
return ! empty( $this->wc_data->get_cart_tax() ) ? $this->wc_data->get_cart_tax() : 0;
252+
},
268253
'total' => function() {
269254
$price = ! empty( $this->wc_data->get_total() ) ? $this->wc_data->get_total() : 0;
270255
return \wc_graphql_price( $price, [ 'currency' => $this->wc_data->get_currency() ] );
271256
},
272-
'totalRaw' => [
273-
'callback' => function() {
274-
return ! empty( $this->wc_data->get_total() ) ? $this->wc_data->get_total() : 0;
275-
},
276-
'capability' => $this->post_type_object->cap->edit_posts,
277-
],
257+
'totalRaw' => function() {
258+
return ! empty( $this->wc_data->get_total() ) ? $this->wc_data->get_total() : 0;
259+
},
278260
'totalTax' => function() {
279261
$price = ! empty( $this->wc_data->get_total_tax() ) ? $this->wc_data->get_total_tax() : 0;
280262
return \wc_graphql_price( $price, [ 'currency' => $this->wc_data->get_currency() ] );
281263
},
282-
'totalTaxRaw' => [
283-
'callback' => function() {
284-
return ! empty( $this->wc_data->get_total_tax() ) ? $this->wc_data->get_total_tax() : 0;
285-
},
286-
'capability' => $this->post_type_object->cap->edit_posts,
287-
],
264+
'totalTaxRaw' => function() {
265+
return ! empty( $this->wc_data->get_total_tax() ) ? $this->wc_data->get_total_tax() : 0;
266+
},
288267
'subtotal' => function() {
289268
$price = ! empty( $this->wc_data->get_subtotal() ) ? $this->wc_data->get_subtotal() : null;
290269
return \wc_graphql_price( $price, [ 'currency' => $this->wc_data->get_currency() ] );
291270
},
292-
'subtotalRaw' => [
293-
'callback' => function() {
294-
return ! empty( $this->wc_data->get_subtotal() ) ? $this->wc_data->get_subtotal() : 0;
295-
},
296-
'capability' => $this->post_type_object->cap->edit_posts,
297-
],
271+
'subtotalRaw' => function() {
272+
return ! empty( $this->wc_data->get_subtotal() ) ? $this->wc_data->get_subtotal() : 0;
273+
},
298274
'orderNumber' => function() {
299275
return ! empty( $this->wc_data->get_order_number() ) ? $this->wc_data->get_order_number() : null;
300276
},

0 commit comments

Comments
 (0)