Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
linenumberstrue
//add cart attributes
cart.flexAttributes.forEach ( function ( key ) {
  result.attributes[key] = cart.get(key);
});

string cart.get(key)

Accesses a flex attribute field for the given parameter keyReturns the value of key as string or null if no value is set under the key.

Example

Code Block
languagejs
linenumberstrue
if (cart.get("ibe2.shippingMethod") === "STORE") {
  regionShipping = parseInt(portal.get("shipping.store.price"));
}

Parameter key:string (required)

The key to be looked up in the flexAttributes of the cart.

boolean cart.has(key)

Returns true if a cart has a flex attribute for the given parameter key, otherwise false.a boolean value depending on whether key is present for a given cart

Example

Code Block
languagejs
linenumberstrue
...
cart.has("ibe2.shippingMethod") // => true
...

Parameter key:string (required)

The key to be checked in the flexAttributes of the cart.

address cart.invoiceAddress

...

A uuid from the list of JSMA cartItems of the cart.

cart.remove(key)

Removes the key from the flexAttributes of the cart

Example

Code Block
languagejs
linenumberstrue
...
cart.remove('ibe2.shippingMethod');
...

Parameter key:string (required)

The key to be removed from the flexAttributes of the cart.

cart.set(key, value)

Sets a flex attribute with the given parametersthe value of a specified key for a given cart.

Example

Code Block
languagejs
linenumberstrue
CartApi.prototype.doSubmitFlexAttributes = function () 
{
  var cart = carts.current;

  [...]

  if (attributes[cart.uuid]) {
    for (var key in attributes[cart.uuid]) {
      cart.set(key, attributes[cart.uuid][key]);
    }
  }
}

Parameter key:string (required)

The key to be set in the flexAttributes of the cart.

Parameter value:string (required)

cart.remove(key)

Removes a flex attribute for given parameter key.

Example

Code Block
languagejs
linenumberstrue
...
cart.remove('ibe2.shippingMethod');
...

...

The value to be set for the key


void cart.setPaymentMethod(payment_mode)

...