Skip to content

Last Ordered Items block - bad js code #13157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Eytham opened this issue Jan 12, 2018 · 4 comments
Closed

Last Ordered Items block - bad js code #13157

Eytham opened this issue Jan 12, 2018 · 4 comments
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@Eytham
Copy link

Eytham commented Jan 12, 2018

The left block Last Ordered Items is not showing properly the Add to cart button on the :
data-bind="css: {'no-display': !lastOrderedItems().isShowAddToCart}
Always returning false.
Target JS file is : Magento_Sales/web/js/view/last-ordered-items.js

Preconditions

  1. Environnement Docker NGINX php 7
  2. Magento 2.2

Steps to reproduce

  1. In my account or in catalog, left block Last ordered items not showing properly for add to cart button

Expected result

  1. Add to cart button viewable to add last ordered items to cart

Actual result

  1. lastOrderedItems().isShowAddToCart always returning FALSE so the add to cart div actions stands with no-display CSS class

Original Code of Magento_Sales/web/js/view/last-ordered-items.js

define([
    'uiComponent',
    'Magento_Customer/js/customer-data'
], function (Component, customerData) {
    'use strict';

    return Component.extend({
        /** @inheritdoc */
        initialize: function () {
            var isShowAddToCart = false,
                item;

            this._super();
            this.lastOrderedItems = customerData.get('last-ordered-items');
            
            for (item in this.lastOrderedItems.items) {
                if (item['is_saleable']) {
                    isShowAddToCart = true;
                    break;
                }
            }

            this.lastOrderedItems.isShowAddToCart = isShowAddToCart;
        }
    });
});

My correction Code :

define([
    'uiComponent',
    'Magento_Customer/js/customer-data',
    'jquery'
], function (Component, customerData, $) {
    'use strict';

    return Component.extend({
        /** @inheritdoc */
        initialize: function () {
            var isShowAddToCart = false,
                item;
            
            this._super();
            this.lastOrderedItems = customerData.get('last-ordered-items');
            
            var self = this;
            $(this.lastOrderedItems().items).each(function(){
                if(this['is_saleable']) {
                    self.lastOrderedItems().isShowAddToCart = true;
                }
            });
        }
    });
});
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jan 12, 2018
@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Jan 13, 2018

@Eytham could you please create Pull request with your changes? It will be much easier to review your changes because we will see diff, all type of tests will be executed

@magento-engcom-team magento-engcom-team added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Feb 16, 2018
@magento-engcom-team
Copy link
Contributor

@Eytham, thank you for your report.
We've acknowledged the issue and added to our backlog.

omiroshnichenko added a commit to omiroshnichenko/magento2 that referenced this issue Nov 2, 2018
omiroshnichenko added a commit to omiroshnichenko/magento2 that referenced this issue Nov 6, 2018
omiroshnichenko added a commit to omiroshnichenko/magento2 that referenced this issue Nov 13, 2018
@sidolov
Copy link
Contributor

sidolov commented Nov 22, 2018

Hi @Eytham. Thank you for your report.
The issue has been fixed in #19039 by @omiroshnichenko in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.1 release.

@sidolov sidolov added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Nov 22, 2018
@sidolov sidolov closed this as completed Nov 22, 2018
magento-engcom-team added a commit that referenced this issue Nov 22, 2018
 - Merge Pull Request #19039 from omiroshnichenko/magento2:13157
 - Merged commits:
   1. c333367
   2. 4803537
   3. 7c9de8e
   4. eaaed4b
gelanivishal pushed a commit to gelanivishal/magento2 that referenced this issue Nov 23, 2018
gelanivishal pushed a commit to gelanivishal/magento2 that referenced this issue Nov 23, 2018
gelanivishal pushed a commit to gelanivishal/magento2 that referenced this issue Nov 23, 2018
@magento-engcom-team
Copy link
Contributor

Hi @Eytham. Thank you for your report.
The issue has been fixed in #19357 by @gelanivishal in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.8 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Nov 24, 2018
magento-engcom-team added a commit that referenced this issue Nov 24, 2018
#19357

 - Merge Pull Request #19357 from gelanivishal/magento2:2.2-develop-PR-port-19039
 - Merged commits:
   1. 7559e3e
   2. 58550b9
   3. f1bb98e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

4 participants