magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.47k stars 9.28k forks source link

Bundle Product discounts not saved to quote_item table #35165

Open hcmlopes opened 2 years ago

hcmlopes commented 2 years ago

Preconditions (*)

  1. Magento 2.4.3-p1

Steps to reproduce (*)

  1. Create Cart Price Rule for 10%
  2. Add Bundle Product to cart
  3. Check column row_total_with_discount, discount_amount, base_discount_amount, discount_percent in database table quote_item
  4. Check API /rest//V1/guest-carts//totals

Expected result (*)

  1. The fields are being calculated properly and stored in the database and therefore are properly returned via API

Actual result (*)

image

Additional Info (*)

  1. Database shows rule 14 should be applied which in this case applies 10%. This can be seen in the checkout where the discount does apply as expected. image
  2. Partially related issue https://github.com/magento/magento2/issues/34288

Severity assessment

m2-assistant[bot] commented 2 years ago

Hi @hcmlopes. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] commented 2 years ago

Hi @engcom-Delta. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Delta commented 2 years ago

Hi @hcmlopes, Thank you for raising an issue .We tried to reproduce the issue on magento 2.4 Develop but we could not find out the endpoint , we have referred dev doc # [[https://devdocs.magento.com/guides/v2.4/rest/tutorials/orders/order-add-items.html]() unfortunately it was not available . Please help us to replicate the issue.

Thanks

hcmlopes commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @hcmlopes. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @hcmlopes, here is your Magento Instance: https://c2763fc9e3b23a6bcf3d4f868db935f6.instances.magento-community.engineering Admin access: https://c2763fc9e3b23a6bcf3d4f868db935f6.instances.magento-community.engineering/admin_50fe Login: bf6dddc3 Password: 1112041f1864

hcmlopes commented 2 years ago

