ZenMagick 0.9.6


org.zenmagick.model.catalog.ZMOffers

Class ZMOffers

ZMObject
|
+--ZMOffers

public class ZMOffers
extends ZMObject

All stuff related to product prices and offers.

Author:
DerManoMann
Version:
$Id: ZMOffers.php 2208 2009-05-06 05:29:40Z dermanomann $

Field Summary
final mixed

$DISCOUNT_FROM_BASE_PRICE

final mixed

DISCOUNT_FROM_SPECIAL_PRICE

final mixed

DISCOUNT_TYPE_AMOUNT

final mixed

$DISCOUNT_TYPE_NONE

final mixed

DISCOUNT_TYPE_PERCENT

final mixed

DISCOUNT_TYPE_PRICE

final mixed

$SALE_TYPE_AMOUNT

final mixed

SALE_TYPE_PERCENT

final mixed

SALE_TYPE_PRICE

Fields inherited from org.zenmagick.ZMObject
properties_
Constructor Summary

ZMOffers(ZMProduct product)

Create new instance.

Method Summary
float

calculateDiscount(float amount)

Calculate discount for either product or the given amount (for example to calculate discounts on attributes).

protected void

calculatePrice()

Calculate the (best) price.

protected void

doGetBasePrice()

Calculate the base price.

protected void

doGetSalePrice()

Calculate the discount price.

float

getBasePrice(boolean tax)

Get the base price; this is the lowest possible product price.

float

getCalculatedPrice(boolean tax)

Get the calculated price.

float

getDiscountAmount()

Get the discount amount.

float

getDiscountPercent()

Get the discount as percent value.

float

getProductPrice(boolean tax)

Get the product price.

array

getQuantityDiscounts(boolean tax)

Get quantity discounts, if any.

float

getSalePrice(boolean tax)

Get the discount price.

float

getSpecialPrice(boolean tax)

Get the special price.

float

getTaxRate()

Get the tax rate for the product.

boolean

isAttributePrice()

Checks if there are attribute prices that will affect the final price.

boolean

isSale()

Checks if a sale price is available.

boolean

isSpecial()

Checks if a special price is available.

void

setProduct(ZMProduct product)

Set the product.

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

Field Detail

DISCOUNT_FROM_BASE_PRICE

public final mixed $DISCOUNT_FROM_BASE_PRICE

DISCOUNT_FROM_SPECIAL_PRICE

public final mixed DISCOUNT_FROM_SPECIAL_PRICE = 1

DISCOUNT_TYPE_AMOUNT

public final mixed DISCOUNT_TYPE_AMOUNT = 3

DISCOUNT_TYPE_NONE

public final mixed $DISCOUNT_TYPE_NONE

DISCOUNT_TYPE_PERCENT

public final mixed DISCOUNT_TYPE_PERCENT = 1

DISCOUNT_TYPE_PRICE

public final mixed DISCOUNT_TYPE_PRICE = 2

SALE_TYPE_AMOUNT

public final mixed $SALE_TYPE_AMOUNT

SALE_TYPE_PERCENT

public final mixed SALE_TYPE_PERCENT = 1

SALE_TYPE_PRICE

public final mixed SALE_TYPE_PRICE = 2

Constructor Detail

ZMOffers

public ZMOffers(ZMProduct product)

Create new instance.

Parameters:
product - The product.

Method Detail

calculateDiscount

public float calculateDiscount(float amount)

Calculate discount for either product or the given amount (for example to calculate discounts on attributes).

Parameters:
amount - Optional amount; default is null to calculate the discount * of the product price.
Returns:
The discounted amount.

calculatePrice

protected void calculatePrice()

Calculate the (best) price. /


doGetBasePrice

protected void doGetBasePrice()

Calculate the base price. /


doGetSalePrice

protected void doGetSalePrice()

Calculate the discount price. /


getBasePrice

public float getBasePrice(boolean tax)

Get the base price; this is the lowest possible product price.

The base price consists of the product price plus the lowest attribute price (if any).

Parameters:
tax - Set to true to include tax (if applicable); default is true.
Returns:
The base price.

getCalculatedPrice

public float getCalculatedPrice(boolean tax)

Get the calculated price.

This is the actual price, taking into account if sale or discount are available.

Parameters:
tax - Set to true to include tax (if applicable); default is true.
Returns:
The calculated price.

getDiscountAmount

public float getDiscountAmount()

Get the discount amount.

Returns:
The discount amount.

getDiscountPercent

public float getDiscountPercent()

Get the discount as percent value.

Returns:
The discount in percent.

getProductPrice

public float getProductPrice(boolean tax)

Get the product price.

This is the price as configured in the database.

Parameters:
tax - Set to true to include tax (if applicable); default is true.
Returns:
The product price.

getQuantityDiscounts

public array getQuantityDiscounts(boolean tax)

Get quantity discounts, if any.

Parameters:
tax - Set to true to include tax (if applicable); default is true.
Returns:
A list of ZMQuantityDiscount instances.

getSalePrice

public float getSalePrice(boolean tax)

Get the discount price.

This price is the price as set up with the sales maker in the admin interface.

Parameters:
tax - Set to true to include tax (if applicable); default is true.
Returns:
The discount price.

getSpecialPrice

public float getSpecialPrice(boolean tax)

Get the special price.

Special price as configured.

Parameters:
tax - Set to true to include tax (if applicable); default is true.
Returns:
The special price.

getTaxRate

public float getTaxRate()

Get the tax rate for the product.

Returns:
The tax rate.

isAttributePrice

public boolean isAttributePrice()

Checks if there are attribute prices that will affect the final price.

Returns:
true if attribute prices exist.

isSale

public boolean isSale()

Checks if a sale price is available.

Returns:
true if a sale price is available.

isSpecial

public boolean isSpecial()

Checks if a special price is available.

Returns:
true if a special price is available.

setProduct

public void setProduct(ZMProduct product)

Set the product.

Parameters:
product - The product.

ZenMagick 0.9.6