Skip to content

Magento 2.2.3 TypeErrors Cannot read property 'quoteData' / 'storecode' / 'sectionLoadUrl' of undefined  #14412

Closed
@brvm

Description

@brvm

Preconditions

  1. Magento 2.2.3
  2. PHP 7.0
  3. MySQL 5.5.38

Steps to reproduce

  1. Create a module in app/code/vendor
  2. Add checkout_cart_index.xml in templates folder under /view/frontend/layout
  3. Add following code:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <link src="Vendor_Module/js/jquery.cartAjaxQty.js"/>
    </head>
</page>
  1. Add .js-file under /view/frontend/web/js called jquery.cartAjaxQty.js
require(['jquery',
    'domReady!',
    'Magento_Checkout/js/model/totals',
    'Magento_Checkout/js/view/summary/abstract-total',
    'Magento_Customer/js/customer-data',
    'Magento_Checkout/js/model/quote',
    'Magento_Catalog/js/price-utils',
    'Magento_Checkout/js/action/get-totals'], function () {
    jQuery(document).ready(function($){

        $(".cart-container .form-cart .action.update").remove();
        jQuery('#shopping-cart-table')
            .on(
                'change',
                'input[name$="[qty]"]',
                function(){
                    console.log("quantity changed");
                    var form = jQuery(jQuery(this).closest('form'));

                    $.ajax({
                        url: form.attr('action'),
                        data: form.serialize(),
                        type: 'post',
                        showLoader: true,
                        context: this.changedInput,
                        success: function (res) {
                            // var parsedResponse = $.parseHTML(res);
                            // var result = $(parsedResponse).find("#form-validate");
                            // $("#form-validate").replaceWith(result);
                            //
                            console.log('Ajax succes function completed');
                        },
                        error: function (xhr, status, error) {
                            var err = eval("(" + xhr.responseText + ")");
                            console.log(err.Message);
                        }
                    });

                }
            );
    });
});
  1. Add .js file to requirejs-config.js located in root frontend folder in module under /view/frontend
var config = {
    map: {
        '*': {
            ajaxQty: 'Vendor_Module/js/jquery.cartAjaxQty'
        }
    }
};
  1. Run

php bin/magento setup:upgrade

  1. Add item to cart and change the quantity in the input box on the cart page.

Expected result

  1. The .js code should load and requirements should be loaded properly
  2. When quantity changes it should output this in the console

(and later on I want to add code to reload the summary, that's why there are all those requirements in the require[])

Actual result

  1. Three different errors (sometimes displaying all in console, mostly one or two of the three) caused by most of the requirements:

screen shot 2018-03-28 at 11 43 54
screen shot 2018-03-28 at 11 44 19
screen shot 2018-03-28 at 11 44 28

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: FrontendComponent: CheckoutFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions