Skip to content

Commit 7fafae6

Browse files
committed
chore: Linter compliance met
1 parent 680f3f2 commit 7fafae6

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

includes/data/mutation/class-checkout-mutation.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static function prepare_checkout_args( $input, $context, $info ) {
7373
'ship_to_different_address' => ! empty( $input['shipToDifferentAddress'] ) && ! wc_ship_to_billing_address_only(),
7474
];
7575

76-
$skipped = ['fees'];
76+
$skipped = [ 'fees' ];
7777
foreach ( self::get_checkout_fields() as $fieldset_key => $fieldset ) {
7878
if ( self::maybe_skip_fieldset( $fieldset_key, $data ) ) {
7979
$skipped[] = $fieldset_key;
@@ -100,8 +100,8 @@ public static function prepare_checkout_args( $input, $context, $info ) {
100100
$fees = $input['fees'];
101101
add_action(
102102
'woocommerce_cart_calculate_fees',
103-
function () use ( $fees ) {
104-
foreach( $fees as $fee_input ) {
103+
static function () use ( $fees ) {
104+
foreach ( $fees as $fee_input ) {
105105
if ( empty( $fee_input['name'] ) || empty( $fee_input['amount'] ) ) {
106106
// TODO: Log invalid fee input.
107107
continue;
@@ -113,12 +113,11 @@ function () use ( $fees ) {
113113
isset( $fee_input['taxable'] ) ? $fee_input['taxable'] : false,
114114
isset( $fee_input['taxClass'] ) ? $fee_input['taxClass'] : '',
115115
];
116-
116+
117117
\WC()->cart->add_fee( ...$fee_args );
118118
}
119119
}
120120
);
121-
122121
}
123122

124123
if ( in_array( 'shipping', $skipped, true ) && ( \WC()->cart->needs_shipping_address() || \wc_ship_to_billing_address_only() ) ) {

includes/mutation/class-cart-add-fee.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ public static function mutate_and_get_payload() {
8888
return static function ( $input, AppContext $context, ResolveInfo $info ) {
8989
Cart_Mutation::check_session_token();
9090

91-
// if ( ! current_user_can( 'edit_shop_orders' ) ) {
92-
// throw new UserError( __( 'You do not have the appropriate capabilities to perform this action.', 'wp-graphql-woocommerce' ) );
93-
// }
91+
if ( ! current_user_can( 'edit_shop_orders' ) ) {
92+
throw new UserError( __( 'You do not have the appropriate capabilities to perform this action.', 'wp-graphql-woocommerce' ) );
93+
}
9494

9595
if ( empty( $input['name'] ) ) {
9696
throw new UserError( __( 'No name provided for fee.', 'wp-graphql-woocommerce' ) );

includes/mutation/class-checkout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static function get_input_fields() {
8888
'fees' => [
8989
'type' => [ 'list_of' => 'FeeInput' ],
9090
'description' => __( 'Fees to add to the order.', 'wp-graphql-woocommerce' ),
91-
]
91+
],
9292
];
9393
}
9494

includes/type/object/class-cart-type.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,16 @@ public static function get_cart_fields( $other_fields = [] ) {
241241
},
242242
],
243243
'feeTotal' => [
244-
'type' => 'String',
245-
'description' => __( 'Cart fee total', 'wp-graphql-woocommerce' ),
244+
'type' => 'String',
245+
'description' => __( 'Cart fee total', 'wp-graphql-woocommerce' ),
246246
'deprecationReason' => __( 'Always null', 'wp-graphql-woocommerce' ),
247-
'args' => [
247+
'args' => [
248248
'format' => [
249249
'type' => 'PricingFieldFormatEnum',
250250
'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ),
251251
],
252252
],
253-
'resolve' => static function ( $source, array $args ) {
253+
'resolve' => static function ( $source, array $args ) {
254254
$price = ! is_null( $source->get_fee_total() ) ? $source->get_fee_total() : 0;
255255

256256
if ( isset( $args['format'] ) && 'raw' === $args['format'] ) {
@@ -261,16 +261,16 @@ public static function get_cart_fields( $other_fields = [] ) {
261261
},
262262
],
263263
'feeTax' => [
264-
'type' => 'String',
265-
'description' => __( 'Cart fee tax', 'wp-graphql-woocommerce' ),
264+
'type' => 'String',
265+
'description' => __( 'Cart fee tax', 'wp-graphql-woocommerce' ),
266266
'deprecationReason' => __( 'Always null', 'wp-graphql-woocommerce' ),
267-
'args' => [
267+
'args' => [
268268
'format' => [
269269
'type' => 'PricingFieldFormatEnum',
270270
'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ),
271271
],
272272
],
273-
'resolve' => static function ( $source, array $args ) {
273+
'resolve' => static function ( $source, array $args ) {
274274
$price = ! is_null( $source->get_fee_tax() ) ? $source->get_fee_tax() : 0;
275275

276276
if ( isset( $args['format'] ) && 'raw' === $args['format'] ) {

includes/type/object/class-root-query.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function register_fields() {
3636
'type' => 'Boolean',
3737
'description' => __( 'Should cart totals be recalculated.', 'wp-graphql-woocommerce' ),
3838
],
39-
'fees' => [
39+
'fees' => [
4040
'type' => [ 'list_of' => 'FeeInput' ],
4141
'description' => __( 'Fees to add to the cart.', 'wp-graphql-woocommerce' ),
4242
],
@@ -54,8 +54,8 @@ public static function register_fields() {
5454
$fees = $args['fees'];
5555
add_action(
5656
'woocommerce_cart_calculate_fees',
57-
function () use ( $fees ) {
58-
foreach( $fees as $fee_input ) {
57+
static function () use ( $fees ) {
58+
foreach ( $fees as $fee_input ) {
5959
if ( empty( $fee_input['name'] ) || empty( $fee_input['amount'] ) ) {
6060
// TODO: Log invalid fee input.
6161
continue;
@@ -67,7 +67,7 @@ function () use ( $fees ) {
6767
isset( $fee_input['taxable'] ) ? $fee_input['taxable'] : false,
6868
isset( $fee_input['taxClass'] ) ? $fee_input['taxClass'] : '',
6969
];
70-
70+
7171
\WC()->cart->add_fee( ...$fee_args );
7272
}
7373
}

0 commit comments

Comments
 (0)