Incorrect Value for Shipping Estimate Occurs in Shopping Cart

In some implementations of the Elbrus release of SuiteCommerce Advanced, a value of $0.00 appears for the shipping estimate when calculating the actual estimated value for shipping. As a result, this indicates an incorrect value of shipping while SuiteCommerce is calculating the actual shipping value. This error occurs if you use SiteBuilder Extensions to create the site.

The following patch corrects a problem in Cart.Detailed.View.js, which is part of the Cart module. To implement this patch, create a custom module to extend the prototype object for the estimateTaxShip() method. You can download the code samples described in this procedure here: IncorrectValueforEstimateOccursinShoppingCart.zip.

Note:

Before proceeding, familiarize yourself with Best Practices for Customizing SCA.

Step 1: Extend Cart.Detailed.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, create Modules/extensions/Cart@1.0.0.

  3. In your new Cart@1.0.0 directory, create a subdirectory called JavaScript.

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

  4. In your new JavaScript subdirectory, create a JavaScript file to extend Cart.Detailed.View.js.

    Name this file according to best practices. For example:

    Cart.Detailed.View.Extension.js

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

                    define('Cart.Detailed.View.Extension'
     ,   [   'Utils'
        ,   'underscore'
       ,   'Backbone'
       ]
       ,   function (
       ,   Utils
       ,   _
       ,   Backbone
    
       ,   jQuery
       )
    {
       'use strict';
    
       _.extend(estimateTaxShip.prototype: function estimateTaxShip(e),
          {
    
               // Build this code in a text editor to make sure that the indents are correct. 
              {
                  var options = this.$(e.target).serializeObject()
                    ,    address_internalid = options.zip + '-' + options.country + '-null'
                    ,    self = this;
    
                    e.preventDefault();
    
                    var address = {
                        internalid: address_internalid
                        ,   zip: options.zip
                        ,   country: options.country
                    };
    
                     // Render method should not fire right now, the accordion must close when the promise resolves. 
                    this.model.set('shipaddress', address_internalid, {silent: true}); 
                    this.$('.cart-summary-button-estimate').text(_('Estimating...').translate());
                    this.$('.cart-summary-button-estimate').prop('disabled', true);
                    var promise = this.saveForm(e);
     
                    if (promise)
                    {
                        promise.then(function() 
                        {
                          var address_internalid = self.model.get('shipaddress');
                           self.model.set('shipaddress', address_internalid); 
                           self.$('.cart-summary-button-estimate').text(_('Estimate').translate());
                           self.$('.cart-summary-button-estimate').prop('disabled', false);
                           self.swapEstimationStatus();
                        });
                    }                      
       
       }); 
    
                  
  6. Save the file.

Step 2: Prepare the Developer Tools For Your Customization

  1. Open your new Cart@1.0.0 module directory.

  2. Create a file in this directory and name it ns.package.json.

    Modules/extensions/Cart@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 the following example:

                    {
        "name": "SuiteCommerce Advanced Elbrus",
        "version": "2.0",
        "buildToolsVersion": "1.3.0",
        "folders": {
            "modules": "Modules",
            "suitecommerceModules": "Modules/suitecommerce",
            "extensionsModules": "Modules/extensions",
            "thirdPartyModules": "Modules/third_parties",
            "distribution": "LocalDistribution",
            "deploy": "DeployDistribution"
        },
        "modules": {
              "extensions/Cart.Extension": "1.0.0",
            "extensions/MyExampleCartExtension1": "1.0.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.

  6. Add Cart.Extension as a dependency to SCA entry point within the SC.Shopping.Starter entrypoint of the JavaScript array.

    Your Distro.js file should look similar to the following:

                     "tasksConfig": {
    //...
    "javascript": [
             //...
             {
                   "entryPoint": "SC.Checkout.Starter", 
                   "exportFile": "checkout.js",
                   "dependencies": [
                      //...
                         "Cart.Extension",
                         //...
                   ],
                               //... 
    
                  
  7. 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, the estimated shipping does not display a value until the calculation is complete.

Related Topics

SCA Patches

General Notices