I am trying to place order with the below mutation, but getting Integrity constraint violation
error for address_id
in saving quote_shipping_rate
.
I assume the old shipping rate is not getting deleted in the transaction flow, but I tried loading by collection in MagentoQuoteModelQuoteAddresRate->beforeSave()
which give zero results in same place order flow.
Magento Version: 2.4.5-p3
PHP: 8.1.16
GraphQL Request:
mutation PaymentOptionsAndPlaceOrder($cartId: String!) {
setPaymentMethodOnCart(
input: {cart_id: $cartId, payment_method: {code: "checkmo" }}
) {
cart {
id
selected_payment_method {
code
title
purchase_order_number
__typename
}
shipping_addresses {
selected_shipping_method {
carrier_code
method_code
method_title
carrier_title
amount {
currency
value
__typename
}
__typename
}
available_shipping_methods {
carrier_code
method_code
price_incl_tax {
currency
value
__typename
}
price_excl_tax {
currency
value
__typename
}
__typename
}
__typename
}
prices {
__typename
applied_taxes {
amount {
currency
value
__typename
}
label
__typename
}
discounts {
amount {
currency
value
__typename
}
label
__typename
}
grand_total {
currency
value
__typename
}
subtotal_excluding_tax {
currency
value
__typename
}
subtotal_including_tax {
currency
value
__typename
}
subtotal_with_discount_excluding_tax {
currency
value
__typename
}
}
items {
uid
prices {
price {
currency
value
__typename
}
discounts {
amount {
currency
value
__typename
}
__typename
}
__typename
}
quantity
product {
uid
name
sku
__typename
}
__typename
}
applied_coupons {
code
__typename
}
__typename
}
__typename
}
placeOrder(input: {cart_id: $cartId}) {
order {
order_number
__typename
}
__typename
}
}
Error Response:
{
"errors": [
{
"debugMessage": "SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`db`.`quote_shipping_rate`, CONSTRAINT `QUOTE_SHIPPING_RATE_ADDRESS_ID_QUOTE_ADDRESS_ADDRESS_ID` FOREIGN KEY (`address_id`) REFERENCES `quote_address` (`address_id`) ON DELETE CASCADE), query was: INSERT INTO `quote_shipping_rate` (`carrier`, `carrier_title`, `code`, `method`, `method_description`, `price`, `method_title`) VALUES (?, ?, ?, ?, ?, ?, ?)",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
"locations": [
{
"line": 124,
"column": 3
}
],
"path": [
"placeOrder"
]
}
],
"data": {
"setGuestEmailOnCart": {
"cart": {
"email": "[email protected]"
}
},
"setPaymentMethodOnCart": {
"cart": {
"id": "XOJkOGPzyrSXAx0hk01A0wq2S9LBASdu",
"selected_payment_method": {
"code": "checkmo",
"title": "Check / Money order",
"purchase_order_number": null,
"__typename": "SelectedPaymentMethod"
},
"shipping_addresses": [
{
"selected_shipping_method": {
"carrier_code": "flatrate",
"method_code": "flatrate",
"method_title": "Fixed",
"carrier_title": "Flat Rate",
"amount": {
"currency": "USD",
"value": 5,
"__typename": "Money"
},
"__typename": "SelectedShippingMethod"
},
"available_shipping_methods": [
{
"carrier_code": "flatrate",
"method_code": "flatrate",
"price_incl_tax": {
"currency": "USD",
"value": 5,
"__typename": "Money"
},
"price_excl_tax": {
"currency": "USD",
"value": 5,
"__typename": "Money"
},
"__typename": "AvailableShippingMethod"
}
],
"__typename": "ShippingCartAddress"
}
],
"prices": {
"__typename": "CartPrices",
"applied_taxes": [],
"discounts": null,
"grand_total": {
"currency": "USD",
"value": 45,
"__typename": "Money"
},
"subtotal_excluding_tax": {
"currency": "USD",
"value": 40,
"__typename": "Money"
},
"subtotal_including_tax": {
"currency": "USD",
"value": 40,
"__typename": "Money"
},
"subtotal_with_discount_excluding_tax": {
"currency": "USD",
"value": 40,
"__typename": "Money"
}
},
"items": [
{
"uid": "Mw==",
"prices": {
"price": {
"currency": "USD",
"value": 40,
"__typename": "Money"
},
"discounts": null,
"__typename": "CartItemPrices"
},
"quantity": 1,
"product": {
"uid": "Mg==",
"name": "Test",
"sku": "Test",
"__typename": "SimpleProduct"
},
"__typename": "SimpleCartItem"
}
],
"applied_coupons": null,
"__typename": "Cart"
},
"__typename": "SetPaymentMethodOnCartOutput"
},
"placeOrder": null
}
}