-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-graphql-woocommerce.0001.fix.wrong-labels-graphql-attributes.patch
52 lines (49 loc) · 2.1 KB
/
wp-graphql-woocommerce.0001.fix.wrong-labels-graphql-attributes.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From 9d82f1bb4ebe10821af0e736add36101e78e0f47 Mon Sep 17 00:00:00 2001
From: creative-andrew <[email protected]>
Date: Tue, 7 May 2024 15:38:16 +0200
Subject: [PATCH] fix: wrong label names in woo-graphql
---
.../class-variation-attribute-connection-resolver.php | 2 ++
includes/type/object/class-variation-attribute-type.php | 8 +-------
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/includes/data/connection/class-variation-attribute-connection-resolver.php b/includes/data/connection/class-variation-attribute-connection-resolver.php
index 1a975c89d6..e6b68b4217 100644
--- a/includes/data/connection/class-variation-attribute-connection-resolver.php
+++ b/includes/data/connection/class-variation-attribute-connection-resolver.php
@@ -94,6 +94,7 @@ class Variation_Attribute_Connection_Resolver {
'id' => $id,
'attributeId' => 0,
'name' => $name,
+ 'label' => $value,
'value' => $value,
];
} else {
@@ -101,6 +102,7 @@ class Variation_Attribute_Connection_Resolver {
'id' => $id,
'attributeId' => $term->term_id,
'name' => $term->taxonomy,
+ 'label' => $term->name,
'value' => $term->slug,
];
}
diff --git a/includes/type/object/class-variation-attribute-type.php b/includes/type/object/class-variation-attribute-type.php
index 0942bb5d74..82119a0702 100644
--- a/includes/type/object/class-variation-attribute-type.php
+++ b/includes/type/object/class-variation-attribute-type.php
@@ -44,13 +44,7 @@ class Variation_Attribute_Type {
'type' => 'String',
'description' => __( 'Label of attribute', 'wp-graphql-woocommerce' ),
'resolve' => static function ( $source ) {
- if ( ! isset( $source['name'] ) ) {
- return null;
- }
-
- $slug = \wc_attribute_taxonomy_slug( $source['name'] );
- $label = preg_replace( '/(-|_)/', ' ', $slug );
- return ! empty( $label ) ? ucwords( $label ) : null;
+ return isset( $source['label'] ) ? $source['label'] : null;
},
],
'name' => [
--
2.24.4