Custom Code CIMcloud Helpers

Overview

CIMcloud Helpers allow you to get certain data, as well as run certain actions within Custom Code.

For a full list of CIMcloud Helper data functions, click the blue Tips and Tricks button on Custom Code pages, or the Advanced section in Workspace Settings / Customer Site Settings.  You can also head directly to this page here:

  • https://{your_site_name}.mycimcloud.com/app_settings_documentation.asp

Available Data

For catalog pages, you can access the ProductModel to pull properties related to the current product’s context.

On all pages custom code is available, you can pull properties related to the logged in Session, including Customer and Account information.

cimcloud.catalog.getProducts()

Allows you to get product data outside the current scope of the viewed product.

Format

cimcloud.catalog.getProducts(sku, callbackFunction());

Response

Example

cimcloud.catalog.getProducts(['YOUR_PRODUCT_SKU'], function(products) {

    console.log(products[0].name());

});

cimcloud.catalog.addToCart()

Allows you to trigger adding items to the cart.  Able to add more than one detail line at once.

Required Fields

  • sku
  • quantity

Optional Fields

  • unit_of_measure
  • warehouse

Format

cimcloud.catalog.addToCart(sku, quantity, unit_of_measure, warehouse)

Example – Adding Multiple Products

cimcloud.catalog.addToCart([
  {
    sku: 'FIRST_EXAMPLE_PRODUCT',
    qty: 3,
    uom: 'uom_std',
    warehouse: '001'
  },
  {
    sku: 'SECOND_EXAMPLE_PRODUCT',
    qty: 2
  }
]);

Example – Adding Products as a Group

Following example allows you to add items to the cart grouped together, so that deleting the parent product deletes the grouped product.  This is used frequently in Product Configurator.

To group products when calling the addToCart helper, create a group JSON object, holding the child products.  Additional properties decide how quantities of the child products are added to cart:

  • qty_type – ratio / fixed
    • qty_multiplier – If ratio, multiplies parent product quantity with this value
    • qty – If fixed, adds a fixed quantity to the cart
cimcloud.catalog.addToCart([
  {
    sku: 'PARENT_EXAMPLE_PRODUCT',
    qty: 3,
    group: [
    {
      sku: 'CHILD_EXAMPLE_PRODUCT_1',
      qty_type: 'ratio',
      qty_multilier: 2,
    },
    {
      sku: 'CHILD_EXAMPLE_PRODUCT_2',
      qty: 1,
      qty_type: 'fixed',
    }]
  }
]);

Was this article helpful

Related Articles

Subscribe to receive email updates of what's new in the CIMcloud Help Center.