Product

FormatPrice

Format a decimal to a price using the current currency.

Arguments

Name Type Default Description
price decimal The price to format excl. VAT.
storeId long _storeId Id of the store.
async boolean false Specifies if a request should be asynchronously.
successfn function(json[, jQForm]) A function to be called if the request succeeds.
errorfn function(json) A function to be called if the request fails.

Return values

Type Description
price A price object.

Example

var price = TC.formatPrice({storeId:1, price:99.99});

GetPrice

Gets a price for a specific product in the current currency.

Arguments

Name Type Default Description
productIdentifier string A unique identifier of the product. E.g. the node id from Umbraco.
storeId long _storeId Id of the store.
async boolean false Specifies if a request should be asynchronously.
successfn function(json[, jQForm]) A function to be called if the request succeeds.
errorfn function(json) A function to be called if the request fails.

Return values

Type Description
price A price object.

Example

var price = TC.getPrice({storeId:1, productIdentifier:'1076'});

GetStock

Gets the current stock for a specific product.

Arguments

Name Type Default Description
productIdentifier string A unique identifier of the product. E.g. the node id from Umbraco.
storeId long _storeId Id of the store.
async boolean false Specifies if a request should be asynchronously.
successfn function(json[, jQForm]) A function to be called if the request succeeds.
errorfn function(json) A function to be called if the request fails.

Return values

Type Description
float The stock of the product. Will be null if no stock have been provided for this product.

Example

var stock = TC.getStock({storeId:1, productIdentifier:'1076'});

GetVariant

Returns a single variant from a product node. The product must have a property with the Tea Commerce: Variant Editor property editor on it. Also you should enter the alias of the document type property on the Store in the Tea Commerce section.

Arguments

Name Type Description
storeId long Id of the store.
model IPublishedContent A product.
variantId string Id of the variant.
onlyValid bool? Will remove all variants that does not validate from the result set. A variant does not validate when there's problems with the combination of variant types.

Return values

Type Description
VariantPublishedContent A special IPublishedContent representation of a variant.

Example

@using TeaCommerce.Umbraco.Web
@using TeaCommerce.Api.Models
@{
  VariantPublishedContent variant = TC.GetVariant( 1, Model, "AFA77248-1D5B-4B31-ACE2-6FD1C609B93B", true );
}

GetVariants

Returns a a list of variants from a product node. The product must have a property with the Tea Commerce: Variant Editor property editor on it. Also you should enter the alias of the document type property on the Store in the Tea Commerce section.

Arguments

Name Type Description
storeId long Id of the store.
storeId IPublishedContent A product.
onlyValid bool? Will remove all variants that does not validate from the result set. A variant does not validate when there's problems with the combination of variant types.

Return values

Type Description
IEnumerable<VariantPublishedContent> A list of special IPublishedContent representations of variants

Example

@using TeaCommerce.Umbraco.Web
@using TeaCommerce.Api.Models
@{
  IEnumerable<VariantPublishedContent> variants = TC.GetVariants( 1, Model, true );
}

GetVariantGroups

Returns a list of variant groups that define the product variants. You can use this list to generate e.g. drop downs for the user to choose his variant combination.

Arguments

Name Type Description
variants IEnumerable<VariantPublishedContent> A list of variants.

Return values

Type Description
IEnumerable<VariantGroup> A list of the Variant groups and types that define a list of variants.

Example

@using TeaCommerce.Umbraco.Web
@using TeaCommerce.Api.Models
@{
  IEnumerable<VariantGroup> variantGroups = TC.GetVariantGroups( variants );
}
@foreach ( VariantGroup variantGroup in attributeGroups ) {
  <select>
    <option value="">Select @variantGroup.Name</option>
    @foreach ( VariantType variantType in variantGroup.Attributes ) {
      <option value="@variantType.Id">@variantType.Name</option>
    }
  </select>
}

GetVariantJson

Returns a json object containing all variants for the product. The data contains information about each variants combination of variant types. Use this data to javascript filter e.g. drop downs when a user/customer selects his variant.

Arguments

Name Type Description
storeId long Id of the store.
model IPublishedContent A product.
onlyValid bool Will remove all variants that does not validate from the result set. A variant does not validate when there's problems with the combination of variant types.

Return values

Type Description
string A json object containing all variants for the product

Example

@using TeaCommerce.Umbraco.Web
@using TeaCommerce.Api.Models
@{
  string variantJson = TC.GetVariantJson( 1, product, true );
}

Example data

{  
   "1113":{  
      "dc8a57d9-ceb3-757e-ee98-073e37df5dd0":{  
         "combinations":[  
            1120,
            1124
         ],
         "productIdentifier":"1113_dc8a57d9-ceb3-757e-ee98-073e37df5dd0"
      },
      "debe8f77-7537-77e8-e454-daab8d7d12a7":{  
         "combinations":[  
            1120,
            1125
         ],
         "productIdentifier":"1113_debe8f77-7537-77e8-e454-daab8d7d12a7"
      },
      "0f18230d-fc26-b794-ca24-4b90637850be":{  
         "combinations":[  
            1120,
            1126
         ],
         "productIdentifier":"1113_0f18230d-fc26-b794-ca24-4b90637850be"
      },
      "6101dc40-d562-357d-9865-742110847978":{  
         "combinations":[  
            1122,
            1124
         ],
         "productIdentifier":"1113_6101dc40-d562-357d-9865-742110847978"
      },
      "23bbe693-0630-080f-a3c1-885cec9539ee":{  
         "combinations":[  
            1122,
            1125
         ],
         "productIdentifier":"1113_23bbe693-0630-080f-a3c1-885cec9539ee"
      },
      "76235695-bb54-e51c-f328-5e332b98ae08":{  
         "combinations":[  
            1122,
            1126
         ],
         "productIdentifier":"1113_76235695-bb54-e51c-f328-5e332b98ae08"
      }
   }
}

GetPropertyValue

Returns the value of a property on the product. Will traverse the content tree recursively to find the value. Will also use the master relation property of the product to search master products.

Note

If you have a IPublishedContent model use that instead of the string productIdentifier, which is slightly slower.

Arguments 1

Name Type Description
storeId long Id of the store.
productIdentifier string A unique identifier of the product. E.g. the node id from Umbraco.
propertyAlias string Alias of the property to find.
func Func<IPublishedContent, bool> A function to filter the recursive call.

Arguments 2

Name Type Description
storeId long Id of the store.
model IPublishedContent A product.
propertyAlias string Alias of the property to find.
variantId string Guid id of the variant.
func Func<IPublishedContent, bool> A function to filter the recursive call.

Return values

Type Description
T The value of the property in the type you want.

Example 1

@using TeaCommerce.Umbraco.Web
@{
  string productName = TC.GetPropertyValue<string>( 1, "1076", "productName" );
}

Example 2

@using TeaCommerce.Umbraco.Web
@{
  string productName = TC.GetPropertyValue<string>( 1, Model, "productName" );
}

Example 3 - variant

@using TeaCommerce.Umbraco.Web
@{
  string productName = TC.GetPropertyValue<string>( 1, Model, "productName", "50D790BC-8848-43FA-B443-2EC0DE25CF3E" );
}
Last Updated: 12/18/2019, 1:58:30 PM