AI agents: the content index is at /llms.txt. Every page is also available as Markdown — send the request header Accept: text/markdown, or append .md to the page URL.
Xperience Docs

Cookie consent

We use necessary cookies (opens in a new tab) to run our website and improve your experience while browsing. Additional cookies are only used with your consent. You may revoke your consent on the Cookies Policy (opens in a new tab) page or in your browser at any time.

Configure (opens in a new tab)
  • Documentation
    InstallationUsing the Xperience interfaceDeveloping websitesConfiguring XperienceManaging usersSecuring websitesDeploying websitesManaging website contentMultilingual websitesMacro expressionsExternal utilitiesIntegrating 3rd party systemsCustom developmentE-commerce featuresOn-line marketing featuresRelease notes - Xperience 13Xperience terminology glossary
  • Tutorial
    Using the Xperience interfaceDeveloper tutorialBusiness tutorialResource hub for marketers
  • API Examples
    ConfigurationContent managementDevelopmentE-commerceOn-line marketingSocial media
  1. Home
  2. E-commerce
  3. Departments

Departments


Was this page helpful?

Send us feedback Go back to top
  • Community Questions & Answers (opens in a new tab)
  • Contact support (opens in a new tab)

List of examples:

  • Departments
    • Creating a new department
    • Updating a department
    • Updating multiple departments
    • Deleting a department
  • Department tax classes
    • Applying tax classes to a department
    • Removing tax classes from a department

Departments

Creating a new department

C#
// Creates a new department object
DepartmentInfo newDepartment = new DepartmentInfo();

// Sets the department properties
newDepartment.DepartmentDisplayName = "New department";
newDepartment.DepartmentName = "NewDepartment";
newDepartment.DepartmentSiteID = SiteContext.CurrentSiteID;

// Saves the department to the database
DepartmentInfo.Provider.Set(newDepartment);
> Back to list of examples

Updating a department

C#
// Gets the department
DepartmentInfo updateDepartment = DepartmentInfo.Provider.Get("NewDepartment", SiteContext.CurrentSiteID);
if (updateDepartment != null)
{
    // Updates the department properties
    updateDepartment.DepartmentDisplayName = updateDepartment.DepartmentDisplayName.ToLower();

    // Saves the changes to the database
    DepartmentInfo.Provider.Set(updateDepartment);
}
> Back to list of examples

Updating multiple departments

C#
// Gets all departments whose code name starts with 'NewDepartment'
var departments = DepartmentInfo.Provider.Get().WhereStartsWith("DepartmentName", "NewDepartment");

// Loops through the departments
foreach (DepartmentInfo modifyDepartment in departments)
{
    // Updates the department properties
    modifyDepartment.DepartmentDisplayName = modifyDepartment.DepartmentDisplayName.ToUpper();

    // Saves the changes to the database
    DepartmentInfo.Provider.Set(modifyDepartment);
}
> Back to list of examples

Deleting a department

C#
// Gets the department
DepartmentInfo deleteDepartment = DepartmentInfo.Provider.Get("NewDepartment", SiteContext.CurrentSiteID);

if (deleteDepartment != null)
{
    // Deletes the department
    DepartmentInfo.Provider.Delete(deleteDepartment);
}
> Back to list of examples

Department tax classes

Applying tax classes to a department

C#
// Gets the department
DepartmentInfo department = DepartmentInfo.Provider.Get("NewDepartment", SiteContext.CurrentSiteID);

// Gets the tax class
TaxClassInfo taxClass = TaxClassInfo.Provider.Get("NewClass", SiteContext.CurrentSiteID);

if ((department != null) && (taxClass != null))
{
    // Adds the tax class to the department
    department.DepartmentDefaultTaxClassID = taxClass.TaxClassID;

    // Saves the changes to the database
    DepartmentInfo.Provider.Set(department);
}
> Back to list of examples

Removing tax classes from a department

C#
// Gets the department
DepartmentInfo department = DepartmentInfo.Provider.Get("NewDepartment", SiteContext.CurrentSiteID);

if (department != null)
{
    // Removes the tax class to the department
    department.DepartmentDefaultTaxClassID = 0;

    // Saves the changes to the database
    DepartmentInfo.Provider.Set(department);
}
> Back to list of examples