Currencies Change to the Default in the Shopping Application

In some implementations of SuiteCommerce Advanced using multi-subsidiaries, users cannot change the currency on the site. The webstore continues to use the default currency.

The following patch corrects the GlobalViews.CurrencySelector.View.js, which is part of the GlobalViews 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: CurrenciesChangeToDefault-Kilimanjaro.zip.

Step 1: Extend GlobalViews.CurrencySelector.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 that is unique but similar to the module being customized.

    For example: Modules/extensions/GlobalViewsExtension@1.0.0.

  3. Open your new GlobalViewsExtension@1.0.0 module and create a subfolder titled JavaScript.

    For example: Modules/extensions/GlobalViewsExtension@1.0.0/JavaScript

  4. In your new JavaScript subdirectory, create a JavaScript file to extend GlobalViews.CurrencySelector.View.js .

    Name this file according to best practices.

    For example: GlobalViews.CurrencySelector.View.Extend.js

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

                    define(
       'GlobalViews.CurrencySelector.View.Extend'
    ,   [
          'GlobalViews.CurrencySelector.View'
    
       ,   'Backbone'
       ,   'underscore'
       ]
    ,   function(
          GlobalViewsCurrencySelectorView
    
       ,   Backbone
       ,   _
       )
    {
       'use strict';
    
       _.extend(GlobalViewsCurrencySelectorView.prototype,
            {
             getContext: function()
             {
                var available_currencies = _.map(SC.ENVIRONMENT.availableCurrencies, function(currency)
                {
                   // @class GlobalViews.CurrencySelector.View.Context.Currency
                   return {
                      // @property {String} code
                      code: currency.code
                      // @property {String} internalId
                   ,   internalId: currency.internalid
                      // @property {String} isDefault
                   ,   isDefault: currency.isdefault
                      // @property {String} symbol
                   ,   symbol: currency.symbol
                      // @property {Boolean} symbolPlacement
                   ,   symbolPlacement: currency.symbolplacement
                      // @property {String} displayName
                   ,   displayName: currency.title || currency.name
                      // @property {Boolean} isSelected
                   ,   isSelected: SC.getSessionInfo('currency').code === currency.code
                   };
                });
    
                // @class GlobalViews.CurrencySelector.View.Context
                return {
                   // @property {Boolean} showCurrencySelector
                   showCurrencySelector: !!(SC.ENVIRONMENT.availableCurrencies && SC.ENVIRONMENT.availableCurrencies.length > 1)
                   // @property {Array<GlobalViews.CurrencySelector.View.Context.Currency>} availableCurrencies
                ,   availableCurrencies: available_currencies || []
                   // @property {String} currentCurrencyCode
                ,   currentCurrencyCode: SC.getSessionInfo('currency').code
                   // @property {String} currentCurrencySymbol
                ,   currentCurrencySymbol: SC.getSessionInfo('currency').symbol
                };
             }
        });
    }); 
    
                  
  6. Save the file.

Step 2: Prepare the Developer Tools For Your Customization

  1. Open your new Transaction.Line.Views.Extension@1.0.0 module directory.

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

    Modules/extensions/Transaction.Line.Views.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 module to the modules object.

    Your code should look similar to:

                    {
        "name": "SuiteCommerce Advanced Kilimanjaro",
        "version": "2.0",
        "isSCA": true,
        "buildToolsVersion": "1.3.1",
        "folders": {
            "modules": "Modules",
            "suitecommerceModules": "Modules/suitecommerce",
            "extensionsModules": "Modules/extensions",
            "thirdPartyModules": "Modules/third_parties",
            "distribution": "LocalDistribution",
            "deploy": "DeployDistribution"
        },
        "modules": {
            "extensions/GlobalViewsExtension": "1.0.0",
            "extensions/MyExampleCartExtension1": "1.0.0", 
                 ... 
    
                  

    This step 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.

  6. Save the distro.json file.

Step 3: Test and Deploy Your Customization

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

  2. Confirm your results.

    Upon successful deployment, Checkout Summary pages should display correct original and discounted sub-total amounts. Strike-through amounts also display correctly.

Related Topics

SCA Patches

General Notices