E-commerce Variables

Edited

A variable EcommerceAPI is available to use during the e-commerce flow. As part of this API, there is a listener that can register (stepChanged) to monitor for changes in steps during the process flow. When a step changes, this listener is called, and is passed 2 variables: the step # the user is coming from and the step# they are going to. Step numbers are 0-index based. For example:

<script>

     eCommerceAPI.stepChanged(  function(fromStep, toStep) { 
          console.log("Changed from step " + fromStep + " to " + toStep);
     }

</script>

There are two more listeners that can be used when calls are made to the InvoicePreview for tax calculation purposes:

  • previewStarted (no parameters)

  • previewEnded (1 boolean parameter - whether a blocking result was returned)

The following example disables the "Next" button while waiting on the InvoicePreview. It is re-enabled unless there was a blocking error in the call:

        
        ecommerceAPI.previewStarted(  function() { 
            $(".btn-next").attr("disabled",true);
        });
        
        ecommerceAPI.previewEnded(  function(hasBlocker) { 
            if (!hasBlocker) $(".btn-next").attr("disabled",false);
        });


The following methods are exposed on the EcommerceAPI and will assist you in getting various information about the steps and products:

getSteps()
getCategories()
getCategoriesByStepNumber(stepNumer) //stepNumber is 0-index based
getSelectedCategories()
getProducts()
getSelectedProducts()
getCartItems()
getCartSubTotal()
getCartTax()
getCartTotal()

Here are some example method calls:

Selection_767

Selection_768

Selection_769

Selection_770

Was this article helpful?

Sorry about that! Care to tell us more?

Thanks for the feedback!

There was an issue submitting your feedback
Please check your connection and try again.