In implementations of Elbrus, 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.
To implement this patch, you must override the
events object of the Cart.AddToCart.Button.View.js file, located in the Cart module. Because of the type of change that you need to make to the View file, you must override the view instead of extending it. You can download the code samples described in this procedure here: AddtoCartButtonDoesNotWork.zip.
prototype object. This improves the chances that your customizations continue to work when migrating to a newer version of SuiteCommerce Advanced. However, this patch requires you to modify a file in a way that you cannot extend, and therefore requires you to use a custom module to override the existing module file. For more information, see Customize and Extend Core SuiteCommerce Advanced Modules.
Step 1: Create the Cart.AddToCart.Button.View.js Override File
This step shows how to override the Cart.AddToCart.Button.View.js file, located in the Cart module.
If you have not done so already, 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:
In your new
Cart.Extension@1.0.0 directory, create a subdirectory called
In 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'
Save the file.
Step 2: Prepare the Developer Tools For Your Customization
This step shows how to set up the ns.package.json file for your custom module and modify distro.json 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:
Build the ns.package.json file using the following code:
In distro.json, add your custom modules to the
Your code should look similar to the following example:
"name": "SuiteCommerce Advanced Elbrus",
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.
Step 3: Test and Deploy Your Customization
Test your source code customizations on a local server (see SCA on a Local Server) or deploy them to your NetSuite account (see Deploy to NetSuite). If you are currently running SCA on a local server, your changes should appear on your local site immediately.
Confirm your results.
Upon successful deployment, the Add to Cart button works with one click.