Table of Contents

Class VariantOption

Namespace
Dynamicweb.Ecommerce.Variants
Assembly
Dynamicweb.Ecommerce.dll

One selectable option within a VariantGroup, e.g. "Red" in a "Colour" group. Variant options are combined across groups to form a VariantCombination.

[Serializable]
public class VariantOption : IComparable<VariantOption>
Inheritance
VariantOption
Implements
Inherited Members

Properties

Color

Gets or sets the colour of this option, used when its group is displayed as VariantColor.

public string? Color { get; set; }

Property Value

string

GroupId

Gets or sets the ID of the VariantGroup this option belongs to.

public required string GroupId { get; set; }

Property Value

string

Icon

Gets or sets the path of the icon shown for this option in the administration.

public string? Icon { get; set; }

Property Value

string

Id

Gets or sets the ID of the variant option. Assigned by the database when the option is first saved.

public string Id { get; set; }

Property Value

string

LargeImage

Gets or sets the path of the large image for this option.

public string? LargeImage { get; set; }

Property Value

string

MediumImage

Gets or sets the path of the medium image for this option.

public string? MediumImage { get; set; }

Property Value

string

SmallImage

Gets or sets the path of the small image for this option.

public string? SmallImage { get; set; }

Property Value

string

SortOrder

Gets or sets the sort order of this option within its group. Options are ordered by this value first, then by Id.

public int SortOrder { get; set; }

Property Value

int

Translations

Gets the per-language translations of this option. Use GetName(string) and SetName(string, string?) to read and write the translated name.

public TranslationCollection<VariantOptionTranslation> Translations { get; }

Property Value

TranslationCollection<VariantOptionTranslation>

Methods

Clone()

Clones this instance.

public VariantOption Clone()

Returns

VariantOption

The instance of the VariantOption.

CompareTo(VariantOption?)

Compares this option with another by SortOrder, then by Id ignoring case.

public int CompareTo(VariantOption? other)

Parameters

other VariantOption

The option to compare with this instance.

Returns

int

A negative value when this option sorts before other, zero when they sort equally, and a positive value when it sorts after.

Equals(object?)

Determines whether the given object is a VariantOption with the same Id, ignoring case.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

true when the IDs match; otherwise, false.

GetHashCode()

Returns a hash code derived from Id, ignoring case.

public override int GetHashCode()

Returns

int

The hash code for this variant option.

GetName(string)

Gets the name of this variant option in the given language.

public string GetName(string languageId)

Parameters

languageId string

The ID of the language to get the name in.

Returns

string

The translated name; the default language's name when the requested language has no translation, and Id when neither has one.

SetName(string, string?)

Sets the name of this variant option in the given language, adding the translation when it is missing.

public void SetName(string languageId, string? name)

Parameters

languageId string

The ID of the language to set the name for.

name string

The variant option name.

Operators

operator ==(VariantOption, VariantOption)

Determines whether two options have the same Id, or are both null.

public static bool operator ==(VariantOption left, VariantOption right)

Parameters

left VariantOption

The first option.

right VariantOption

The second option.

Returns

bool

true when the options are equal per Equals(object?); otherwise, false.

operator >(VariantOption, VariantOption)

Determines whether the left option sorts after the right one, per CompareTo(VariantOption?).

public static bool operator >(VariantOption left, VariantOption right)

Parameters

left VariantOption

The first option. A null value never sorts after anything.

right VariantOption

The second option.

Returns

bool

true when left sorts after right; otherwise, false.

operator >=(VariantOption, VariantOption)

Determines whether the left option sorts after or equally to the right one, per CompareTo(VariantOption?).

public static bool operator >=(VariantOption left, VariantOption right)

Parameters

left VariantOption

The first option. A null value only qualifies when right is null too.

right VariantOption

The second option.

Returns

bool

true when left does not sort before right; otherwise, false.

operator !=(VariantOption, VariantOption)

Determines whether two options have different IDs.

public static bool operator !=(VariantOption left, VariantOption right)

Parameters

left VariantOption

The first option.

right VariantOption

The second option.

Returns

bool

The negation of the operator ==(VariantOption, VariantOption) operator.

operator <(VariantOption, VariantOption)

Determines whether the left option sorts before the right one, per CompareTo(VariantOption?).

public static bool operator <(VariantOption left, VariantOption right)

Parameters

left VariantOption

The first option. A null value sorts before any instance.

right VariantOption

The second option.

Returns

bool

true when left sorts before right; otherwise, false.

operator <=(VariantOption, VariantOption)

Determines whether the left option sorts before or equally to the right one, per CompareTo(VariantOption?).

public static bool operator <=(VariantOption left, VariantOption right)

Parameters

left VariantOption

The first option. A null value sorts before or equally to anything.

right VariantOption

The second option.

Returns

bool

true when left does not sort after right; otherwise, false.

To top