Quantity Pricing Displayed in Web Store Even When “Require Login for Pricing” is Enabled
In some implementations of the Kilimanjaro, Vinson, and Elbrus releases of SuiteCommerce Advanced, quantity pricing displays in the web store even when Require Login for Pricing is enabled.
The following patch corrects a problem in QuantityPricing.View.js, which is part of the QuantityPricing module. To implement this patch, create a custom module to extend the prototype
object for the initialize
function. You can download the code samples described in this procedure here: QuantityPricingAconcaguaCodeSamples..
Before proceeding, familiarize yourself with Best Practices for Customizing SCA.
Step 1: Extend QuantityPricing.View.js
-
Create an extensions directory to store your custom module. Depending on your implementation, this directory might already exist.
-
Within this directory, create a custom module with a name similar to the module being customized.
For example, create
Modules/extensions/QuantityPricing.Extension@1.0.0
. -
In your new QuantityPricing.Extension@1.0.0 directory, create a subdirectory called
JavaScript
.For example:
Modules/extensions/QuantityPricing.Extension@1.0.0/JavaScript
-
In your new JavaScript subdirectory, create a JavaScript file to extend QuantityPricing.View.js.
Name this file according to best practices.
QuantityPricing.View.Extension.js
-
Open this file and extend the
QuanitityPricing.View
method as shown in the following code snippet.define( 'QuantityPricing.View.Extension' , [ 'QuantityPricing.View' , 'QuantityPricing.Utils' , 'SC.Configuration' , 'Profile.Model' , 'Backbone' , 'underscore' ] , function ( QuantityPricingView , QuantityPricingUtils , Configuration , ProfileModel , Backbone , _ ) { 'use strict'; _.extend(QuantityPricingView.prototype, { initialize: function () { this.profileModel = ProfileModel.getInstance(); this._isEnabled = !this.profileModel.hidePrices(); this.price_schedule = QuantityPricingUtils.rearrangeQuantitySchedule(this.model.get('item'), _.isFunction(this.model.getSelectedMatrixChilds) ? this.model.getSelectedMatrixChilds() : []); this.model.on('change', function () { var new_price_schedule = QuantityPricingUtils.rearrangeQuantitySchedule(this.model.get('item'), _.isFunction(this.model.getSelectedMatrixChilds) ? this.model.getSelectedMatrixChilds() : []); if (!_.isEqual(this.price_schedule, new_price_schedule)) { this.price_schedule = new_price_schedule; this.render(); } }, this); this.item_key = this.model.get('item').id + '' + (new Date()).getMilliseconds(); } }); });
-
Save the file.
Step 2: Prepare the Developer Tools For Your Customization
-
Open your new QuantityPricing.Extension@1.0.0 module directory.
-
Create a file in this directory and name it ns.package.json.
Modules/extensions/QuantityPricing.Extension@1.0.0/ns.package.json
-
Paste the following code into your new ns.package.json file:
{ "gulp": { "javascript": [ "JavaScript/*.js" ] } }
-
Open the distro.json file. This is located in your root directory.
-
Add your custom module to the
modules
object.Your code should look similar to the following example:
{ "name": "SuiteCommerce Advanced Aconcagua", "version": "2.0", "isSCA": true, "buildToolsVersion": "sco-2018.1.0", "folders": { "modules": "Modules", "suitecommerceModules": "Modules/suitecommerce", "extensionsModules": "Modules/extensions", "thirdPartyModules": "Modules/third_parties", "distribution": "LocalDistribution", "deploy": "DeployDistribution" }, "modules": { "extensions/QuantityPricing.Extension": "1.0.0", "suitecommerce/Account": "sco-2018.1.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. -
Add
QuantityPricing.Extension
as a dependency to SCA entry point within theSC.Shopping.Starter
andSC.MyAccount.Starter
entrypoints of the JavaScript array.Your Distro.js file should look similar to the following:
"tasksConfig": { //... "javascript": [ //... { "entryPoint": "SC.Shopping.Starter", "exportFile": "shopping.js", "dependencies": [ //... "ProductDetailToQuote", "StoreLocator", "SC.CCT.Html", "QuantityPricing.View.Extension" ], //... { "entryPoint": "SC.MyAccount.Starter", "exportFile": "myaccount.js", "dependencies": [ //... "GoogleMap.Configuration", "StoreLocatorAccessPoints", "SC.CCT.Html", "QuantityPricing.View.Extension" ], //...
-
Save the distro.json file.
Step 3: Test and Deploy Your Customization
-
Test your source code customizations on a local server (see Test SCA Customizations on a Local Server) or deploy them to your NetSuite account (see Deploy SCA Customizations 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, quantity pricing will not display in the web store when Require Login for Pricing is enabled.