Address Not Set for Orders for Unfulfillable Items

In some implementations of the Kilimanjaro release of SuiteCommerce Advanced (SCA), the default address is not set for orders for unfulfillable (service or downloaded) items. Because the default address fields cannot be empty in the final order record, items are cleared from the shopping cart after tax recalculation if SuiteTax is disabled and the address is outside the US.

These patch instructions describe how to prevent the default address field from being not set for orders for service or items that are downloaded.

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

If you are unfamiliar with implementing patches for SCA, refer to the following:

Step 1: Create the Override File

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

Find the following code:

            setShippingAddress: function setShippingAddress (data, current_order)
      {
         if (data.shipaddress !== current_order.shipaddress)
         {
            if (data.shipaddress)
            {
               if (this.isSecure && !~data.shipaddress.indexOf('null'))
               {
                  // Heads Up!: This "new String" is to fix a nasty bug
                  ModelsInit.order.setShippingAddress(new String(data.shipaddress).toString());
               }
               else
               {
                  var address = _.find(data.addresses, function (address)
                  {
                     return address.internalid === data.shipaddress;
                  });

                  address && ModelsInit.order.estimateShippingCost(address);
               }
            }
            else if (this.isSecure)
            {
               ModelsInit.order.removeShippingAddress();
            }
            else
            {
               ModelsInit.order.estimateShippingCost({
                  zip: null
               ,   country: null
               });
               ModelsInit.order.removeShippingMethod();
            }
         }
      } 

          

And replace it with the following code:

            setShippingAddress: function setShippingAddress (data, current_order)
      {
         if (data.shipaddress !== current_order.shipaddress)
         {
            if (data.shipaddress)
            {
               if (this.isSecure && !~data.shipaddress.indexOf('null'))
               {
                  // Heads Up!: This "new String" is to fix a nasty bug
                  ModelsInit.order.setShippingAddress(new String(data.shipaddress).toString());
               }
               else
               {
                  var address = _.find(data.addresses, function (address)
                  {
                     return address.internalid === data.shipaddress;
                  });

                  address && ModelsInit.order.estimateShippingCost(address);
               }
            }
            else if (this.isSecure)
            {
               if(ModelsInit.context.getSetting('FEATURE', 'tax_overhauling') === 'T')
               {
                  ModelsInit.order.removeShippingAddress();
               }
            }
            else
            {
               ModelsInit.order.estimateShippingCost({
                  zip: null
               ,   country: null
               });
               ModelsInit.order.removeShippingMethod();
            }
         }
      } 

          

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, perform the following actions:

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

                    { "gulp": { "javascript": [ "JavaScript/*.js" ] }, "overrides": { "suitecommerce/LiveOrder@X.Y.Z/JavaScript/LiveOrder.Model.js" : "JavaScript/LiveOrder.Model.js" }
    } 
    
                  
    Important:

    You must replace the string, X.Y.Z, with the version of the module in your implementation of SCA.

  2. Open the distro.json file in the root SCA 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/LiveOrderExtension": "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