Table of Contents

Class BuyerIdentifier

Namespace
CMS.Commerce
Assembly
CMS.Commerce.dll

Value object representing a buyer identifier. A buyer is either an existing customer or a registered member. This type guarantees that only one kind can be set at a time.

public sealed record BuyerIdentifier
Inheritance
object
BuyerIdentifier
Extension Methods

Properties

Kind

The kind of this buyer identifier (Customer or Member).

public BuyerIdentifierKind Kind { get; }

Property Value

BuyerIdentifierKind

Value

The numeric value of the identifier.

public int Value { get; }

Property Value

int

Methods

Equals(BuyerIdentifier?)

public bool Equals(BuyerIdentifier? other)

Parameters

other BuyerIdentifier

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

FromCustomerId(int)

Creates a buyer identifier for an existing customer. Corresponds to Customer.

public static BuyerIdentifier FromCustomerId(int customerId)

Parameters

customerId int

The customer identifier.

Returns

BuyerIdentifier

A BuyerIdentifier of kind Customer when customerId > 0; otherwise null.

FromMemberId(int)

Creates a buyer identifier for a registered member. Corresponds to Member.

public static BuyerIdentifier FromMemberId(int memberId)

Parameters

memberId int

The member identifier.

Returns

BuyerIdentifier

A BuyerIdentifier of kind Member when memberId > 0; otherwise null.

Remarks

If the registered member ID corresponds to an existing customer, then in contexts such as order creation or price calculations, this BuyerIdentifier is used to identify the customer, regardless of whether it was created using FromCustomerId(int) or FromMemberId(int).

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

Operators

operator ==(BuyerIdentifier?, BuyerIdentifier?)

public static bool operator ==(BuyerIdentifier? left, BuyerIdentifier? right)

Parameters

left BuyerIdentifier
right BuyerIdentifier

Returns

bool

operator !=(BuyerIdentifier?, BuyerIdentifier?)

public static bool operator !=(BuyerIdentifier? left, BuyerIdentifier? right)

Parameters

left BuyerIdentifier
right BuyerIdentifier

Returns

bool