Closed
Description
Preconditions
- Magento 2.2.3
- PHP 7.0
- MySQL 5.5.38
Steps to reproduce
- Create a module in app/code/vendor
- Add checkout_cart_index.xml in templates folder under /view/frontend/layout
- 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>
- 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);
}
});
}
);
});
});
- 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'
}
}
};
- Run
php bin/magento setup:upgrade
- Add item to cart and change the quantity in the input box on the cart page.
Expected result
- The .js code should load and requirements should be loaded properly
- 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
- Three different errors (sometimes displaying all in console, mostly one or two of the three) caused by most of the requirements:
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.2 release lineThe issue has been fixed in 2.3 release lineGate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.3 release