Filter Site Option Does Not Work As Expected

In some implementations of the Vinson release of SuiteCommerce Advanced (SCA), site filtering does not work as expected. For example, in NetSuite if you go to Commerce > Websites > Configuration, select the Advanced Tab, and then on the Filter Site Subtab you set the Filter Site option to current, you should only see orders for the current web store when viewing the Purchase History in the My Account home page. But, orders for other web stores from the same account are also listed in the Purchase History. These patch instructions describe how to correct this problem.

To implement this patch, create a custom module to override the SuiteScript Transaction.Model.js file, which is part of the Transaction module.

If you are not familiar with implementing patches for SuiteCommerce Advanced, refer to the following:

Step 1: Create the Override File

Following the instructions and recommendations in the Patch Using Override Mode procedure, create a new directory and file: /Modules/extensions/TransactionExtension@1.0.0/SuiteScript/Transaction.Model.js. In the new Transaction.Model.js file, find and replace the following lines with the provided code sample.

Find these lines:

            if (this.isMultiSite)
                {
                    var site_id = ModelsInit.session.getSiteSettings(['siteid']).siteid
                    ,        filter_site = SC.Configuration.filter_site
                    ,        search_filter_array = null;

                    if (_.isString(filter_site) && filter_site === 'current')
                    {
                             search_filter_array = [site_id, '@NONE@'];
                    }
                    else if (_.isString(filter_site) && filter_site === 'all')
                    {
                             search_filter_array = [];
                    }
                    else if (_.isArray(filter_site))
                    {
                             search_filter_array = filter_site;
                             search_filter_array.push('@NONE@');
                    }


                    if (search_filter_array && search_filter_array.length)
                    {
                             this.filters.site_operator = 'and';
                             this.filters.site = ['website', 'anyof', _.uniq(search_filter_array)];
                    }
                } 

          

And replace them with the following code:

            if (this.isMultiSite)
                {
                    var site_id = ModelsInit.session.getSiteSettings(['siteid']).siteid
                    ,        filter_site = SC.Configuration.filterSite.option
                    , filter_site_id = SC.Configuration.filterSite.ids
                    ,        search_filter_array = null;
                                
                                

                    if (_.isString(filter_site) && filter_site === 'current')
                    {
                                        
                             search_filter_array = [site_id, '@NONE@'];
                    }
                    else if (_.isString(filter_site) && filter_site === 'all')
                    {
                                        
                             search_filter_array = [];
                    }

                    else if (_.isArray(filter_site_id) && filter_site === 'siteIds')
                    {
                                        
                             search_filter_array = filter_site_id;
                             search_filter_array.push('@NONE@');
                    }


                    if (search_filter_array && search_filter_array.length)
                    {
                             this.filters.site_operator = 'and';
                             this.filters.site = ['website', 'anyof', _.uniq(search_filter_array)];
                    }
                } 

          

Step 2: Prepare the Developer Tools For Your Patch

When preparing the Developer Tools for your patch as described in the Patch Using Override Mode procedure, you should:

  1. Paste the following sample code into the new ns.package.json file that you create in the Modules directory: /Modules/extensions/TransactionExtension@1.0.0/ns.package.json

                    {
        "gulp": {
            "ssp-libraries": [
                "SuiteScript/*.js"
            ]
     },
       "overrides": {
          "suitecommerce/Transaction@1.2.0/SuiteScript/Transaction.Model.js" : "SuiteScript/Transaction.Model.js"
       }
    } 
    
                  
  2. Open the distro.json file in the root SuiteCommerce Advanced development directory and then add your custom module to the modules object as described in the Patch Using Override Mode procedure. The following sample shows the value to add to the list of existing values that follow the “modules” key.

                    "modules": {
        "extensions/TransactionExtension": "1.0.0",
        . . . 
    
                  

Step 3: Test and Deploy Your Patch

Follow the instructions provided in the Patch Using Override Mode procedure to test and deploy your patch.

Related Topics

SCA Patches

General Notices