SilverShop\Discounts\Model\OrderCoupon
Applies a discount to current order, if applicable, when entered at checkout.
Synopsis
class OrderCoupon
extends Discount
{
- // members
- private static array $db = ;
- private static array $has_one = ;
- private static array $searchable_fields = ;
- private static array $summary_fields = ;
- private static string $singular_name = 'Coupon';
- private static string $plural_name = 'Coupons';
- private static $minimum_code_length = NULL;
- private static integer $generated_code_length = 10;
- private static string $table_name = 'SilverShop_OrderCoupon';
- // Inherited members from Discount
- protected $message;
- protected $messagetype;
- // methods
- public static void get_by_code()
- public static string generate_code()
- public void getCMSFields()
- public void validate()
- protected void onBeforeWrite()
- public $this setCode()
- public void canView()
- public void canCreate()
- public void canDelete()
- public void canEdit()
- // Inherited methods from Discount
- 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
Tasks
Line | Task |
---|---|
62+ | depending on the length, it may be possible that all the possible codes have been generated. |
Members
private
- $db
- $generated_code_length
- $has_one
- $minimum_code_length
- $plural_name
- $searchable_fields
- $singular_name
- $summary_fields
- $table_name
protected
- $message
- $messagetype
Methods
protected
public
- canCreate()
- canDelete()
- canEdit()
- canView()
- generate_code() — Generates a unique code.
- getCMSFields()
- get_by_code()
- setCode() — Forces codes to be alpha-numeric, uppercase, and trimmed
- validate()
Inherited from SilverShop\Discounts\Model\Discount
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