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

Adminhtml - Product with custom option date [required] when creating an order via admin #36423

Open kestraly opened 2 years ago

kestraly commented 2 years ago

Preconditions and environment

Steps to reproduce

- Set Date as drop down in Stores > Configuration > Catalog > [Date & Time Custom Options] Date Fields Order - Day / Month / Year Save

- Catalog > Products > Select or add a new product Add a date custom option to a product with date.phtml as required

- Sales > Order Create a new order, with new customer Select Add Products Select the product with the required custom option date

Expected result

Be able to select date and press continue and process the order.

Actual result

Console logs javascript syntax error closing of }

./vendor/magento/module-catalog/view/adminhtml/templates/catalog/product/composite/fieldset/options/type/date.phtml

Checking in ./var/view_preprocessed/pub/static/vendor/magento/module-catalog/view/adminhtml/templates/catalog/product/composite/fieldset/options/type/date.phtml- line 63 is escaped with //

jQuery.validator.addMethod('validate-datetime-

Becomes

// jQuery.validator.addMethod('validate-datetime-

Removing line 59 //<![CDATA[ and line 91//]]> in date.phtml fixes the syntax error

The product cannot be added to the order and a work around must be employed

Additional information

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @kestraly. 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

kestraly commented 2 years ago

@magento give me 2.4-develop instance

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

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

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

Hi @kestraly, here is your Magento Instance: https://c5930c694d6c0d2be495a0fbda0bc0ab.instances.magento-community.engineering Admin access: https://c5930c694d6c0d2be495a0fbda0bc0ab.instances.magento-community.engineering/admin_76d7 Login: 7c82a08d Password: d9eec1f3fcc6

kestraly commented 2 years ago

Error is reproduced, but allowed to add to cart with single option

Uncaught SyntaxError: Unexpected token '}' at legacy-build.min.js:1:9878 at Array.map () at Array.collect (legacy-build.min.js:1:19426) at String.evalScripts (legacy-build.min.js:1:9845) at legacy-build.min.js:1:6086

require([
                "jquery",
                "mage/backend/validation"
            ], function(jQuery){

                //<![CDATA[                jQuery.validator.addMethod('validate-datetime-1', function(v) {
                    var dateTimeParts = jQuery('.datetime-picker[id^="options_1"]');
                    for (var i=0; i < dateTimeParts.length; i++) {
                        if (dateTimeParts[i].value == "") return false;
                    }
                    return true;
                }, 'This\u0020is\u0020a\u0020required\u0020option.');                //]]>

            });
m2-assistant[bot] commented 2 years ago

Hi @engcom-Dash. 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-Dash commented 2 years ago

@magento give me 2.4-develop instance

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

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

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

Hi @engcom-Dash, here is your Magento Instance: https://c5930c694d6c0d2be495a0fbda0bc0ab.instances.magento-community.engineering Admin access: https://c5930c694d6c0d2be495a0fbda0bc0ab.instances.magento-community.engineering/admin_ab2f Login: 7439b8d7 Password: f88d2d8fc1c7

engcom-Dash commented 2 years ago

@magento give me 2.4-develop instance

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

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

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

Hi @engcom-Dash, here is your Magento Instance: https://c5930c694d6c0d2be495a0fbda0bc0ab.instances.magento-community.engineering Admin access: https://c5930c694d6c0d2be495a0fbda0bc0ab.instances.magento-community.engineering/admin_5dc3 Login: 5da09c54 Password: ba7e07e13eb1

engcom-Dash commented 2 years ago

Hi @kestraly ,

We are trying to reproduce the issue in 2.4-develop branch...we are not able to reproduce the issue.we are getting expected results. Steps: 1.Stores > Configuration > Catalog > [Date & Time Custom Options] Date Fields Order - Day / Month / Year

  1. Sales > Order Create a new order, with new customer Select Add Products Select the product with the required custom option date

Magento version 2.4-develop PHP 7.4

We are able place the order successfully

Let us know if we missing anything!!! Thanks!!!

kestraly commented 2 years ago

@engcom-Dash Whilst selecting date, if you check your console in the browser, you’ll see the JS error. It basically stops the validation process, which in turn breaks adding further custom options.

The bigger issue is how pre_processed files is handled.

I can add imagery if required

kestraly commented 2 years ago

Image of the error that appears in console.

plJ8Q4.md.jpg

It definitely breaks custom options. Please review your console @engcom-Dash whilst adding the custom option to basket. Then review the line to see that addMethod is becoming ommited //<![CDATA[ jQuery.validator.addMethod('validate-datetime-1', function(v) {

engcom-Dash commented 2 years ago

@magento give me 2.4-develop instance

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

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

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

Hi @engcom-Dash, here is your Magento Instance: https://c5930c694d6c0d2be495a0fbda0bc0ab.instances.magento-community.engineering Admin access: https://c5930c694d6c0d2be495a0fbda0bc0ab.instances.magento-community.engineering/admin_ff47 Login: 052a2869 Password: 418e75ac7e9e

engcom-Dash commented 2 years ago

Hi @kestraly , Thanks For your Information!!! We are Worked as per your last comment...We are also getting same JS error in console.So we are confirming the issue.

Precondition: Magento Version 2.4-develop PHP 8.1 Magento installed with custom date module. Steps To reproduce: 1.Set Date as drop down in Stores > Configuration > Catalog > [Date & Time Custom Options] 2.set the Date Fields Order - Day / Month / Year 3.save and clear cache 4.go to Catalog > Products > Select or add a new product 5.Add a date custom option to a product with date.phtml as required 6.go to Sales > Order 7.Create a new order, with new customer 8.Select add products 9.Select the product with the required custom option date we are gettingJjs error in console as per-actual result. Screenshots:

Screenshot 2022-11-09 at 2 39 54 PM

Error is reproduced, but allowed to add to cart with single option

Uncaught SyntaxError: Unexpected token '}' at legacy-build.min.js:1:9878 at Array.map () at Array.collect (legacy-build.min.js:1:19426) at String.evalScripts (legacy-build.min.js:1:9845) at legacy-build.min.js:1:6086

Let us know if we missing anything !!!

Thanks!!!

github-jira-sync-bot commented 2 years ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 2 years ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 2 years ago

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

m2-assistant[bot] commented 2 years ago

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

JeromeBeckett commented 10 months ago

We just encountered this. Still an issue in 2.4.6-p3 and 2.4.7-beta2.

RetroProgrammist commented 10 months ago

patch.zip Patch for Unexpected token '}' error How use it https://experienceleague.adobe.com/docs/commerce-operations/upgrade-guide/patches/apply.html?lang=en#composer

andrewbess commented 10 months ago

Hello @RetroProgrammist I think it would be better to wrap CDATA component using other commenting style For example: /*<![CDATA[*/

I am going to prepare the PR to resolve this problem

andrewbess commented 10 months ago

@magento I am working on it