\HasPromotionalPricing
Extension for Buyable models to allow promotional pricing to be applied.
- can be applied to categories as well
- can be limited by start and/or end date
- can be absolute price or percentage discount
- can specify whether to display as a sale (i.e. show old price crossed out)
- Author: Mark Guinn <mark@adaircreative.com>
Synopsis
class HasPromotionalPricing
extends DataExtension
{
- // members
- private static boolean $compound_discounts = false;
- private static boolean $disable_discounts = false;
- private static array $db = ;
- protected static bool $bypass = false;
- protected double $_cachedPrice;
- protected $_cachedOriginal;
- // methods
- protected void updateFields()
- public void updateCMSFields()
- public void updateProductCMSFields()
- public double sellingPriceBeforePromotion()
- public Money getOriginalPrice()
- public void OriginalPrice()
- public float calculatePromoSavings()
- public Money PromoSavings()
- public void updateSellingPrice()
- protected array collectParentPromoSources()
- protected bool applyPromoFrom()
- public bool hasValidPromotion()
- public bool HasPromotion()
Hierarchy
Extends
- DataExtension
Members
private
- $compound_discounts
- $db
- $disable_discounts
protected
Methods
protected
- applyPromoFrom() — Apply the discount from this or any parent object to a given price.
- collectParentPromoSources() — Collects any other sources of applicable discounts, leaving room for extension from other sources.
- updateFields() — Extracts out the field updating since that could happen at a couple different extension points.
public
- HasPromotion() — For template so logic is slightly different and more compressed.
- OriginalPrice()
- PromoSavings()
- calculatePromoSavings()
- getOriginalPrice() — Original price for template usage
- hasValidPromotion() — Does this object have an applicable promo?
- sellingPriceBeforePromotion() — Returns the selling price without any discounts added in.
- updateCMSFields()
- updateProductCMSFields() — This is another extension point I added that is called AFTER all the product-specific fields and tabs are in place.
- updateSellingPrice()