@engcom-Delta Steps to reproduce

  1. Request Magento instance
  2. Generate a new guest cart by making a POST request to /rest/default/V1/guest-carts
  3. Use Cart ID received and make POST request to /rest/default/V1/guest-carts/:cartId/items
    Payload
    {
    "cartItem": {
    "sku": "WS12-M-Orange",
    "qty": 1,
    "quote_id": "{{cartId}}"
    }
    }
  4. Use Cart ID received and make POST request to /rest/default/V1/guest-carts/:cartId/items
    Payload

    Make sure to replace {{cartId}} with the cart ID received from Step 2

    {
    "cartItem": {
    "sku": "24-WG080",
    "qty": 4,
    "quote_id": "{{cartId}}",
    "product_option": {
      "extension_attributes": {
        "bundle_options": [
          {
            "option_id": 1,
            "option_qty": 1,
            "option_selections": [2]
          },
          {
            "option_id": 2,
            "option_qty": 1,
            "option_selections": [4]
          },
          {
            "option_id": 3,
            "option_qty": 1,
            "option_selections": [6]
          },
          {
            "option_id": 4,
            "option_qty": 1,
            "option_selections": [8]
          }
        ]
      }
    }
    }
    }
  5. Make GET request to /rest/default/V1/guest-carts/:cartId/totals Result
    {
    "grand_total": 198.4,
    "base_grand_total": 198.4,
    "subtotal": 316,
    "base_subtotal": 316,
    "discount_amount": -117.6,
    "base_discount_amount": -117.6,
    "subtotal_with_discount": 198.4,
    "base_subtotal_with_discount": 198.4,
    "shipping_amount": 0,
    "base_shipping_amount": 0,
    "shipping_discount_amount": 0,
    "base_shipping_discount_amount": 0,
    "tax_amount": 0,
    "base_tax_amount": 0,
    "weee_tax_applied_amount": null,
    "shipping_tax_amount": 0,
    "base_shipping_tax_amount": 0,
    "subtotal_incl_tax": 316,
    "shipping_incl_tax": 0,
    "base_shipping_incl_tax": 0,
    "base_currency_code": "USD",
    "quote_currency_code": "USD",
    "items_qty": 6,
    "items": [
        {
            "item_id": 10,
            "price": 68,
            "base_price": 68,
            "qty": 4,
            "row_total": 272,
            "base_row_total": 272,
            "row_total_with_discount": 0,
            "tax_amount": 0,
            "base_tax_amount": 0,
            "discount_amount": 0,
            "base_discount_amount": 0,
            "discount_percent": 0,
            "price_incl_tax": 68,
            "base_price_incl_tax": 68,
            "row_total_incl_tax": 272,
            "base_row_total_incl_tax": 272,
            "options": "[{\"value\":\"1 x Sprite Stasis Ball 65 cm <span class=\\\"price\\\">$27.00<\\/span>\",\"label\":\"Sprite Stasis Ball\"},{\"value\":\"1 x Sprite Foam Yoga Brick <span class=\\\"price\\\">$5.00<\\/span>\",\"label\":\"Sprite Foam Yoga Brick\"},{\"value\":\"1 x Sprite Yoga Strap 8 foot <span class=\\\"price\\\">$17.00<\\/span>\",\"label\":\"Sprite Yoga Strap\"},{\"value\":\"1 x Sprite Foam Roller <span class=\\\"price\\\">$19.00<\\/span>\",\"label\":\"Sprite Foam Roller\"}]",
            "weee_tax_applied_amount": null,
            "weee_tax_applied": null,
            "name": "Sprite Yoga Companion Kit"
        },
        {
            "item_id": 15,
            "price": 22,
            "base_price": 22,
            "qty": 2,
            "row_total": 44,
            "base_row_total": 44,
            "row_total_with_discount": 0,
            "tax_amount": 0,
            "base_tax_amount": 0,
            "tax_percent": 0,
            "discount_amount": 8.8,
            "base_discount_amount": 8.8,
            "discount_percent": 20,
            "price_incl_tax": 22,
            "base_price_incl_tax": 22,
            "row_total_incl_tax": 44,
            "base_row_total_incl_tax": 44,
            "options": "[]",
            "weee_tax_applied_amount": null,
            "weee_tax_applied": null,
            "name": "Radiant Tee-M-Orange"
        }
    ],
    "total_segments": [
        {
            "code": "subtotal",
            "title": "Subtotal",
            "value": 316
        },
        {
            "code": "discount",
            "title": "Discount",
            "value": -117.6
        },
        {
            "code": "shipping",
            "title": "Shipping & Handling",
            "value": 0
        },
        {
            "code": "tax",
            "title": "Tax",
            "value": 0,
            "extension_attributes": {
                "tax_grandtotal_details": []
            }
        },
        {
            "code": "grand_total",
            "title": "Grand Total",
            "value": 198.4,
            "area": "footer"
        }
    ]
    }

    Expected result

    Both items should have their respective discount information. As you can see the bundle product, item_id: 10 in the example, does not have discount_amount, base_discount_amount, percecnt_discount, row_total_with_discount which would be used to properly display line item rows

engcom-Delta commented 2 years ago

Hi @hcmlopes ,

Thanks for providing detailed steps to replicate , after following the steps issue is reproducible. We found that discount_amount, base_discount_amount, percecnt_discount, row_total_with_discount values are missing Hence issue has been confirmed.

Results:

Screenshot 2022-03-22 at 12 43 38 PM Screenshot 2022-03-22 at 12 45 29 PM
github-jira-sync-bot commented 2 years ago

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-2679 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 years ago

:white_check_mark: Confirmed by @engcom-Delta. Thank you for verifying the issue.
Issue Available: @engcom-Delta, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

engcom-Delta commented 2 years ago

Hi @hcmlopes , We had a confirmation from PO this is not a bug or missed requirement, the intended functionality on the dynamic bundle was to NOT calculate its parent and the luma cart was ignoring those fields in case of bundle. Hence we are closing it.

Thanks

engcom-Hotel commented 2 years ago

Hello @hcmlopes,

As per discussion internally we reopening this ticket as a feature request.

Thanks

sebfie commented 2 years ago

Hello, Can we have a patch for that or something to fix it without waiting new version?