In Elbrus version, clicking the Add to Cart button once does not actually add the chosen items to the cart. Instead, users must click this button twice. This error only occurs if the focus is on the Quantity field.
Step 1: Create the Cart.AddToCart.Button.View.js override file:
- To override the Cart.AddToCart.Button.View.js file, located in the Cart module, create a directory to store your custom module.
- Open this directory and create a subdirectory to maintain your customizations.Give this directory a name similar to the module being customized. For example:
Modules/extensions/Cart.Extension@1.0.0 - In your new
Cart.Extension@1.0.0directory, create a subdirectory calledJavaScript.Modules/extensions/Cart.Extension@1.0.0/JavaScript - Copy the following file into the new JavaScript directory:
Modules/suitecommerce/Cart@X.Y.Z/JavaScript/Cart.AddToCart.Button.View.jsIn this case, X.Y.Z represents the version of the module in your implementation of SuiteCommerce Advanced. - Open Cart.AddToCart.Button.View.js and make the following change:Locate the following line in the new file:
'click [data-type="add-to-cart"]': 'addToCart'
Replace the line with the following lines:
'mouseup [data-type="add-to-cart"]': 'addToCart'
, 'click [data-type="add-to-cart"]': 'addToCart'
6. Save the file.
Step 2: Prepare the Developers Tools For Customization
- To make sure that the Gulp tasks include your modules when you deploy, open the Modules/extensions/Cart.Extension@1.0.0 module directory.
- Create a file in this directory and name it ns.package.json:
Modules/extensions/Cart.Extension@1.0.0/ns.package.json - Build the ns.package.json file using the following code:
{
"gulp": {
"javascript": [
"JavaScript/*.js"
]
},
"overrides": {
"suitecommerce/Cart@X.Y.Z/JavaScript/Cart.AddToCart.Button.View.js" : "JavaScript/Cart.AddToCart.Button.View.js"
}
}
In distro.json, add your custom modules to the modules object.
Your code should look similar to the following example:
{
"name": "SuiteCommerce Advanced Elbrus",
"version": "2.0",
"buildToolsVersion": "1.3.0",
"folders": {
"modules": "Modules",
"suitecommerceModules": "Modules/suitecommerce",
"extensionsModules": "Modules/extensions",
"thirdPartyModules": "Modules/third_parties",
"distribution": "LocalDistribution",
"deploy": "DeployDistribution"
},
"modules": {
"extensions/Cart.Extension": "1.0.0",
"extensions/MyExampleCartExtension1": "1.0.0",
...
This ensures that the Gulp tasks include your module when you deploy. In this example, the custom modules are added at the beginning of the list of modules. However, you can add the modules anywhere in the modules object. The order of precedence in this list does not matter.
Save the distro.json file.
Then save and test the changes locally. After deployment the ADD TO CART button will work.