Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions includes/admin/class-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function get_fields() {
. ( defined( 'NO_QL_SESSION_HANDLER' ) ? __( ' This setting is disabled. The "NO_QL_SESSION_HANDLER" flag has been triggered with code', 'wp-graphql-woocommerce' ) : '' ),
'type' => 'checkbox',
'value' => defined( 'NO_QL_SESSION_HANDLER' ) ? 'on' : woographql_setting( 'disable_ql_session_handler', 'off' ),
'disabled' => defined( 'NO_QL_SESSION_HANDLER' ) ? true : false,
'disabled' => defined( 'NO_QL_SESSION_HANDLER' ),
],
[
'name' => 'enable_unsupported_product_type',
Expand All @@ -101,7 +101,7 @@ public static function get_fields() {
]
),
'value' => $enable_auth_urls_hardcoded ? $all_urls_checked : woographql_setting( 'enable_authorizing_url_fields', [] ),
'disabled' => $enable_auth_urls_hardcoded ? true : false,
'disabled' => $enable_auth_urls_hardcoded,
'sanitize_callback' => static function( $value ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentionally leaked to prevent merge conflicts with #764

if ( empty( $value ) ) {
return [];
Expand Down
2 changes: 1 addition & 1 deletion includes/connection/class-products.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public static function bypass_get_args_sanitization( $args, $connection_resolver
* @return \WPGraphQL\Data\Connection\PostObjectConnectionResolver
*/
public static function set_ordering_query_args( $resolver, $args ) {
$backward = isset( $args['last'] ) ? true : false;
$backward = isset( $args['last'] );

if ( ! empty( $args['where']['orderby'] ) ) {
$default_fields = [
Expand Down
2 changes: 1 addition & 1 deletion includes/connection/class-wc-terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function register_connections() {
$wc_post_types = WP_GraphQL_WooCommerce::get_post_types();

// Loop through the allowed_taxonomies to register appropriate connections.
foreach ( $allowed_taxonomies as $taxonomy => $tax_object ) {
foreach ( $allowed_taxonomies as $tax_object ) {
foreach ( $wc_post_types as $post_type ) {
if ( 'product' === $post_type ) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ public function get_query() {
* {@inheritDoc}
*/
public function get_ids_from_query() {
$ids = ! empty( $this->query ) ? $this->query : [];

return $ids;
return ! empty( $this->query ) ? $this->query : [];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ public function get_query() {
* @return array
*/
public function get_ids_from_query() {
$ids = ! empty( $this->query ) ? $this->query : [];

return $ids;
return ! empty( $this->query ) ? $this->query : [];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function get_query() {
}//end switch

$items = [];
foreach ( $this->source->get_items( $type ) as $id => $item ) {
foreach ( $this->source->get_items( $type ) as $item ) {
$items[] = $item;
}

Expand Down
3 changes: 1 addition & 2 deletions includes/data/mutation/class-order-mutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ protected static function get_order_item_keys( $type ) {
* @param array $item_keys Order item keys.
* @param string $type Order item type slug.
*/
$item_keys = apply_filters( 'woographql_get_order_item_keys', [], $type );
return $item_keys;
return apply_filters( 'woographql_get_order_item_keys', [], $type );
}//end switch
}

Expand Down
6 changes: 3 additions & 3 deletions includes/model/class-order.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ protected function owner_matches_current_user() {
}

// If customer ID matches current user, return true.
return absint( $customer_id ) === absint( $this->current_user->ID ) ? true : false;
return absint( $customer_id ) === absint( $this->current_user->ID );
}

/**
Expand Down Expand Up @@ -327,7 +327,7 @@ public function guest_order_customer_matches_current_user() {
}

// If customer email matches current user, return true.
return $customer_email === $session_customer->get_billing_email() ? true : false;
return $customer_email === $session_customer->get_billing_email();
}

/**
Expand All @@ -336,7 +336,7 @@ public function guest_order_customer_matches_current_user() {
* @return bool
*/
public function is_private() {
return wc_is_order_status( 'wc-' . $this->data->get_status() ) ? false : true;
return ! wc_is_order_status( 'wc-' . $this->data->get_status() );
}

/**
Expand Down
4 changes: 1 addition & 3 deletions includes/mutation/class-cart-add-fee.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static function register_mutation() {
* @return array
*/
public static function get_input_fields() {
$input_fields = [
return [
'name' => [
'type' => [ 'non_null' => 'String' ],
'description' => __( 'Unique name for the fee.', 'wp-graphql-woocommerce' ),
Expand All @@ -60,8 +60,6 @@ public static function get_input_fields() {
'description' => __( 'The tax class for the fee if taxable.', 'wp-graphql-woocommerce' ),
],
];

return $input_fields;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions includes/mutation/class-cart-add-item.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ public static function get_output_fields() {
'cartItem' => [
'type' => 'CartItem',
'resolve' => static function ( $payload ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentionally leaked to prevent merge conflicts with #764

$item = \WC()->cart->get_cart_item( $payload['key'] );

return $item;
return \WC()->cart->get_cart_item( $payload['key'] );
},
],
'cart' => Cart_Mutation::get_cart_field( true ),
Expand Down
4 changes: 1 addition & 3 deletions includes/mutation/class-order-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function register_mutation() {
* @return array
*/
public static function get_input_fields() {
$input_fields = [
return [
'parentId' => [
'type' => 'Int',
'description' => __( 'Parent order ID.', 'wp-graphql-woocommerce' ),
Expand Down Expand Up @@ -110,8 +110,6 @@ public static function get_input_fields() {
'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'wp-graphql-woocommerce' ),
],
];

return $input_fields;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions includes/mutation/class-order-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ public static function mutate_and_get_payload() {
// Actions for after the order is saved.
if ( true === $input['isPaid'] ) {
$order->payment_complete(
! empty( $input['transactionId'] ) ?
$input['transactionId']
! empty( $input['transactionId'] )
? $input['transactionId']
: ''
);
}
Expand Down
6 changes: 2 additions & 4 deletions includes/type/object/class-customer-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,12 @@ public static function register() {
'description' => __( 'Customer\'s stored payment tokens.', 'wp-graphql-woocommerce' ),
'resolve' => static function( $source ) {
if ( get_current_user_id() === $source->ID ) {
$tokens = array_filter(
return array_filter(
array_values( \WC_Payment_Tokens::get_customer_tokens( $source->ID ) ),
static function ( $token ) {
return 'CC' === $token->get_type();
}
);
return $tokens;
}

throw new UserError( __( 'Not authorized to view this user\'s payment methods.', 'wp-graphql-woocommerce' ) );
Expand All @@ -254,13 +253,12 @@ static function ( $token ) {
'description' => __( 'Customer\'s stored payment tokens.', 'wp-graphql-woocommerce' ),
'resolve' => static function( $source ) {
if ( get_current_user_id() === $source->ID ) {
$tokens = array_filter(
return array_filter(
array_values( \WC_Payment_Tokens::get_customer_tokens( $source->ID ) ),
static function ( $token ) {
return 'eCheck' === $token->get_type();
}
);
return $tokens;
}

throw new UserError( __( 'Not authorized to view this user\'s payment methods.', 'wp-graphql-woocommerce' ) );
Expand Down
2 changes: 1 addition & 1 deletion includes/type/object/class-meta-data-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static function get_metadata_field_definition() {
],
'resolve' => static function( $source, array $args ) {
// Set unique flag.
$single = ! empty( $args['multiple'] ) ? false : true;
$single = empty( $args['multiple'] );

// Check "key" argument and format meta_data objects.
if ( ! empty( $args['key'] ) && $source->meta_exists( $args['key'] ) ) {
Expand Down
4 changes: 1 addition & 3 deletions includes/type/object/class-root-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,7 @@ public static function register_fields() {
throw new UserError( sprintf( __( 'No product exists with the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $product_id ) );
}

$product = Factory::resolve_crud_object( $product_id, $context );

return $product;
return Factory::resolve_crud_object( $product_id, $context );
},
]
);
Expand Down
4 changes: 1 addition & 3 deletions includes/utils/class-transfer-session-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ public function get_client_session_id() {
return $client_session_id;
}

$client_session_id = '';

return $client_session_id;
return '';
}
}