Bronto Cart Recovery Link Redirects to Blank Page

This topic applies to

Applies to

SuiteCommerce Advanced | Kilimanjaro | Elbrus

 

In some implementations of the Kilimanjaro and Elbrus releases of SuiteCommerce Advanced, the link provided in the Bronto cart recovery email redirects to a blank page.

The following patch corrects a problem in Utils.js, which is part of the Utilities module and in productDetails.Router.js, which is a part of the ProductDetails module. To implement these patches, create custom modules to extend the prototype object for the parseUrlOptions() and productDetailsRouter() methods. You can download the code samples described in this procedure here: BrontoCartRecoveryLinkRedirects—ElbrusSample.zip.

Note

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


Step 1: Extend Utils.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/UtilitiesExtension@1.0.0.

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

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

  4. In your new JavaScript subdirectory, create a JavaScript file to extend Utils.js.

    Name this file according to best practices.

    For example: Utils.Extension.js

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

    define('Utils.Extension' , [ 'Utils' , 'jQuery' , 'underscore' , 'Backbone' , 'String.format' , 'Backbone.Validation' ] , function ( Utils , jQuery , _ , Backbone ) { 'use strict'; _.extend(Utils.prototype, function parseUrlOptions(options_String) { options_string = options_string || ''; if (~options_string.indexOf('?')) { options_string = _.last(options_string.split('?')); } if (~options_string.indexOf('#')) { options_string = _.first(options_string.split('#')); } var options = {}; if (options_string.length > 0) { var tokens = options_string.split(/\&/g) , current_token; while (tokens.length > 0) { current_token = tokens.shift().split(/\=/g); if (current_token[0].length === 0) { continue; } try{ options[current_token[0]] = decodeURIComponent(current_token[1]); }catch(e){ options[current_token[0]] = current_token[1]; } } } return options; }); });
  6. Save the file.

Step 2: Extend ProductDetails.Router.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/ProductDetailsExtension@1.0.0.

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

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

  4. In your new JavaScript subdirectory, create a JavaScript file to extend ProductDetails.Router.js.

    Name this file according to best practices.

    For example: ProductDetails.Router.Extension.js

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

    define( 'ProductDetails.Router.Extension' , [ 'ProductDetails.Router' , 'Product.Model' , 'ProductDetails.Full.View' , 'ProductDetails.QuickView.View' , 'underscore' , 'Backbone' , 'AjaxRequestsKiller' , 'Utils' ] , function ( ProductDetailsRouter , ProductModel , ProductDetailsFullView , ProductDetailsQuickView , _ , Backbone , AjaxRequestsKiller , Utils ) { 'use strict'; _.extend(productDetailsRouter.prototype, function productDetailsByUrl(url){ { try{ url = decodeURIComponent(url); }catch(e){ //do nothing } // if there are any options in the URL var options = null; if (~url.indexOf('?')) { options = Utils.parseUrlOptions(url); url = url.split('?')[0]; } // Now go grab the data and show it if (options) { this.productDetails({url: url}, url, options); } else { this.productDetails({url: url}, url); } } }); });
  6. Save the file.

Step 3: Prepare the Developer Tools For Your Customization

  1. Open your new UtilitiesExtension@1.0.0 module directory.

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

    Modules/extensions/UtilitiesExtension@1.0.0/ns.package.json

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

    { "gulp": { "javascript": [ "JavaScript/*.js" ] } }
  4. Open your new ProductDetailsExtension@1.0.0 module directory.

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

    Modules/extensions/ProductDetailsExtension@1.0.0/ns.package.json

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

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

  8. Add your custom modules to the modules object.

    Your code should look similar to:

    { "name": "SuiteCommerce Advanced Elbrus", "version": "2.0", "isSCA": true, "buildToolsVersion": "1.3.0", "folders": { "modules": "Modules", "suitecommerceModules": "Modules/suitecommerce", "extensionsModules": "Modules/extensions", "thirdPartyModules": "Modules/third_parties", "distribution": "LocalDistribution", "deploy": "DeployDistribution" }, "modules": { "extensions/UtilitiesExtension": "1.0.0", "extensions/ProductDetailsExtension"; "1.0.0", "suitecommerce/Account": "2.3.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.

  9. Add ProductDetails.Router.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:

           "javascript": [
                {
                    "entryPoint": "SC.Shopping.Starter",
                    "exportFile": "shopping.js",
                    "dependencies": [
                        "GoogleMap", 
    //...
                    "StoreLocator",
                    "ProductDetails.Router.Extension"
                   ],
    //...
  10. Save the distro.json file.

Step 4: 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 link in the Bronto cart recovery email redirects to a valid page.

Related Topics