Table of Contents

Class Voucher

Namespace
Dynamicweb.Ecommerce.Orders.SalesDiscounts
Assembly
Dynamicweb.Ecommerce.dll
The class Voucher represents base for discounts on voucher codes.
[Obsolete("Use Dynamicweb.Ecommerce.Orders.Vouchers.Voucher instead.")]
public class Voucher : Voucher
Inheritance
Voucher
Inherited Members

Constructors

Voucher(IDataReader)

Initializes a new instance of the Voucher class.
public Voucher(IDataReader dataReader)

Parameters

dataReader IDataReader
The data reader.

Voucher(string, int)

Initializes a new instance of the Voucher class.
public Voucher(string code, int voucherListId)

Parameters

code string
The voucher code.
voucherListId int
The voucher list id.

Properties

ID

[Obsolete("Use Id instead.")]
public int ID { get; set; }

Property Value

int

VoucherAccessUserId

ID of the user who used the voucher
[Obsolete("Use UserId instead.")]
public int? VoucherAccessUserId { get; set; }

Property Value

int?

Methods

CheckVouchers(List<string>)

Checks the vouchers in the database
public static List<string> CheckVouchers(List<string> vouchers)

Parameters

vouchers List<string>

Returns

List<string>

Delete()

public void Delete()

Delete(int)

public void Delete(int id)

Parameters

id int

Fill(IDataReader)

Fills this instance with data from given reader
public void Fill(IDataReader reader)

Parameters

reader IDataReader
The reader.

GenerateVoucher(int, int)

Generate Voucher
public static string GenerateVoucher(int listId, int numberOfSymbols = 8)

Parameters

listId int
ID of the list to generate voucher for.
numberOfSymbols int
optional. Voucher length, in characters.

Returns

string
The voucher code

Remarks

If list not exist in db - return null

GenerateVouchers(int, int, int)

Generate Vouchers
public static void GenerateVouchers(int number, int listId, int numberOfSymbols = 8)

Parameters

number int
Number of vouchers
listId int
ID of the list to generate vouchers for
numberOfSymbols int
Number of symbols in voucher code

GetAllVouchers()

Get all vouchers
public static IEnumerable<Voucher> GetAllVouchers()

Returns

IEnumerable<Voucher>

GetAllVouchersForList(int)

Get the collection of vouchers for specific List
public static IEnumerable<Voucher> GetAllVouchersForList(int listId)

Parameters

listId int
List ID

Returns

IEnumerable<Voucher>

GetDiscountForVoucher()

Get discount for current voucher
public SalesDiscount GetDiscountForVoucher()

Returns

SalesDiscount

GetDiscountForVoucher(int)

[Obsolete("Use GetDiscountForVoucher(voucherCode As string) instead")]
public static SalesDiscount GetDiscountForVoucher(int voucherCode)

Parameters

voucherCode int

Returns

SalesDiscount

GetDiscountForVoucher(string)

Get the discount by voucher code
public static SalesDiscount GetDiscountForVoucher(string voucherCode)

Parameters

voucherCode string
Voucher code

Returns

SalesDiscount

GetVoucherByCode(string)

Get Voucher by Voucher Code
public static Voucher GetVoucherByCode(string voucherCode)

Parameters

voucherCode string

Returns

Voucher

GetVoucherByCode(string, int)

Get Voucher by Voucher Code
public static Voucher GetVoucherByCode(string voucherCode, int listId)

Parameters

voucherCode string
listId int

Returns

Voucher

IsValid(string, int)

Check If voucher is valid and can be applied
public static bool IsValid(string voucherCode, int listId)

Parameters

voucherCode string
Voucher Code
listId int
List ID

Returns

bool

Load(int)

public void Load(int id)

Parameters

id int

RenderVoucherMail(Voucher, string, string)

Renders the mail template for the vouchers
public static string RenderVoucherMail(Voucher voucher, string userName, string userEmail)

Parameters

voucher Voucher
Voucher object
userName string
User Name
userEmail string
User email to send voucher to

Returns

string

Save()

public void Save()

UpdateVouchersOrderId(string, string)

Update Voucher Code with Order
public static void UpdateVouchersOrderId(string orderId, string newOrderId)

Parameters

orderId string
Order ID to change
newOrderId string
New Order ID
To top