Standard Promotion with Inline Discount and Rate as Percentage Not Updating the Amount in Checkout

This topic applies to

Applies to

Vinson | Mont Blanc | Denali

In some implementations of the Vinson, Mont Blanc, and Denali releases of SuiteCommerce Advanced, the amount in checkout is not updating when applying a standard promotion with an inline discount and the rate as percentage.

The following patch corrects a problem in ItemViews.Cell.Navigable.View.js, which is part of the ItemViews module. To implement this patch, create a custom module to extend the prototype object for the getContext() method. You can download the code samples described in this procedure here: ItemViews.Cell.Navigable.View.Extension@1.0.0–Vinson.zip.

Note

Before proceeding, familiarize yourself with Best Practices for Customizing SuiteCommerce Advanced.


Step 1: Extend ItemViews.Cell.Navigable.View.js

  1. Create an extensions directory to store your custom module. Depending on your implementation, this directory might already exist.

  2. Within this directory, create a custom module with a name similar to the module being customized.

    For example: Modules/extensions/ItemViews.Cell.Navigable.View.Extension@1.0.0.

  3. Open your new ItemViews.Cell.Navigable.View.Extension@1.0.0 module and create a subfolder titled JavaScript.

    For example: Modules/extensions/ItemViews.Cell.Navigable.View.Extension@1.0.0/JavaScript

  4. In your new JavaScript subdirectory, create a JavaScript file to extend ItemViews.Cell.Navigable.View.js.

    Name this file according to best practices.

    For example: ItemViews.Cell.Navigable.View.Extension.js

  5. Open this file and extend the getContext() function as shown in the following code snippet.

    define('ItemViews.Cell.Navigable.View.Extension' , [ 'ItemViews.SelectedOption.View' ] , function ( ItemViewsSelectedOptionView ) { 'use strict'; _.extend(ItemViews.Cell.Navigable.View.prototype, { getContext: function () { var item = this.model.get('item') , line = this.model; //@class ItemViews.Navigable.View.Context return { //@property {String} itemId itemId: item.get('internalid') //@property {String} itemName , itemName: item.get('_name') //@property {String} cellClassName , cellClassName: this.options.cellClassName //@property {Boolean} isNavigable , isNavigable: !!this.options.navigable && !!item.get('_isPurchasable') //@property {String} rateFormatted , rateFormatted: line.get('rate_formatted') //@property {String} itemSKU , itemSKU: item.get('_sku') //@property {Boolean} showOptions , showOptions: !!(line.get('options') && line.get('options').length) //@property {String} itemImageURL , itemImageURL: item.get('_thumbnail').url //@property {String} itemImageAltText , itemImageAltText: item.get('_thumbnail').altimagetext //@property {String} itemURLAttributes , itemURLAttributes: item.get('_linkAttributes') //@property {Number} quantity , quantity: line.get('quantity') //@property {Boolean} showDetail2Title , showDetail2Title: !!this.options.detail2Title //@property {String} detail2Title , detail2Title: this.options.detail2Title //@property {String} detail2 , detail2: line.get(this.options.detail2) //@property {Boolean} showReason , showBlockDetail2: !!line.get(this.options.detail2) //@property {Boolean} showDetail3Title , showDetail3Title: !!this.options.detail3Title //@property {String} detail3Title , detail3Title: this.options.detail3Title //@property {String} detail3 , detail3: line.get('amount') > line.get('total') ? line.get('total_formatted') : line.get(this.options.detail3) //@property {Boolean} showComparePrice , showComparePrice: line.get('amount') > line.get('total') //@property {String} comparePriceFormatted , comparePriceFormatted: line.get('amount_formatted') }; } } });
  6. Save the file.

Step 2: Prepare the Developer Tools For Your Customization

  1. Open your new ItemViews.Cell.Navigable.View.Extension@1.0.0 module directory.

  2. Create a file in this directory titled ns.package.json.

    Modules/extensions/ItemViews.Cell.Navigable.View.Extension@1.0.0/ns.package.json

  3. Paste the following code into your new ns.package.json file:

    { "gulp": { "javascript":[ "JavaScript/*.js" ] } }
  4. Open the distro.json file. This is located in your root directory.

  5. Add your custom modules to the modules object.

    Your code should look similar to:

    { "name": "SuiteCommerce Advanced Vinson Release", "version": "2.0", "buildToolsVersion": "1.2.1", "folders": { "modules": "Modules", "suitecommerceModules": "Modules/suitecommerce", "extensionsModules": "Modules/extensions", "thirdPartyModules": "Modules/third_parties", "distribution": "LocalDistribution", "deploy": "DeployDistribution" }, "modules": { "extensions/ItemViews.Cell.Navigable.View.Extension": "1.0.0", "suitecommerce/Account": "2.2.0", ...

    This step ensures that the Gulp tasks include your modules 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.

  6. Save the distro.json file.

Step 3: Test and Deploy Your Customization

  1. 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.

  2. Confirm your results.

    Upon successful deployment, the amount displays on checkout pages when applying standard promotion with inline discount and the rate set as a percentage.

Related Topics