Skip to content
Open
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
1 change: 0 additions & 1 deletion includes/data/mutation/class-checkout-mutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ protected static function validate_checkout( &$data ) {
if ( WC()->cart->needs_payment() ) {
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();

\codecept_debug( $available_gateways );
if ( ! isset( $available_gateways[ $data['payment_method'] ] ) ) {
throw new UserError( __( 'Invalid payment method.', 'wp-graphql-woocommerce' ) );
} else {
Expand Down
10 changes: 10 additions & 0 deletions includes/model/class-product-variation.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ protected function init() {
'salePriceRaw' => function () {
return ! empty( $this->wc_data->get_sale_price() ) ? $this->wc_data->get_sale_price() : null;
},
'shippingClass' => function () {
$shipping_class_id = $this->wc_data->get_shipping_class_id();
$shipping_class_term = get_term( $shipping_class_id, 'product_shipping_class' );

if ( ! is_wp_error( $shipping_class_term ) && ! is_null( $shipping_class_term ) && is_a( $shipping_class_term, 'WP_Term' ) ) {
$shipping_class = $shipping_class_term;
}

return $shipping_class ?? null;
},

/**
* Connection resolvers fields
Expand Down
2 changes: 1 addition & 1 deletion includes/model/class-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ protected function init() {
return ! empty( $this->wc_data->get_height() ) ? $this->wc_data->get_height() : null;
},
'shippingClassId' => function () {
return ! empty( $this->wc_data->get_image_id() ) ? $this->wc_data->get_shipping_class_id() : null;
return ! empty( $this->wc_data->get_shipping_class_id() ) ? $this->wc_data->get_shipping_class_id() : null;
},
'shippingRequired' => function () {
return $this->wc_data->needs_shipping();
Expand Down
2 changes: 1 addition & 1 deletion includes/type/interface/class-product-variation.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public static function get_fields() {
'description' => __( 'Product variation purchase_note', 'wp-graphql-woocommerce' ),
],
'shippingClass' => [
'type' => 'String',
'type' => 'ShippingClass',
'description' => __( 'Product variation shipping class', 'wp-graphql-woocommerce' ),
],
'catalogVisibility' => [
Expand Down
4 changes: 3 additions & 1 deletion tests/wpunit/ProductVariationQueriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ public function testVariationQuery() {
height
menuOrder
purchaseNote
shippingClass
shippingClass {
id
}
catalogVisibility
hasAttributes
type
Expand Down
Loading