[PaaS only]{class="badge informative" title="Applies to Adobe Commerce on Cloud projects (Adobe-managed PaaS infrastructure) and on-premises projects only."}

ACSD-64431: The “placeOrder” mutation with coupon code in the request throws an internal server error

The ACSD-64431 patch fixes the issue where the placeOrder mutation containing the coupon code information in the request throws an internal server error instead of placing the order successfully. This patch is available when the Quality Patches Tool (QPT) 1.1.61 is installed. The patch ID is ACSD-64431. Please note that the issue is scheduled to be fixed in Adobe Commerce 2.4.8.

Affected products and versions

The patch is created for Adobe Commerce version:

  • Adobe Commerce (all deployment methods) 2.4.7-p3

Compatible with Adobe Commerce versions:

  • Adobe Commerce (all deployment methods) 2.4.7 - 2.4.7-p4
NOTE
The patch might become applicable to other versions with new Quality Patches Tool releases. To check if the patch is compatible with your Adobe Commerce version, update the magento/quality-patches package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.

Issue

The placeOrder mutation that contains the coupon code information in the request throws an internal error, instead of placing the order successfully.

Steps to reproduce:

  1. Create a simple product with SKU 2836611.

  2. Create a Cart Price Rule, set Coupon to Specific Coupon and enter TEST1234 as the coupon code.

  3. Create a customer:

    code language-none
    mutation {
    createCustomer(
        input: {
        firstname: "John"
        lastname: "Doe"
        email: "john.doe@example.com"
        password: "b1b2b3l@w+"
        is_subscribed: true
        }
    ) {
        customer {
        firstname
        lastname
        email
        is_subscribed
        }
    }
    }
    
  4. Generate a customer token. You can use this token for subsequent requests.

    code language-none
    mutation {
    generateCustomerToken(email: "john.doe@example.com", password: "b1b2b3l@w+") {
        token
    }
    }
    
  5. Create an empty cart. Save the cart ID and use it for the subsequent requests.

    code language-none
    mutation {
        createEmptyCart
    }
    
  6. Add the product to the cart:

    code language-none
    mutation {
        addProductsToCart(
            cartId: "xxxx"
            cartItems: [{ quantity: 1, sku: "2836611" }]
        ) {
            cart {
                itemsV2 {
                    items {
                        product {
                            name
                            sku
                        }
                        ... on ConfigurableCartItem {
                            configurable_options {
                                configurable_product_option_uid
                                value_label
                            }
                        }
                        quantity
                    }
                    total_count
                    page_info {
                        page_size
                        current_page
                        total_pages
                    }
                }
            }
            user_errors {
                code
                message
            }
        }
    }
    
  7. Apply the coupon:

    code language-none
    mutation {
        applyCouponToCart(input: { cart_id: "xxxx", coupon_code: "TEST1234" }) {
            cart {
                itemsV2 {
                    items {
                        product {
                            name
                        }
                        quantity
                    }
                    total_count
                    page_info {
                        page_size
                        current_page
                        total_pages
                    }
                }
                applied_coupons {
                    code
                }
                prices {
                    grand_total {
                        value
                        currency
                    }
                }
            }
        }
    }
    
  8. Set a shipping address:

    code language-none
    mutation {
        setShippingAddressesOnCart(
            input: {
                cart_id: "xxxxx"
                shipping_addresses: [
                    {
                        address: {
                            firstname: "John"
                            lastname: "Doe"
                            company: "Company Name"
                            street: ["3320 N Crescent Dr", "Beverly Hills"]
                            city: "Los Angeles"
                            region: "CA"
                            region_id: 12
                            postcode: "90210"
                            country_code: "US"
                            telephone: "123-456-0000"
                            save_in_address_book: false
                        }
                    }
                ]
            }
        ) {
            cart {
                shipping_addresses {
                    firstname
                    lastname
                    company
                    street
                    city
                    region {
                        code
                        label
                    }
                    postcode
                    telephone
                    country {
                        code
                        label
                    }
                    available_shipping_methods {
                        carrier_code
                        carrier_title
                        method_code
                        method_title
                    }
                }
            }
        }
    }
    
  9. Set a shipping method:

    code language-none
    mutation {
        setShippingMethodsOnCart(
            input: {
                cart_id: "xxxx"
                shipping_methods: [{ carrier_code: "flatrate", method_code: "flatrate" }]
            }
        ) {
            cart {
                shipping_addresses {
                    selected_shipping_method {
                        carrier_code
                        carrier_title
                        method_code
                        method_title
                        amount {
                            value
                            currency
                        }
                    }
                }
            }
        }
    }
    
  10. Set a billing address:

    code language-none
    mutation {
        setBillingAddressOnCart(
            input: {
                cart_id: "xxxx"
                billing_address: {
                    address: {
                        firstname: "John"
                        lastname: "Doe"
                        company: "Company Name"
                        street: ["64 Strawberry Dr", "Beverly Hills"]
                        city: "Los Angeles"
                        region: "CA"
                        region_id: 12
                        postcode: "90210"
                        country_code: "US"
                        telephone: "123-456-0000"
                        save_in_address_book: true
                    }
                }
            }
        ) {
            cart {
                billing_address {
                    firstname
                    lastname
                    company
                    street
                    city
                    region {
                        code
                        label
                    }
                    postcode
                    telephone
                    country {
                        code
                        label
                    }
                }
            }
        }
    }
    
  11. Set a payment method:

    code language-none
    mutation {
        setPaymentMethodOnCart(
            input: { cart_id: "xxxx", payment_method: { code: "checkmo" } }
        ) {
            cart {
                selected_payment_method {
                    code
                }
            }
        }
    }
    
  12. Place the order:

    code language-none
    mutation {
    placeOrder(
        input: {
        cart_id: "{{cart_id}}"
        }
    ) {
        orderV2 {
        number
        token
        }
        errors {
        message
        code
        }
    }
    }
    

Expected results:

The order should be placed.

Actual results:

The following error message appears:
"message": "Internal server error"

exception.log contains the following error:

    report.ERROR: "discount_model" value should be specifiedGraphQL (1:135)
    1: mutation { placeOrder(input: {cart_id: "xxxx"}) { orderV2 { total { discounts { amount { currency value } coupon { code } } } } errors { message code } } }

Apply the patch

To apply individual patches, use the following links depending on your deployment method:

To learn more about Quality Patches Tool, refer to:

recommendation-more-help
c2d96e17-5179-455c-ad3a-e1697bb4e8c3