[僅限PaaS]{class="badge informative" title="僅適用於雲端專案(Adobe管理的PaaS基礎結構)和內部部署專案的Adobe Commerce 。"}

ACSD-64431:請求中有優惠券代碼的「placeOrder」突變擲回內部伺服器錯誤

ACSD-64431修補程式修正了要求中包含優惠券代碼資訊的placeOrder突變擲回內部伺服器錯誤,而非成功下訂單的問題。 安裝Quality Patches Tool (QPT) 1.1.61時,即可使用此修補程式。 修補程式ID為ACSD-64431。 請注意,此問題已排程在Adobe Commerce 2.4.8中修正。

受影響的產品和版本

已為Adobe Commerce版本建立修補程式:

  • Adobe Commerce (所有部署方法) 2.4.7-p3

與Adobe Commerce版本相容:

  • Adobe Commerce (所有部署方法) 2.4.7 - 2.4.7-p4
NOTE
此修補程式可能適用於發行版本為Quality Patches Tool的其他版本。 若要檢查修補程式是否與您的Adobe Commerce版本相容,請將magento/quality-patches套件更新至最新版本,並在Quality Patches Tool上檢查相容性:搜尋修補程式頁面。 使用修補程式ID作為搜尋關鍵字,以尋找修補程式。

問題

要求中包含優惠券代碼資訊的placeOrder突變會擲回內部錯誤,而不是順利下訂單。

要再現的步驟

  1. 建立具有​ SKU 2836611 ​的簡單產品。

  2. 建立​ Cart Price Rule、將​ Coupon ​設為Specific Coupon並輸入​ TEST1234 ​作為抵用券代碼。

  3. 建立客戶:

    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. 產生客戶權杖。 您可以針對後續請求使用此代號。

    code language-none
    mutation {
    generateCustomerToken(email: "john.doe@example.com", password: "b1b2b3l@w+") {
        token
    }
    }
    
  5. 建立空的購物車。 儲存購物車ID並用於後續請求。

    code language-none
    mutation {
        createEmptyCart
    }
    
  6. 將產品新增至購物車:

    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. 套用抵用券:

    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. 設定送貨地址:

    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. 設定送貨方法:

    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. 設定帳單地址:

    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. 設定付款方式:

    code language-none
    mutation {
        setPaymentMethodOnCart(
            input: { cart_id: "xxxx", payment_method: { code: "checkmo" } }
        ) {
            cart {
                selected_payment_method {
                    code
                }
            }
        }
    }
    
  12. 下訂單:

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

預期結果

應該下訂單。

實際結果

出現下列錯誤訊息:
"message": "Internal server error"

exception.log包含下列錯誤:

    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 } } }

套用修補程式

若要套用個別修補程式,請根據您的部署方法使用下列連結:

相關閱讀

若要進一步瞭解Quality Patches Tool,請參閱:

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