magento2-react-checkout
magento2-react-checkout copied to clipboard
GraphQL queries requesting attributes that are not present
We are running into an issue with 2.4.3-p1 where hyva checkout is requesting product_type and other attributes that do not exist according to Magento documentation here: documentation
Cannot query field "product_type" on type "CartItemInterface". Did you mean "product"?; Cannot query field "row_total_incl_tax" on type "CartItemPrices".; Cannot query field "price_incl_tax" on type "CartItemPrices".
On the demo site inspecting the network requests, I can see that this property is being excluded from the request but on the Github repository I see that cartItemsInfo.js it is clearly there. What am I missing here, is it a version desync or did I overlook something during setup?
Version 2.4.2-p1 is also affected by follow issue.
@Jasper-ketelaar i think the demo site is currently running on an older version. Probably on 1.0.2. The changes you mentioned are later incorporated. But they are working fine in my environment where I am using the latest version of this in 2.4.3
too. No problems so far
I check it on 2.4.3 and its appear that problem is on enterprise edition. Community with Hyva 1.0.4 work correctly, on enterprise edition works 1.0.3 and lower.
@chajr I am working on community editions too. So probably this is Enterprise specific issue. Maybe it will be worth reporting it to Adobe commerce?
i have the same problem on ver. 2.4.3-p1
the graphql query that runs is something like this
[...]
items {
id
product_type
quantity
prices {
row_total_incl_tax {
value
}
price_incl_tax {
value
}
}
product {
id
name
[...]
while a valid query for 2.4.3(-p1) would be something along these lines:
[...]
items {
id
quantity
prices {
row_total_including_tax {
value
}
}
product {
__typename
[...]
hm, in develop src/reactapp/src/api/cart/utility/query/cartItemsInfo.js
- has a different structure for the query, a number of fields are taken out compared to the version that is available for general use via composer... next released published on packagist should work fine or install via github...
I have the same issue on the Magento Open Source ver. 2.4.3-p1.
"name": "hyva-themes/magento2-react-checkout",
"version": "1.0.8"
Here is the error, how you solve it and why it happens?
So I solved it by creating example module to rewrite the main react as it shows here https://github.com/hyva-themes/magento2-checkout-example and after that rewriting
vendor/hyva-themes/magento2-react-checkout/src/reactapp/src/api/cart/utility/query/cartItemsInfo.js
and modifying the file with this content
const cartItemsInfo = `
items {
id
__typename
quantity
prices {
row_total_including_tax{
value
}
price {
value
}
}
product {
id
name
sku
small_image {
label
url
}
url_key
}
...on ConfigurableCartItem {
configurable_options {
id
option_label
value_label
}
}
}`;
export default cartItemsInfo;
Also it needed to change the modifier to get the new attribute names. THis is the file I rewrited
vendor/hyva-themes/magento2-react-checkout/src/reactapp/src/api/cart/fetchGuestCart/modifier.js
changing the function
return cartItems.reduce((accumulator, item) => {
const { id, quantity, prices, product, product_type: productType } = item;
const priceAmount = _get(prices, 'price.value');
const price = formatPrice(priceAmount);
const rowTotalAmount = _get(prices, 'row_total_including_tax.value');
const rowTotal = formatPrice(rowTotalAmount);
const productId = _get(product, 'id');
const productSku = _get(product, 'sku');
const productName = _get(product, 'name');
const productUrl = _get(product, 'url_key');
const productSmallImgUrl = _get(product, 'small_image.url');
const selectedConfigOptions = (
_get(item, 'configurable_options') || []
).map((configOption) => {
const {
id: optionId,
value_label: value,
option_label: option,
} = configOption;
return {
optionId,
value,
option,
label: `${option}: ${value}`,
};
});
accumulator[id] = {
id,
productType,
quantity,
isConfigurable: productType === 'configurable',
priceAmount,
price,
rowTotal,
rowTotalAmount,
productId,
productSku,
productName,
productUrl,
productSmallImgUrl,
selectedConfigOptions,
};
return accumulator;
}, {});
}
By the way , this issue on the dev branch is solved .
FYI, even after the latest release from 12th July this issue is still happening 6 months later. Are there plans to incorporate this fix into the main branch?