ZenMagick 0.9.8


org.zenmagick.store.services.ZMCoupons
\store\services\ZMCoupons.php at line 34

Class ZMCoupons

ZMObject
└─ZMCoupons

public class ZMCoupons
extends ZMObject

Coupons.

Author:
DerManoMann
Version:
$Id: ZMCoupons.php 2694 2009-12-03 22:32:18Z dermanomann $

Field Summary
final str

BALANCE_ADD

final str

BALANCE_SET

final str

TYPPE_FIXED

final str

TYPPE_GV

final str

TYPPE_PERCENT

final str

TYPPE_SHIPPING

Fields inherited from org.zenmagick.core.ZMObject
properties_
Constructor Summary

ZMCoupons()

Create new instance.

Method Summary
ZMCoupon

createCoupon(mixed couponCode, float amount, string type, int accountId)

Create a new coupon.

string

createCouponCode(string salt, int length)

Create a new coupon code.

void

createCouponTracker(ZMCoupon coupon, ZMAccount account, ZMGVReceiver gvreceiver)

Create a new coupon tracker record.

void

creditCoupon(int couponId, int accountId)

Credit coupon for account.

void

finaliseCoupon(int couponId, int accountId, string remoteIp)

Finalise a coupon.

ZMCoupon

getCouponForCode(string code, int languageId)

Coupon lookup for the given code.

ZMCoupon

getCouponForId(int id, int languageId)

Coupon lookup for the given id.

ZMCouponQueue

getCouponQueueEntryForId(int queueId)

Get a coupon queue entry.

ZMCouponRestrictions

getRestrictionsForCouponId(mixed couponId, int id)

Load coupon restrictions for the given coupon id.

float

getVoucherBalanceForAccountId(int accountId)

Get the coupon/voucher balance for the given account.

static void

instance()

Get instance.

boolean

isCouponRedeemable(string couponId)

Check if a given coupon code can be redeemed.

void

redeemCoupon(int couponId, int accountId, string remoteIp)

Redeem a coupon.

void

setVoucherBalanceForAccountId(int accountId, float amount)

Update the coupon/coucher balance for the given account id.

protected void

updateVoucherBalanceForAccountId(int accountId, float amount, string mode)

Update the coupon/coucher balance for the given account id.

Methods inherited from org.zenmagick.core.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Field Detail

\store\services\ZMCoupons.php at line 36

BALANCE_ADD

public final str BALANCE_ADD = 'balance_add'

\store\services\ZMCoupons.php at line 35

BALANCE_SET

public final str BALANCE_SET = 'balance_set'

\store\services\ZMCoupons.php at line 38

TYPPE_FIXED

public final str TYPPE_FIXED = 'F'

\store\services\ZMCoupons.php at line 37

TYPPE_GV

public final str TYPPE_GV = 'G'

\store\services\ZMCoupons.php at line 39

TYPPE_PERCENT

public final str TYPPE_PERCENT = 'P'

\store\services\ZMCoupons.php at line 40

TYPPE_SHIPPING

public final str TYPPE_SHIPPING = 'S'

Constructor Detail

\store\services\ZMCoupons.php at line 47

ZMCoupons

public ZMCoupons()

Create new instance.


Method Detail

\store\services\ZMCoupons.php at line 169

createCoupon

public ZMCoupon createCoupon(mixed couponCode, float amount, string type, int accountId)

Create a new coupon.

Parameters:
accountId - The account id.
amount - The new amount.
type - The coupon type.
Returns:
A ZMCoupon instance or null.

\store\services\ZMCoupons.php at line 278

createCouponCode

public string createCouponCode(string salt, int length)

Create a new coupon code.

Parameters:
salt - The salt to be used to generate the unique code.
length - The coupon code length; default is 0 to use the setting couponCodeLength.
Returns:
A new unique coupon code.

\store\services\ZMCoupons.php at line 182

createCouponTracker

public void createCouponTracker(ZMCoupon coupon, ZMAccount account, ZMGVReceiver gvreceiver)

Create a new coupon tracker record.

Parameters:
coupon - The coupon.
account - The sender account.
gvreceiver - The receiver.

\store\services\ZMCoupons.php at line 262

creditCoupon

public void creditCoupon(int couponId, int accountId)

Credit coupon for account.

Parameters:
couponId - The coupon id.
accountId - The redeeming account id.

\store\services\ZMCoupons.php at line 227

finaliseCoupon

public void finaliseCoupon(int couponId, int accountId, string remoteIp)

Finalise a coupon.

Parameters:
couponId - The coupon id.
accountId - The redeeming account id.
remoteIp - The redeeming IP addres; default is an empty string.

\store\services\ZMCoupons.php at line 74

getCouponForCode

public ZMCoupon getCouponForCode(string code, int languageId)

Coupon lookup for the given code.

Parameters:
code - The coupons code.
languageId - The languageId; default is null for session language.
Returns:
A ZMCoupon instance or null.

\store\services\ZMCoupons.php at line 96

getCouponForId

public ZMCoupon getCouponForId(int id, int languageId)

Coupon lookup for the given id.

Parameters:
id - The coupon id.
languageId - The languageId; default is null for session language.
Returns:
A ZMCoupon instance or null.

\store\services\ZMCoupons.php at line 249

getCouponQueueEntryForId

public ZMCouponQueue getCouponQueueEntryForId(int queueId)

Get a coupon queue entry.

Parameters:
queueId - The coupon queue id.
Returns:
A queue entry or null.

\store\services\ZMCoupons.php at line 308

getRestrictionsForCouponId

public ZMCouponRestrictions getRestrictionsForCouponId(mixed couponId, int id)

Load coupon restrictions for the given coupon id.

Parameters:
id - The coupon id.
Returns:
The restrictions.

\store\services\ZMCoupons.php at line 117

getVoucherBalanceForAccountId

public float getVoucherBalanceForAccountId(int accountId)

Get the coupon/voucher balance for the given account.

Parameters:
accountId - The account id.
Returns:
The available balance or 0.

\store\services\ZMCoupons.php at line 62

instance

public static void instance()

Get instance.


\store\services\ZMCoupons.php at line 199

isCouponRedeemable

public boolean isCouponRedeemable(string couponId)

Check if a given coupon code can be redeemed.

Parameters:
couponId - The coupon id to verify.
Returns:
true if the coupon can be redeemed, false if not.

\store\services\ZMCoupons.php at line 215

redeemCoupon

public void redeemCoupon(int couponId, int accountId, string remoteIp)

Redeem a coupon.

This will call finaliseCoupon(...) and creditCoupon(...).

Parameters:
couponId - The coupon id.
accountId - The redeeming account id.
remoteIp - The redeeming IP addres; default is an empty string.

\store\services\ZMCoupons.php at line 130

setVoucherBalanceForAccountId

public void setVoucherBalanceForAccountId(int accountId, float amount)

Update the coupon/coucher balance for the given account id.

Parameters:
accountId - The account id.
amount - The new amount.

\store\services\ZMCoupons.php at line 141

updateVoucherBalanceForAccountId

protected void updateVoucherBalanceForAccountId(int accountId, float amount, string mode)

Update the coupon/coucher balance for the given account id.

Parameters:
accountId - The account id.
amount - The new amount.
mode - Optional update mode; either BALANCE_SET or BALANCE_ADD.

ZenMagick 0.9.8