SilverShop\Discounts\Model\Discount
Synopsis
class Discount
extends DataObject
implements
PermissionProvider
{
- // members
- private static array $db = ;
- private static array $belongs_many_many = ;
- private static array $defaults = ;
- private static array $field_labels = ;
- private static array $summary_fields = ;
- private static array $searchable_fields = ;
- private static string $singular_name = 'Discount';
- private static string $plural_name = 'Discounts';
- private static string $default_sort = 'EndDate DESC, StartDate DESC';
- private static string $table_name = 'SilverShop_Discount';
- protected $message;
- protected $messagetype;
- private static integer $unpaid_use_timeout = 10;
- // methods
- public array getConstraints()
- public static ArrayList get_matching()
- public void getCMSFields()
- public void getDefaultSearchContext()
- public boolean validateOrder()
- public DataObject setCastedField()
- public calculated getDiscountValue()
- public void getDiscountNice()
- public void getAmount()
- public int getUseCount()
- public boolean isUsed()
- public void setPercent()
- public void setFor()
- public string getFor()
- public DataList getAppliedOrders()
- public float getSavingsTotal()
- public double getSavingsForOrder()
- public void canView()
- public void canCreate()
- public void canDelete()
- public void canEdit()
- protected void message()
- protected void error()
- public void getMessage()
- public void getMessageType()
- public void providePermissions()
- public bool valid()
Hierarchy
Extends
- SilverStripe\ORM\DataObject
Implements
- SilverStripe\Security\PermissionProvider
Members
private
- $belongs_many_many
- $db
- $default_sort
- $defaults
- $field_labels
- $plural_name
- $searchable_fields
- $singular_name
- $summary_fields
- $table_name
- $unpaid_use_timeout
—
integer
Number of minutes ago to include for carts with paymetn start in the {@link getAppliedOrders()} function
protected
- $message
- $messagetype
Methods
protected
public
- canCreate()
- canDelete()
- canEdit()
- canView()
- getAmount() — Get discounting amount
- getAppliedOrders() — Get the orders that this discount has been used on.
- getCMSFields()
- getConstraints()
- getDefaultSearchContext()
- getDiscountNice()
- getDiscountValue() — Works out the discount on a given value.
- getFor()
- getMessage()
- getMessageType()
- getSavingsForOrder() — Get the amount saved on the given order with this discount.
- getSavingsTotal() — Get the total amount saved through the use of this discount, accross all paid orders.
- getUseCount() — Get the number of times a discount has been used.
- get_matching() — Get the smallest possible list of discounts that can apply to a given order.
- isUsed() — Returns whether this coupon is used.
- providePermissions()
- setCastedField() — We have to tap in here to correct "50" to "0.5" for the percent field. This is a common user error and it's nice to just fix it for them.
- setFor() — Map the single 'For' to the For"X" boolean fields
- setPercent()
- valid()
- validateOrder() — Check if this coupon can be used with a given order