diff --git a/access-functions.php b/access-functions.php index 23b11059e..ffbd6c7ec 100644 --- a/access-functions.php +++ b/access-functions.php @@ -89,3 +89,81 @@ function wc_graphql_get_order_statuses() { } return $order_statuses; } + +/** + * Format the price with a currency symbol. + * + * @param float $price Raw price. + * @param array $args Arguments to format a price { + * Array of arguments. + * Defaults to empty array. + * + * @type string $currency Currency code. + * Defaults to empty string (Use the result from get_woocommerce_currency()). + * @type string $decimal_separator Decimal separator. + * Defaults the result of wc_get_price_decimal_separator(). + * @type string $thousand_separator Thousand separator. + * Defaults the result of wc_get_price_thousand_separator(). + * @type string $decimals Number of decimals. + * Defaults the result of wc_get_price_decimals(). + * @type string $price_format Price format depending on the currency position. + * Defaults the result of get_woocommerce_price_format(). + * } + * @return string + */ +function wc_graphql_price( $price, $args = array() ) { + $args = apply_filters( + 'wc_price_args', + wp_parse_args( + $args, + array( + 'currency' => '', + 'decimal_separator' => wc_get_price_decimal_separator(), + 'thousand_separator' => wc_get_price_thousand_separator(), + 'decimals' => wc_get_price_decimals(), + 'price_format' => get_woocommerce_price_format(), + ) + ) + ); + + $unformatted_price = $price; + $negative = $price < 0; + $price = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) ); + $price = apply_filters( 'formatted_woocommerce_price', number_format( $price, $args['decimals'], $args['decimal_separator'], $args['thousand_separator'] ), $price, $args['decimals'], $args['decimal_separator'], $args['thousand_separator'] ); + + if ( apply_filters( 'woocommerce_price_trim_zeros', false ) && $args['decimals'] > 0 ) { + $price = wc_trim_zeros( $price ); + } + + $symbol = html_entity_decode( get_woocommerce_currency_symbol( $args['currency'] ) ); + $return = ( $negative ? '-' : '' ) . sprintf( $args['price_format'], $symbol, $price ); + + /** + * Filters the string of price markup. + * + * @param string $return Price HTML markup. + * @param string $price Formatted price. + * @param array $args Pass on the args. + * @param float $unformatted_price Price as float to allow plugins custom formatting. Since 3.2.0. + */ + return apply_filters( 'wc_graphql_price', $return, $price, $args, $unformatted_price, $symbol ); +} + +/** + * Format a price range for display. + * + * @param string $from Price from. + * @param string $to Price to. + * @return string + */ +function wc_graphql_price_range( $from, $to ) { + $price = sprintf( + /* translators: 1: price from 2: price to */ + _x( '%1$s %2$s %3$s', 'Price range: from-to', 'wp-graphql-woocommerce' ), + is_numeric( $from ) ? wc_graphql_price( $from ) : $from, + apply_filters( 'graphql_format_price_range_separator', '-', $from, $to ), + is_numeric( $to ) ? wc_graphql_price( $to ) : $to + ); + + return apply_filters( 'graphql_format_price_range', $price, $from, $to ); +} diff --git a/includes/class-actions.php b/includes/class-actions.php index f3ae8991d..cf1f36624 100644 --- a/includes/class-actions.php +++ b/includes/class-actions.php @@ -23,6 +23,7 @@ use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Tax_Status; use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\WC_Connection_Orderby_Enum; use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Tax_Rate_Connection_Orderby_Enum; +use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Pricing_Field_Format; use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Customer_Address_Input; use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Product_Attribute_Input; use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\WC_Connection_Orderby_Input; @@ -103,6 +104,7 @@ public static function graphql_register_types() { Tax_Status::register(); WC_Connection_Orderby_Enum::register(); Tax_Rate_Connection_Orderby_Enum::register(); + Pricing_Field_Format::register(); // InputObjects. Customer_Address_Input::register(); diff --git a/includes/model/class-order.php b/includes/model/class-order.php index 86711484b..248ed57e9 100644 --- a/includes/model/class-order.php +++ b/includes/model/class-order.php @@ -96,29 +96,85 @@ protected function init() { return ! empty( $this->data->get_date_paid() ) ? $this->data->get_date_paid() : null; }, 'discountTotal' => function() { - return ! empty( $this->data->get_discount_total() ) ? $this->data->get_discount_total() : 0; - }, + $price = ! empty( $this->data->get_discount_total() ) ? $this->data->get_discount_total() : 0; + return \wc_graphql_price( $price, array( 'currency' => $this->data->get_currency() ) ); + }, + 'discountTotalRaw' => array( + 'callback' => function() { + return ! empty( $this->data->get_discount_total() ) ? $this->data->get_discount_total() : 0; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'discountTax' => function() { - return ! empty( $this->data->get_discount_tax() ) ? $this->data->get_discount_tax() : 0; - }, + $price = ! empty( $this->data->get_discount_tax() ) ? $this->data->get_discount_tax() : 0; + return \wc_graphql_price( $price, array( 'currency' => $this->data->get_currency() ) ); + }, + 'discountTaxRaw' => array( + 'callback' => function() { + return ! empty( $this->data->get_discount_tax() ) ? $this->data->get_discount_tax() : 0; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'shippingTotal' => function() { - return ! empty( $this->data->get_shipping_total() ) ? $this->data->get_shipping_total() : 0; - }, + $price = ! empty( $this->data->get_shipping_total() ) ? $this->data->get_shipping_total() : 0; + return \wc_graphql_price( $price, array( 'currency' => $this->data->get_currency() ) ); + }, + 'shippingTotalRaw' => array( + 'callback' => function() { + return ! empty( $this->data->get_shipping_total() ) ? $this->data->get_shipping_total() : 0; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'shippingTax' => function() { - return ! empty( $this->data->get_shipping_tax() ) ? $this->data->get_shipping_tax() : 0; - }, + $price = ! empty( $this->data->get_shipping_tax() ) ? $this->data->get_shipping_tax() : 0; + return \wc_graphql_price( $price, array( 'currency' => $this->data->get_currency() ) ); + }, + 'shippingTaxRaw' => array( + 'callback' => function() { + return ! empty( $this->data->get_shipping_tax() ) ? $this->data->get_shipping_tax() : 0; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'cartTax' => function() { - return ! empty( $this->data->get_cart_tax() ) ? $this->data->get_cart_tax() : 0; - }, + $price = ! empty( $this->data->get_cart_tax() ) ? $this->data->get_cart_tax() : 0; + return \wc_graphql_price( $price, array( 'currency' => $this->data->get_currency() ) ); + }, + 'cartTaxRaw' => array( + 'callback' => function() { + return ! empty( $this->data->get_cart_tax() ) ? $this->data->get_cart_tax() : 0; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'total' => function() { - return ! empty( $this->data->get_total() ) ? $this->data->get_total() : 0; - }, + $price = ! empty( $this->data->get_total() ) ? $this->data->get_total() : 0; + return \wc_graphql_price( $price, array( 'currency' => $this->data->get_currency() ) ); + }, + 'totalRaw' => array( + 'callback' => function() { + return ! empty( $this->data->get_total() ) ? $this->data->get_total() : 0; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'totalTax' => function() { - return ! empty( $this->data->get_total_tax() ) ? $this->data->get_total_tax() : 0; - }, + $price = ! empty( $this->data->get_total_tax() ) ? $this->data->get_total_tax() : 0; + return \wc_graphql_price( $price, array( 'currency' => $this->data->get_currency() ) ); + }, + 'totalTaxRaw' => array( + 'callback' => function() { + return ! empty( $this->data->get_total_tax() ) ? $this->data->get_total_tax() : 0; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'subtotal' => function() { - return ! empty( $this->data->get_subtotal() ) ? $this->data->get_subtotal() : 0; - }, + $price = ! empty( $this->data->get_subtotal() ) ? $this->data->get_subtotal() : null; + return \wc_graphql_price( $price, array( 'currency' => $this->data->get_currency() ) ); + }, + 'subtotalRaw' => array( + 'callback' => function() { + return ! empty( $this->data->get_subtotal() ) ? $this->data->get_subtotal() : 0; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'orderNumber' => function() { return ! empty( $this->data->get_order_number() ) ? $this->data->get_order_number() : null; }, diff --git a/includes/model/class-product-variation.php b/includes/model/class-product-variation.php index 1ec8f1038..f645aa219 100644 --- a/includes/model/class-product-variation.php +++ b/includes/model/class-product-variation.php @@ -95,14 +95,38 @@ protected function init() { return ! empty( $this->data->get_sku() ) ? $this->data->get_sku() : null; }, 'price' => function() { - return ! empty( $this->data->get_price() ) ? $this->data->get_price() : null; - }, + return ! empty( $this->data->get_price() ) + ? \wc_graphql_price( $this->data->get_price() ) + : null; + }, + 'priceRaw' => array( + 'callback' => function() { + return ! empty( $this->data->get_price() ) ? $this->data->get_price() : null; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'salePrice' => function() { - return ! empty( $this->data->get_sale_price() ) ? $this->data->get_sale_price() : null; - }, + return ! empty( $this->data->get_sale_price() ) + ? \wc_graphql_price( $this->data->get_sale_price() ) + : null; + }, + 'salePriceRaw' => array( + 'callback' => function() { + return ! empty( $this->data->get_sale_price() ) ? $this->data->get_sale_price() : null; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'regularPrice' => function() { - return ! empty( $this->data->get_regular_price() ) ? $this->data->get_regular_price() : null; - }, + return ! empty( $this->data->get_regular_price() ) ? + \wc_graphql_price( $this->data->get_regular_price() ) + : null; + }, + 'regularPriceRaw' => array( + 'callback' => function() { + return ! empty( $this->data->get_regular_price() ) ? $this->data->get_regular_price() : null; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'dateOnSaleFrom' => function() { return ! empty( $this->data->get_date_on_sale_from() ) ? $this->data->get_date_on_sale_from() : null; }, diff --git a/includes/model/class-product.php b/includes/model/class-product.php index 56d7a5d40..b8f9384ae 100644 --- a/includes/model/class-product.php +++ b/includes/model/class-product.php @@ -92,6 +92,37 @@ private function get_object( $id ) { } } + /** + * Returns string of variation price range. + * + * @param string $pricing_type - Range selected pricing type. + * @param boolean $raw - Whether to return raw value. + * + * @return string|null + */ + private function get_variation_price( $pricing_type = '', $raw = false ) { + $prices = $this->data->get_variation_prices( true ); + + if ( empty( $prices['price'] ) || ( 'sale' === $pricing_type && ! $this->data->is_on_sale() ) ) { + return null; + } else { + $min_price = current( $prices['price'] ); + $max_price = end( $prices['price'] ); + $min_reg_price = current( $prices['regular_price'] ); + $max_reg_price = end( $prices['regular_price'] ); + + if ( $min_price !== $max_price ) { + $price = ! $raw ? \wc_graphql_price_range( $min_price, $max_price ) : implode( ', ', $prices['price'] ); + } elseif ( 'regular' !== $pricing_type && $this->data->is_on_sale() && $min_reg_price === $max_reg_price ) { + $price = ! $raw ? \wc_graphql_price_range( $min_price, $max_reg_price ) : implode( ', ', $prices['price'] ); + } else { + $price = ! $raw ? \wc_graphql_price( $min_price ) : $min_price; + } + } + + return apply_filters( 'graphql_get_variation_price', $price, $this ); + } + /** * Initializes the Product field resolvers * @@ -145,83 +176,62 @@ protected function init() { return ! empty( $this->data->get_sku() ) ? $this->data->get_sku() : null; }, 'price' => function() { - if ( ! empty( $this->data ) ) { - if ( 'variable' === $this->data->get_type() ) { - return ! empty( $this->data->get_variation_price( 'min' ) ) - ? $this->data->get_variation_price( 'min' ) - : null; - } - return ! empty( $this->data->get_price() ) - ? $this->data->get_price() - : null; + if ( 'variable' === $this->data->get_type() ) { + return $this->get_variation_price(); } - return null; + + return ! empty( $this->data->get_price() ) + ? \wc_graphql_price( $this->data->get_price() ) + : null; }, - 'priceMax' => function() { - if ( ! empty( $this->data ) ) { + 'priceRaw' => array( + 'callback' => function() { if ( 'variable' === $this->data->get_type() ) { - return ! empty( $this->data->get_variation_price( 'max' ) ) - ? $this->data->get_variation_price( 'max' ) - : null; + return $this->get_variation_price( '', true ); } - return ! empty( $this->data->get_price() ) - ? $this->data->get_price() - : null; - } - return null; - }, + + return ! empty( $this->data->get_price() ) ? $this->data->get_price() : null; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'regularPrice' => function() { - if ( ! empty( $this->data ) ) { - if ( 'variable' === $this->data->get_type() ) { - return ! empty( $this->data->get_variation_regular_price( 'min' ) ) - ? $this->data->get_variation_regular_price( 'min' ) - : null; - } - return ! empty( $this->data->get_regular_price() ) - ? $this->data->get_regular_price() - : null; + if ( 'variable' === $this->data->get_type() ) { + return $this->get_variation_price( 'regular' ); } - return null; + + return ! empty( $this->data->get_regular_price() ) + ? \wc_graphql_price( $this->data->get_regular_price() ) + : null; }, - 'regularPriceMax' => function() { - if ( ! empty( $this->data ) ) { + 'regularPriceRaw' => array( + 'callback' => function() { if ( 'variable' === $this->data->get_type() ) { - return ! empty( $this->data->get_variation_regular_price( 'max' ) ) - ? $this->data->get_variation_regular_price( 'max' ) - : null; + return $this->get_variation_price( 'regular', true ); } - return ! empty( $this->data->get_regular_price() ) - ? $this->data->get_regular_price() - : null; - } - return null; - }, + + return ! empty( $this->data->get_regular_price() ) ? $this->data->get_regular_price() : null; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'salePrice' => function() { - if ( ! empty( $this->data ) ) { - if ( 'variable' === $this->data->get_type() ) { - return ! empty( $this->data->get_variation_sale_price( 'min' ) ) - ? $this->data->get_variation_sale_price( 'min' ) - : null; - } - return ! empty( $this->data->get_sale_price() ) - ? $this->data->get_sale_price() - : null; + if ( 'variable' === $this->data->get_type() ) { + return $this->get_variation_price( 'sale' ); } - return null; + + return ! empty( $this->data->get_sale_price() ) + ? \wc_graphql_price( $this->data->get_sale_price() ) + : null; }, - 'salePriceMax' => function() { - if ( ! empty( $this->data ) ) { + 'salePriceRaw' => array( + 'callback' => function() { if ( 'variable' === $this->data->get_type() ) { - return ! empty( $this->data->get_variation_sale_price( 'max' ) ) - ? $this->data->get_variation_sale_price( 'max' ) - : null; + return $this->get_variation_price( 'sale', true ); } - return ! empty( $this->data->get_sale_price() ) - ? $this->data->get_sale_price() - : null; - } - return null; - }, + + return ! empty( $this->data->get_sale_price() ) ? $this->data->get_sale_price() : null; + }, + 'capability' => $this->post_type_object->cap->edit_posts, + ), 'dateOnSaleFrom' => function() { return ! empty( $this->data->get_date_on_sale_from() ) ? $this->data->get_date_on_sale_from() : null; }, diff --git a/includes/type/enum/class-pricing-field-format.php b/includes/type/enum/class-pricing-field-format.php new file mode 100644 index 000000000..a94cd6636 --- /dev/null +++ b/includes/type/enum/class-pricing-field-format.php @@ -0,0 +1,32 @@ + array( 'value' => 'formatted' ), + 'RAW' => array( 'value' => 'raw' ), + ); + + register_graphql_enum_type( + 'PricingFieldFormatEnum', + array( + 'description' => __( 'Pricing field format enumeration', 'wp-graphql-woocommerce' ), + 'values' => $values, + ) + ); + } +} diff --git a/includes/type/object/class-cart-type.php b/includes/type/object/class-cart-type.php index 25949224f..9d557a84f 100644 --- a/includes/type/object/class-cart-type.php +++ b/includes/type/object/class-cart-type.php @@ -96,94 +96,106 @@ public static function register_cart() { 'description' => __( 'The cart object', 'wp-graphql-woocommerce' ), 'fields' => array( 'subtotal' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart subtotal', 'wp-graphql-woocommerce' ), 'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) { - return ! is_null( $source->get_subtotal() ) ? $source->get_subtotal() : 0; + $price = ! is_null( $source->get_subtotal() ) ? $source->get_subtotal() : 0; + return \wc_graphql_price( $price ); }, ), 'subtotalTax' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart subtotal tax', 'wp-graphql-woocommerce' ), 'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) { - return ! is_null( $source->get_subtotal_tax() ) ? $source->get_subtotal_tax() : 0; + $price = is_null( $source->get_subtotal_tax() ) ? $source->get_subtotal_tax() : 0; + return \wc_graphql_price( $price ); }, ), 'discountTotal' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart discount total', 'wp-graphql-woocommerce' ), 'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) { - return ! is_null( $source->get_discount_total() ) ? $source->get_discount_total() : 0; + $price = ! is_null( $source->get_discount_total() ) ? $source->get_discount_total() : 0; + return \wc_graphql_price( $price ); }, ), 'discountTax' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart discount tax', 'wp-graphql-woocommerce' ), 'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) { - return ! is_null( $source->get_discount_tax() ) ? $source->get_discount_tax() : 0; + $price = ! is_null( $source->get_discount_tax() ) ? $source->get_discount_tax() : 0; + return \wc_graphql_price( $price ); }, ), 'shippingTotal' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart shipping total', 'wp-graphql-woocommerce' ), 'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) { - return ! is_null( $source->get_shipping_total() ) ? $source->get_shipping_total() : 0; + $price = ! is_null( $source->get_shipping_total() ) ? $source->get_shipping_total() : 0; + return \wc_graphql_price( $price ); }, ), 'shippingTax' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart shipping tax', 'wp-graphql-woocommerce' ), 'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) { - return ! is_null( $source->get_shipping_tax() ) ? $source->get_shipping_tax() : 0; + $price = ! is_null( $source->get_shipping_tax() ) ? $source->get_shipping_tax() : 0; + return \wc_graphql_price( $price ); }, ), 'contentsTotal' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart contents total', 'wp-graphql-woocommerce' ), 'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) { - return ! is_null( $source->get_cart_contents_total() ) + $price = ! is_null( $source->get_cart_contents_total() ) ? $source->get_cart_contents_total() : 0; + return \wc_graphql_price( $price ); }, ), 'contentsTax' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart contents tax', 'wp-graphql-woocommerce' ), 'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) { - return ! is_null( $source->get_cart_contents_tax() ) + $price = ! is_null( $source->get_cart_contents_tax() ) ? $source->get_cart_contents_tax() : 0; + return \wc_graphql_price( $price ); }, ), 'feeTotal' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart fee total', 'wp-graphql-woocommerce' ), 'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) { - return ! is_null( $source->get_fee_total() ) ? $source->get_fee_total() : 0; + $price = ! is_null( $source->get_fee_total() ) ? $source->get_fee_total() : 0; + return \wc_graphql_price( $price ); }, ), 'feeTax' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart fee tax', 'wp-graphql-woocommerce' ), 'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) { - return ! is_null( $source->get_fee_tax() ) ? $source->get_fee_tax() : 0; + $price = ! is_null( $source->get_fee_tax() ) ? $source->get_fee_tax() : 0; + return \wc_graphql_price( $price ); }, ), 'total' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart total after calculation', 'wp-graphql-woocommerce' ), 'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) { $source->calculate_totals(); - return isset( $source->get_totals()['total'] ) + $price = isset( $source->get_totals()['total'] ) ? apply_filters( 'woocommerce_cart_get_total', $source->get_totals()['total'] ) : null; + return \wc_graphql_price( $price ); }, ), 'totalTax' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart total tax amount', 'wp-graphql-woocommerce' ), 'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) { - return ! is_null( $source->get_total_tax() ) ? $source->get_total_tax() : 0; + $price = ! is_null( $source->get_total_tax() ) ? $source->get_total_tax() : 0; + return \wc_graphql_price( $price ); }, ), 'isEmpty' => array( @@ -266,31 +278,35 @@ public static function register_cart_item() { }, ), 'subtotal' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Item\'s subtotal', 'wp-graphql-woocommerce' ), 'resolve' => function( $source ) { - return isset( $source['line_subtotal'] ) ? floatval( $source['line_subtotal'] ) : null; + $price = isset( $source['line_subtotal'] ) ? floatval( $source['line_subtotal'] ) : 0; + return \wc_graphql_price( $price ); }, ), 'subtotalTax' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Item\'s subtotal tax', 'wp-graphql-woocommerce' ), 'resolve' => function( $source ) { - return isset( $source['line_subtotal_tax'] ) ? floatval( $source['line_subtotal_tax'] ) : null; + $price = isset( $source['line_subtotal_tax'] ) ? floatval( $source['line_subtotal_tax'] ) : 0; + return \wc_graphql_price( $price ); }, ), 'total' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Item\'s total', 'wp-graphql-woocommerce' ), 'resolve' => function( $source ) { - return isset( $source['line_total'] ) ? floatval( $source['line_total'] ) : null; + $price = isset( $source['line_total'] ) ? floatval( $source['line_total'] ) : null; + return \wc_graphql_price( $price ); }, ), 'tax' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Item\'s tax', 'wp-graphql-woocommerce' ), 'resolve' => function( $source ) { - return isset( $source['line_tax'] ) ? floatval( $source['line_tax'] ) : null; + $price = isset( $source['line_tax'] ) ? floatval( $source['line_tax'] ) : null; + return \wc_graphql_price( $price ); }, ), ), @@ -306,7 +322,7 @@ public static function register_cart_fee() { 'CartFee', array( 'description' => __( 'An additional fee', 'wp-graphql-woocommerce' ), - 'fields' => array( + 'fields' => array( 'id' => array( 'type' => array( 'non_null' => 'ID' ), 'description' => __( 'Fee ID', 'wp-graphql-woocommerce' ), diff --git a/includes/type/object/class-order-type.php b/includes/type/object/class-order-type.php index 15e7e87ed..002cfd591 100644 --- a/includes/type/object/class-order-type.php +++ b/includes/type/object/class-order-type.php @@ -89,36 +89,154 @@ public static function register() { 'description' => __( 'Date order was paid', 'wp-graphql-woocommerce' ), ), 'discountTotal' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Discount total amount', 'wp-graphql-woocommerce' ), + 'args' => array( + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), + ), + ), + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->discountTotalRaw; + } else { + // @codingStandardsIgnoreLine. + return $source->discountTotal; + } + }, ), 'discountTax' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Discount tax amount', 'wp-graphql-woocommerce' ), + 'args' => array( + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), + ), + ), + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->discountTaxRaw; + } else { + // @codingStandardsIgnoreLine. + return $source->discountTax; + } + }, ), 'shippingTotal' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Shipping total amount', 'wp-graphql-woocommerce' ), + 'args' => array( + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), + ), + ), + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->shippingTotalRaw; + } else { + // @codingStandardsIgnoreLine. + return $source->shippingTotal; + } + }, ), 'shippingTax' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Shipping tax amount', 'wp-graphql-woocommerce' ), + 'args' => array( + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), + ), + ), + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->shippingTaxRaw; + } else { + // @codingStandardsIgnoreLine. + return $source->shippingTax; + } + }, ), 'cartTax' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Cart tax amount', 'wp-graphql-woocommerce' ), + 'args' => array( + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), + ), + ), + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->cartTaxRaw; + } else { + // @codingStandardsIgnoreLine. + return $source->cartTax; + } + }, ), 'total' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Order grand total', 'wp-graphql-woocommerce' ), + 'args' => array( + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), + ), + ), + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->totalRaw; + } else { + return $source->total; + } + }, ), 'totalTax' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Order taxes', 'wp-graphql-woocommerce' ), + 'args' => array( + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), + ), + ), + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->totalTaxRaw; + } else { + // @codingStandardsIgnoreLine. + return $source->totalTax; + } + }, ), 'subtotal' => array( - 'type' => 'Float', + 'type' => 'String', 'description' => __( 'Order subtotal', 'wp-graphql-woocommerce' ), + 'args' => array( + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), + ), + ), + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->subtotalRaw; + } else { + return $source->subtotal; + } + }, ), 'orderNumber' => array( 'type' => 'String', diff --git a/includes/type/object/class-product-type.php b/includes/type/object/class-product-type.php index 154e5345b..a941bb709 100644 --- a/includes/type/object/class-product-type.php +++ b/includes/type/object/class-product-type.php @@ -87,56 +87,58 @@ public static function register() { ), 'price' => array( 'type' => 'String', + 'description' => __( 'Product\'s active price', 'wp-graphql-woocommerce' ), 'args' => array( - 'max' => array( - 'type' => 'Boolean', - 'description' => __( 'Show maximum price (Variable type product)', 'wp-graphql-woocommerce' ), + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), ), ), - 'description' => __( 'Product\'s active price', 'wp-graphql-woocommerce' ), - 'resolve' => function( $product, array $args ) { - if ( ! empty( $args['max'] ) && $args['max'] ) { - // @codingStandardsIgnoreLine - return $product->priceMax; + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->priceRaw; + } else { + return $source->price; } - // @codingStandardsIgnoreLine - return $product->price; }, ), 'regularPrice' => array( 'type' => 'String', + 'description' => __( 'Product\'s regular price', 'wp-graphql-woocommerce' ), 'args' => array( - 'max' => array( - 'type' => 'Boolean', - 'description' => __( 'Show maximum price (Variable type product)', 'wp-graphql-woocommerce' ), + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), ), ), - 'description' => __( 'Product\'s regular price', 'wp-graphql-woocommerce' ), - 'resolve' => function( $product, array $args ) { - if ( ! empty( $args['max'] ) && $args['max'] ) { - // @codingStandardsIgnoreLine - return $product->regularPriceMax; + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->regularPriceRaw; + } else { + // @codingStandardsIgnoreLine. + return $source->regularPrice; } - // @codingStandardsIgnoreLine - return $product->regularPrice; }, ), 'salePrice' => array( 'type' => 'String', + 'description' => __( 'Product\'s sale price', 'wp-graphql-woocommerce' ), 'args' => array( - 'max' => array( - 'type' => 'Boolean', - 'description' => __( 'Show maximum price (Variable type product)', 'wp-graphql-woocommerce' ), + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), ), ), - 'description' => __( 'Product\'s sale price', 'wp-graphql-woocommerce' ), - 'resolve' => function( $product, array $args ) { - if ( ! empty( $args['max'] ) && $args['max'] ) { - // @codingStandardsIgnoreLine - return $product->salePriceMax; + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->salePriceRaw; + } else { + // @codingStandardsIgnoreLine. + return $source->salePrice; } - // @codingStandardsIgnoreLine - return $product->salePrice; }, ), 'dateOnSaleFrom' => array( diff --git a/includes/type/object/class-product-variation-type.php b/includes/type/object/class-product-variation-type.php index 5b58919d0..bc081b5ac 100644 --- a/includes/type/object/class-product-variation-type.php +++ b/includes/type/object/class-product-variation-type.php @@ -63,14 +63,58 @@ public static function register() { 'price' => array( 'type' => 'String', 'description' => __( 'Product variation\'s active price', 'wp-graphql-woocommerce' ), + 'args' => array( + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), + ), + ), + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->priceRaw; + } else { + return $source->price; + } + }, ), 'regularPrice' => array( 'type' => 'String', 'description' => __( 'Product variation\'s regular price', 'wp-graphql-woocommerce' ), + 'args' => array( + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), + ), + ), + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->regularPriceRaw; + } else { + // @codingStandardsIgnoreLine. + return $source->regularPrice; + } + }, ), 'salePrice' => array( 'type' => 'String', 'description' => __( 'Product variation\'s sale price', 'wp-graphql-woocommerce' ), + 'args' => array( + 'format' => array( + 'type' => 'PricingFieldFormatEnum', + 'description' => __( 'Format of the price', 'wp-graphql-woocommerce' ), + ), + ), + 'resolve' => function( $source, $args ) { + if ( isset( $args['format'] ) && 'raw' === $args['format'] ) { + // @codingStandardsIgnoreLine. + return $source->salePriceRaw; + } else { + // @codingStandardsIgnoreLine. + return $source->salePrice; + } + }, ), 'dateOnSaleFrom' => array( 'type' => 'String', diff --git a/tests/_support/Helper/crud-helpers/cart.php b/tests/_support/Helper/crud-helpers/cart.php index 0c08b538b..6baf3621a 100644 --- a/tests/_support/Helper/crud-helpers/cart.php +++ b/tests/_support/Helper/crud-helpers/cart.php @@ -10,18 +10,18 @@ public function to_relay_id( $id ) { public function print_query( $id = 0 ) { $cart = WC()->cart; return array( - 'subtotal' => floatval( $cart->get_subtotal() ), - 'subtotalTax' => floatval( $cart->get_subtotal_tax() ), - 'discountTotal' => floatval( $cart->get_discount_total() ), - 'discountTax' => floatval( $cart->get_discount_tax() ), - 'shippingTotal' => floatval( $cart->get_shipping_total() ), - 'shippingTax' => floatval( $cart->get_shipping_tax() ), - 'contentsTotal' => floatval( $cart->get_cart_contents_total() ), - 'contentsTax' => floatval( $cart->get_cart_contents_tax() ), - 'feeTotal' => floatval( $cart->get_fee_total() ), - 'feeTax' => floatval( $cart->get_fee_tax() ), - 'total' => floatval( $cart->get_totals()['total'] ), - 'totalTax' => floatval( $cart->get_total_tax() ), + 'subtotal' => \wc_graphql_price( $cart->get_subtotal() ), + 'subtotalTax' => \wc_graphql_price( $cart->get_subtotal_tax() ), + 'discountTotal' => \wc_graphql_price( $cart->get_discount_total() ), + 'discountTax' => \wc_graphql_price( $cart->get_discount_tax() ), + 'shippingTotal' => \wc_graphql_price( $cart->get_shipping_total() ), + 'shippingTax' => \wc_graphql_price( $cart->get_shipping_tax() ), + 'contentsTotal' => \wc_graphql_price( $cart->get_cart_contents_total() ), + 'contentsTax' => \wc_graphql_price( $cart->get_cart_contents_tax() ), + 'feeTotal' => \wc_graphql_price( $cart->get_fee_total() ), + 'feeTax' => \wc_graphql_price( $cart->get_fee_tax() ), + 'total' => \wc_graphql_price( $cart->get_totals()['total'] ), + 'totalTax' => \wc_graphql_price( $cart->get_total_tax() ), 'isEmpty' => $cart->is_empty(), 'displayPricesIncludeTax' => $cart->display_prices_including_tax(), 'needsShippingAddress' => $cart->needs_shipping_address(), @@ -42,10 +42,10 @@ public function print_item_query( $key ) { 'variationId' => $item['variation_id'] ), 'quantity' => $item['quantity'], - 'subtotal' => $item['line_subtotal'], - 'subtotalTax' => $item['line_subtotal_tax'], - 'total' => $item['line_total'], - 'tax' => $item['line_tax'], + 'subtotal' => \wc_graphql_price( $item['line_subtotal'] ), + 'subtotalTax' => \wc_graphql_price( $item['line_subtotal_tax'] ), + 'total' => \wc_graphql_price( $item['line_total'] ), + 'tax' => \wc_graphql_price( $item['line_tax'] ), ); } diff --git a/tests/_support/Helper/crud-helpers/order.php b/tests/_support/Helper/crud-helpers/order.php index 62ceb28ba..3782ad424 100644 --- a/tests/_support/Helper/crud-helpers/order.php +++ b/tests/_support/Helper/crud-helpers/order.php @@ -175,14 +175,14 @@ public function print_query( $id ) { 'date' => $data->get_date_created()->__toString(), 'modified' => $data->get_date_modified()->__toString(), 'status' => strtoupper( $data->get_status() ), - 'discountTotal' => floatval( $data->get_discount_total() ), - 'discountTax' => floatval( $data->get_discount_tax() ), - 'shippingTotal' => floatval( $data->get_shipping_total() ), - 'shippingTax' => floatval( $data->get_shipping_tax() ), - 'cartTax' => floatval( $data->get_cart_tax() ), - 'total' => floatval( $data->get_total() ), - 'totalTax' => floatval( $data->get_total_tax() ), - 'subtotal' => floatval( $data->get_subtotal() ), + 'discountTotal' => \wc_graphql_price( $data->get_discount_total(), array( 'currency' => $data->get_currency() ) ), + 'discountTax' => \wc_graphql_price( $data->get_discount_tax(), array( 'currency' => $data->get_currency() ) ), + 'shippingTotal' => \wc_graphql_price( $data->get_shipping_total(), array( 'currency' => $data->get_currency() ) ), + 'shippingTax' => \wc_graphql_price( $data->get_shipping_tax(), array( 'currency' => $data->get_currency() ) ), + 'cartTax' => \wc_graphql_price( $data->get_cart_tax(), array( 'currency' => $data->get_currency() ) ), + 'total' => \wc_graphql_price( $data->get_total(), array( 'currency' => $data->get_currency() ) ), + 'totalTax' => \wc_graphql_price( $data->get_total_tax(), array( 'currency' => $data->get_currency() ) ), + 'subtotal' => \wc_graphql_price( $data->get_subtotal(), array( 'currency' => $data->get_currency() ) ), 'orderNumber' => $data->get_order_number(), 'orderKey' => $data->get_order_key(), 'createdVia' => ! empty( $data->get_created_via() ) diff --git a/tests/_support/Helper/crud-helpers/product-variation.php b/tests/_support/Helper/crud-helpers/product-variation.php index e13d79461..b840d6df7 100644 --- a/tests/_support/Helper/crud-helpers/product-variation.php +++ b/tests/_support/Helper/crud-helpers/product-variation.php @@ -91,9 +91,9 @@ public function print_query( $id ) { : null, 'description' => ! empty( $data->get_description() ) ? $data->get_description() : null, 'sku' => $data->get_sku(), - 'price' => ! empty( $data->get_price() ) ? $data->get_price() : null, - 'regularPrice' => ! empty( $data->get_regular_price() ) ? $data->get_regular_price() : null, - 'salePrice' => ! empty( $data->get_sale_price() ) ? $data->get_sale_price() : null, + 'price' => ! empty( $data->get_price() ) ? \wc_graphql_price( $data->get_price() ) : null, + 'regularPrice' => ! empty( $data->get_regular_price() ) ? \wc_graphql_price( $data->get_regular_price() ) : null, + 'salePrice' => ! empty( $data->get_sale_price() ) ? \wc_graphql_price( $data->get_sale_price() ) : null, 'dateOnSaleFrom' => ! empty( $data->get_date_on_sale_from() ) ? $data->get_date_on_sale_from() : null, diff --git a/tests/_support/Helper/crud-helpers/product.php b/tests/_support/Helper/crud-helpers/product.php index 44ffb9f57..2f1d1380a 100644 --- a/tests/_support/Helper/crud-helpers/product.php +++ b/tests/_support/Helper/crud-helpers/product.php @@ -229,13 +229,13 @@ public function print_query( $id ) { : null, 'sku' => $data->get_sku(), 'price' => ! empty( $data->get_price() ) - ? $data->get_price() + ? \wc_graphql_price( $data->get_price() ) : null, 'regularPrice' => ! empty( $data->get_regular_price() ) - ? $data->get_regular_price() + ? \wc_graphql_price( $data->get_regular_price() ) : null, 'salePrice' => ! empty( $data->get_sale_price() ) - ? $data->get_sale_price() + ? \wc_graphql_price( $data->get_sale_price() ) : null, 'dateOnSaleFrom' => $data->get_date_on_sale_from(), 'dateOnSaleTo' => $data->get_date_on_sale_to(), diff --git a/tests/wpunit/CartMutationsTest.php b/tests/wpunit/CartMutationsTest.php index 2132bd190..688eb0f7a 100644 --- a/tests/wpunit/CartMutationsTest.php +++ b/tests/wpunit/CartMutationsTest.php @@ -165,10 +165,10 @@ public function testAddToCartMutationWithProduct() { ), 'variation' => null, 'quantity' => $cart_item['quantity'], - 'subtotal' => floatval( $cart_item['line_subtotal'] ), - 'subtotalTax' => floatval( $cart_item['line_subtotal_tax'] ), - 'total' => floatval( $cart_item['line_total'] ), - 'tax' => floatval( $cart_item['line_tax'] ), + 'subtotal' => wc_graphql_price( $cart_item['line_subtotal'] ), + 'subtotalTax' => wc_graphql_price( $cart_item['line_subtotal_tax'] ), + 'total' => wc_graphql_price( $cart_item['line_total'] ), + 'tax' => wc_graphql_price( $cart_item['line_tax'] ), ), ), ), @@ -215,10 +215,10 @@ public function testAddToCartMutationWithProductVariation() { 'id' => $this->variation->to_relay_id( $cart_item['variation_id'] ), ), 'quantity' => $cart_item['quantity'], - 'subtotal' => floatval( $cart_item['line_subtotal'] ), - 'subtotalTax' => floatval( $cart_item['line_subtotal_tax'] ), - 'total' => floatval( $cart_item['line_total'] ), - 'tax' => floatval( $cart_item['line_tax'] ), + 'subtotal' => wc_graphql_price( $cart_item['line_subtotal'] ), + 'subtotalTax' => wc_graphql_price( $cart_item['line_subtotal_tax'] ), + 'total' => wc_graphql_price( $cart_item['line_total'] ), + 'tax' => wc_graphql_price( $cart_item['line_tax'] ), ), ), ), @@ -633,10 +633,10 @@ public function testEmptyCartMutation() { 'id' => $this->variation->to_relay_id( $cart_item['variation_id'] ), ), 'quantity' => $cart_item['quantity'], - 'subtotal' => floatval( $cart_item['line_subtotal'] ), - 'subtotalTax' => floatval( $cart_item['line_subtotal_tax'] ), - 'total' => floatval( $cart_item['line_total'] ), - 'tax' => floatval( $cart_item['line_tax'] ), + 'subtotal' => wc_graphql_price( $cart_item['line_subtotal'] ), + 'subtotalTax' => wc_graphql_price( $cart_item['line_subtotal_tax'] ), + 'total' => wc_graphql_price( $cart_item['line_total'] ), + 'tax' => wc_graphql_price( $cart_item['line_tax'] ), ), ), ), @@ -735,10 +735,10 @@ public function testApplyCouponMutation() { 'id' => $this->product->to_relay_id( $cart_item['product_id'] ), ), 'quantity' => $cart_item['quantity'], - 'subtotal' => floatval( $cart_item['line_subtotal'] ), - 'subtotalTax' => floatval( $cart_item['line_subtotal_tax'] ), - 'total' => floatval( $cart_item['line_total'] ), - 'tax' => floatval( $cart_item['line_tax'] ), + 'subtotal' => wc_graphql_price( $cart_item['line_subtotal'] ), + 'subtotalTax' => wc_graphql_price( $cart_item['line_subtotal_tax'] ), + 'total' => wc_graphql_price( $cart_item['line_total'] ), + 'tax' => wc_graphql_price( $cart_item['line_tax'] ), ), ), ), @@ -837,10 +837,10 @@ public function testRemoveCouponMutation() { 'id' => $this->product->to_relay_id( $cart_item['product_id'] ), ), 'quantity' => $cart_item['quantity'], - 'subtotal' => floatval( $cart_item['line_subtotal'] ), - 'subtotalTax' => floatval( $cart_item['line_subtotal_tax'] ), - 'total' => floatval( $cart_item['line_total'] ), - 'tax' => floatval( $cart_item['line_tax'] ), + 'subtotal' => wc_graphql_price( $cart_item['line_subtotal'] ), + 'subtotalTax' => wc_graphql_price( $cart_item['line_subtotal_tax'] ), + 'total' => wc_graphql_price( $cart_item['line_total'] ), + 'tax' => wc_graphql_price( $cart_item['line_tax'] ), ), ), ), diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index da00ed174..2d4a12bc2 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -69,6 +69,7 @@ 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Discount_Type' => $baseDir . '/includes/type/enum/class-discount-type.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Manage_Stock' => $baseDir . '/includes/type/enum/class-manage-stock.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Order_Status' => $baseDir . '/includes/type/enum/class-order-status.php', + 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Pricing_Field_Format' => $baseDir . '/includes/type/enum/class-pricing-field-format.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Product_Types' => $baseDir . '/includes/type/enum/class-product-types.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Stock_Status' => $baseDir . '/includes/type/enum/class-stock-status.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Tax_Class' => $baseDir . '/includes/type/enum/class-tax-class.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 8fd856c1a..7d5fe9e49 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -84,6 +84,7 @@ class ComposerStaticInitee0d17af17b841ed3a93c4a0e5cc5e5f 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Discount_Type' => __DIR__ . '/../..' . '/includes/type/enum/class-discount-type.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Manage_Stock' => __DIR__ . '/../..' . '/includes/type/enum/class-manage-stock.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Order_Status' => __DIR__ . '/../..' . '/includes/type/enum/class-order-status.php', + 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Pricing_Field_Format' => __DIR__ . '/../..' . '/includes/type/enum/class-pricing-field-format.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Product_Types' => __DIR__ . '/../..' . '/includes/type/enum/class-product-types.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Stock_Status' => __DIR__ . '/../..' . '/includes/type/enum/class-stock-status.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Tax_Class' => __DIR__ . '/../..' . '/includes/type/enum/class-tax-class.php',