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.55k stars 9.32k forks source link

Checkout - Conflict in the discount label #32942

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hey guys,

The checkout is applying the title of the block totals "discount" in the wrong way.

If there is a third-party block in totals_segment containing "discount" as part of the code and it comes before the discount, it is applied instead. (Attachment "checkout-discount.jpg")

Analyzing the code of the file "module-sales-rule/view/frontend/web/js/view/summary/discount.js", line line 60, there is a search with indexOf ('discount').

Preconditions (*)

Magento 2.3.x, 2.4.x

Steps to reproduce (*)

Create any module whose totals code contains "discount" and precede "discount" block.

Expected result (*)

Ideally, change the "return segment.code.indexOf('discount') !== -1;" for "return segment.code == 'discount';" (Attachment "discount-code.jpg")

checkout-discount discount-code

m2-assistant[bot] commented 3 years ago

Hi @dholidev. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

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

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


: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, please join the Community Contributions Triage session to discuss the appropriate ticket.

:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

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

ghost commented 3 years ago

@felipeSoulmkt, pode acompanhar.

felipeSoulmkt commented 3 years ago

perfeito @dholidev, obrigado pela ajuda

m2-assistant[bot] commented 3 years ago

Hi @engcom-Alfa. 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:

m2-assistant[bot] commented 3 years ago

Hi @engcom-Lima. 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-Lima commented 3 years ago

Hi @dholidev,

Unfortunately can't reproduce, Can you please provide me more reproducible steps e.g. which module you are using?

It would be helpful for me in debugging if you can give me more details.

eloom commented 3 years ago

Hi @engcom-Lima,

I cannot provide the module, but we have an assembled environment.

We have a Magento discount rule "Desconto (10 OFF)" and the discount that our payment module offers when the credit card purchase is made in a single payment "Desconto à vista".

Please enter this address "https://m2.eloom.com.br/customer/account/login/", with this access data "m2@eloom.com.br / Papa1mage2to", go to the checkout, choose any shipping method and in the payment choose "Terminado in 1111 (expires: 2023/11)" and in the parcels leave the first one selected.

Note that in the review, both blocks have "Desconto à vista". In the console, type "window.checkoutConfig.totalsData.total_segments" and see that the block "eloom_discount" comes before "discount" (must come before).

This is because of the indexOf of the file "module-sales-rule/view/frontend/web/js/view/summary/discount.js".

Please tell me if you need my help.

Thanks.

engcom-Lima commented 3 years ago

Hi @dholidev

I checked your instance and saw the response in console same which you mentioned in your ticket.

Can you confirm me one thing? your concern is label should be "Desconto (10 OFF)" instead of "Desconto à vista"? Am i right?

eloom commented 3 years ago

Hi @engcom-Lima

Yes, "Desconto (10 OFF)".

If you change the javascript code I mentioned to "return segment.code == 'discount';", both discounts will be correct.

engcom-Lima commented 3 years ago

Hi @dholidev

One more thing please confirm, We have created magento discount rule "Discount (10 OFF)". It is applied as per expected. here i have one more question, it is necessary to install any payment offer module to reproduce this? if yes then tell me about the same so that i can install and try to reproduce for you.

eloom commented 3 years ago

Hi @engcom-Lima,

we cannot provide the payment module causing the conflict.

engcom-Lima commented 3 years ago

Hi @dholidev

As far as it is not an magento issue, it may be due to your payment module specific only. We had worked on the ticket and can't reproduce the issue so We need the reproducible steps. Hence we are closing this ticket.

Please feel free to raise the new ticket or reopen the existing ticket in case of any issue.

Thanks for the understanding !

engcom-Lima commented 3 years ago

Hi @dholidev

As far as it is not an magento issue, it may be due to your payment module specific only. We had worked on the ticket and can't reproduce the issue so We need the reproducible steps. Hence we are closing this ticket.

Please feel free to raise the new ticket or reopen the existing ticket in case of any issue.

Thanks for the understanding !

ghost commented 3 years ago

Hi @engcom-Lima,

The problem lies in Magento's poorly written code logic when using the "indexOf()" method, reported in the first thead. It is not in the payment module.

We will provide this link to agencies and developers using our solution and they will know which side the problem is on.

Thanks for your attention.

eloom commented 3 years ago

@felipeSoulmkt,

conforme pode ver em 2 theads acima, o suporte do Magento finalizou o ticket informando que o problema não está no Magento porque não conseguiu reproduzir o erro em razão de não fornecemos o módulo de pagamento a eles, mesmo montando um ambiente e dando acessos para testarem.

Se analisar o primeira thead deste chamado em que reportamos o problema e com o mínimo conhecimento de lógica de programação, verá que ao varrer o array de segmentos dos totais usando um "indexOf()" é o causador do conflito, visto que qualquer string contendo "discount" satisfaz a busca no trecho de código.

Não iremos alterar os nomes dos blocos de desconto no nosso módulo de pagamento porque o problema está no código mal escrito do Magento.

Abraço