Sunnysideup\Ecommerce\Model\OrderModifier
which returns an array of IDs SEQUENCE - USE FOR ALL MODIFIERS!!! *** 1. model defining static variables (e.g. $db, $has_one) *** 2. cms variables + functions (e.g. getCMSFields, $searchableFields) *** 3. other (non) static variables (e.g. private static $special_name_for_something, protected $order) *** 4. CRUD functions (e.g. canEdit) *** 5. init and update functions *** 6. form functions (e. g. Showform and getform) *** 7. template functions (e.g. ShowInTable, TableTitle, etc...) ... USES DB VALUES *** 8. inner calculations.... USES CALCULATED VALUES *** 9. calculate database fields: protected function Live[field name] ... USES CALCULATED VALUES *** 10. standard database related functions (e.g. onBeforeWrite, onAfterWrite, etc...) *** 11. AJAX related functions *** 12. debug functions.
FAQs
*** What is the difference between cart and table
The Cart is a smaller version of the Table. Table is used for Checkout Page + Confirmation page.
Cart is used for other pages (pre-checkout for example). At times, the values and names may differ
Synopsis
class OrderModifier
extends OrderAttribute
{
- // members
- protected bool $doNotAddAutomatically = false;
- protected bool $canBeRemoved = false;
- protected bool $mustUpdate = false;
- private static array $api_access = ;
- private static array $ajax_total_format = ;
- private static string $table_name = 'OrderModifier';
- private static array $db = ;
- private static array $defaults = ;
- private static array $searchable_fields = ;
- private static array $summary_fields = ;
- private static array $casting = ;
- private static string $singular_name = 'Order Modifier';
- private static string $plural_name = 'Order Modifiers';
- private static string $description = 'An addition to the order that sits between the sub-total and the total (e.g. tax, delivery, etc...).';
- private integer $runningTotal = 0;
- private OrderModifierDescriptor $orderModifier_Descriptor;
- // Inherited members from OrderAttribute
- protected null|bool $_canEdit;
- protected null|bool $_canView;
- protected bool $baseInitCalled;
- // methods
- public void i18n_singular_name()
- public void i18n_plural_name()
- public FieldList getCMSFields()
- public FieldList scaffoldSearchFields()
- public static void init_for_order()
- public void init()
- public void runUpdate()
- public bool canCreate()
- public bool canDelete()
- public float CalculationTotal()
- public void ShowForm()
- public void ShowFormInEditableOrderTable()
- public bool ShowFormOutsideEditableOrderTable()
- public null|OrderModifierForm getModifierForm()
- public string TableTitle()
- public void getTableTitle()
- public string Heading()
- public string Description()
- public string MoreInfoPage()
- public void ShowInTable()
- public DBMoney TableValueAsMoney()
- public void getTableValueAsMoney()
- public bool HideInAjaxUpdate()
- public bool CanBeRemoved()
- public bool CanAdd()
- public bool DoNotAddAutomatically()
- public float CalculatedTotal()
- public string AddLink()
- public string RemoveLink()
- public array PostSubmitAction()
- public float getRunningTotal()
- public void getLiveType()
- public bool IsChargeable()
- public bool IsDeductable()
- public bool IsNoChange()
- public bool IsRemoved()
- public void onBeforeRemove()
- public void onAfterRemove()
- public array updateForAjax()
- public void debug()
- protected bool canBeUpdated()
- protected void checkField()
- protected headingField()
- protected descriptionField()
- protected null|DataObject|OrderModifierDescriptor getOrderModifierDescriptor()
- protected void LiveName()
- protected void LiveTableValue()
- protected DBCurrency LiveCalculatedTotal()
- protected void LiveType()
- // Inherited methods from OrderAttribute
- public void i18n_singular_name()
- public void i18n_plural_name()
- public void init()
- public bool canCreate()
- public bool canView()
- public bool canEdit()
- public bool canDelete()
- public string CMSEditLink()
- public static void set_price_has_been_fixed()
- public static null|bool get_price_has_been_fixed()
- public string OrderAttributeType()
- public null|Order Order()
- public string Classes()
- public EcommerceConfigAjaxDefinitions AJAXDefinitions()
- public void ShowInTable()
- public bool ShowInCart()
- public string TableTitle()
- public void getTableTitle()
- public string CartTitle()
- public void getCartTitle()
- public string TableSubTitle()
- public void getTableSubTitle()
- public string TableSubTitleNOHTML()
- public void getTableSubTitleNOHTML()
- public string CartSubTitle()
- public void getCartSubTitle()
- public DBMoney CalculatedTotalAsMoney()
- public void getCalculatedTotalAsMoney()
- public void runUpdate()
- public void debug()
- protected void onBeforeWrite()
- protected void onAfterWrite()
- protected bool priceHasBeenFixed()
- // Inherited methods from OrderCached
- public void setOrderCached()
- public Order|null; getOrderCached()
Hierarchy
Members
private
- $ajax_total_format — array
- $api_access
—
array
what variables are accessible through http://mysite.com/api/ecommerce/v1/OrderModifier/. - $casting
—
array
stardard SS definition. - $db
- $defaults
—
array
make sure to choose the right Type and Name for this. - $description
—
string
Standard SS variable. - $orderModifier_Descriptor
—
Sunnysideup\Ecommerce\Model\OrderModifierDescriptor
caching of relevant OrderModifierDescriptor. - $plural_name
—
string
stardard SS variable. - $runningTotal
—
float
When recalculating all the modifiers, this private variable is added to as a running total other modifiers can then tap into this to work out their own values. - $searchable_fields
—
array
stardard SS variable. - $singular_name
—
string
stardard SS variable. - $summary_fields
—
array
stardard SS definition. - $table_name — string
protected
- $_canEdit
—
Sunnysideup\Ecommerce\Model\null|bool
save edit status for speed's sake. - $_canView
—
Sunnysideup\Ecommerce\Model\null|bool
save view status for speed's sake. - $baseInitCalled
—
Sunnysideup\Ecommerce\Model\bool
we use this variable to make sure that the parent::runUpdate() is called in all child classes this is similar to the checks run for parent::init in the controller class. - $canBeRemoved
—
Sunnysideup\Ecommerce\Model\bool
$can_be_removed Identifies whether a modifier can be removed by the user. - $doNotAddAutomatically
—
Sunnysideup\Ecommerce\Model\bool
$doNotAddAutomatically Identifies whether a modifier is NOT automatically added Most modifiers, such as delivery and GST would be added automatically. - $mustUpdate
—
Sunnysideup\Ecommerce\Model\bool
This is a flag for running an update. - $orderCached — Sunnysideup\Ecommerce\Model\Order
- $orderCachedStatusID — int
Methods
protected
- LiveCalculatedTotal() — This function is always called to determine the amount this modifier needs to charge or deduct - if any.
- LiveName()
- LiveTableValue()
- LiveType()
- canBeUpdated() — You can overload this method as canEdit might not be the right indicator.
- checkField() — This method simply checks if a fields has changed and if it has changed it updates the field.
- descriptionField()
- getOrderModifierDescriptor() — returns the relevant orderModifier_Descriptor.
- headingField()
public
- AddLink() — This link is for modifiers that have been removed and are being put "back".
- CalculatedTotal() — Actual calculation used.
- CalculationTotal() — Provides a modifier total that is positive or negative, depending on whether the modifier is chargable or not.
- CanAdd() — Checks if the modifier can be added manually.
- CanBeRemoved() — Checks if the modifier can be removed.
- Description() — returns a description if there is one.
- DoNotAddAutomatically() — Identifier whether a modifier will be added automatically for all new orders.
- Heading() — returns a heading if there is one.
- HideInAjaxUpdate() — some modifiers can be hidden after an ajax update (e.g. if someone enters a discount coupon and it does not exist).
- IsChargeable() — should be extended if it is true in child class.
- IsDeductable() — should be extended if it is true in child class.
- IsNoChange() — should be extended if it is true in child class.
- IsRemoved() — should be extended if it is true in child class Needs to be a public class.
- MoreInfoPage() — returns a page for a more info link... (if there is one).
- PostSubmitAction() — retursn and array like this: array(Title => "bla", Link => "/doit/now/");.
- RemoveLink() — Link that can be used to remove the modifier.
- ShowForm() — This determines whether the OrderModifierForm is shown or not. {@link OrderModifier::get_form()}.
- ShowFormInEditableOrderTable() — Should the form be included in the EDITABLE form on the checkout page?
- ShowFormOutsideEditableOrderTable() — Should the form be shown outside of editable table on the checkout page (opposite of ShowFormInEditableOrderTable)?
- ShowInTable() — tells you whether the modifier shows up on the checkout / cart form.
- TableTitle() — Casted variable, returns the table title.
- TableValueAsMoney() — Returns the Money object of the Table Value.
- canCreate() — standard SS Method.
- canDelete() — standard SS Method.
- debug() — Debug helper method.
- getCMSFields() — stardard SS metbod.
- getLiveType()
- getModifierForm() — This function returns a form that allows a user to change the modifier to the order.
- getRunningTotal() — returns the running total variable.
- getTableTitle()
- getTableValueAsMoney()
- i18n_plural_name()
- i18n_singular_name()
- init() — This method runs when the OrderModifier is first added to the order.
- init_for_order()
- onAfterRemove() — removing the Order Modifier does not delete it rather, it ignores it (e.g. remove discount coupon) We cant delete it, because we need to have a positive record of it being removed.
- onBeforeRemove() — removing the Order Modifier does not delete it rather, it ignores it (e.g. remove discount coupon) We cant delete it, because we need to have a positive record of it being removed.
- runUpdate()
- scaffoldSearchFields() — Determine which properties on the DataObject are searchable, and map them to their default {@link FormField} representations. Used for scaffolding a searchform for {@link ModelAdmin}.
- updateForAjax()
Inherited from Sunnysideup\Ecommerce\Model\OrderAttribute
protected
- onAfterWrite() — Standard SS method.
- onBeforeWrite() — Standard SS method We add the Sort value from the OrderAttributeGroup to the OrderAttribute.
- priceHasBeenFixed() — meaning that is has been saved in the CalculatedTotal field so that it can not be altered.
public
- AJAXDefinitions() — returns the instance of EcommerceConfigAjax for use in templates.
- CMSEditLink() — link to edit the record.
- CalculatedTotalAsMoney() — Returns the Money object of the CalculatedTotal.
- CartSubTitle() — the sub title for the order item or order modifier.
- CartTitle() — Return a name of what this attribute is called e.g. "Product 21" or "Discount" Cart is a short version of table.
- Classes() — Return a string of class names, in order of hierarchy from OrderAttribute for the current attribute.
- Order() — returns the order - for some unknown reason it seems we need this.
- OrderAttributeType() — This is a key function that returns the type of the object. In principle anything can be returned but the intention is to only return a few options e.g. OrderItem, Tax, Delivery, etc... so that computations can be carried out based on the type of OrderAttribute we are looking at.
- ShowInCart() — Should this item be shown on in the cart (which is on other pages than the checkout page).
- ShowInTable()
- TableSubTitle() — the sub title for the order item or order modifier.
- TableSubTitleNOHTML() — the sub title for the order item or order modifier.
- TableTitle() — Return a name of what this attribute is called e.g. "Product 21" or "Discount".
- canCreate() — standard SS method.
- canDelete() — Standard SS method.
- canEdit() — Standard SS method This is an important method.
- canView() — Standard SS method This is an important method.
- debug() — Debug helper method.
- getCalculatedTotalAsMoney()
- getCartSubTitle()
- getCartTitle()
- getTableSubTitle()
- getTableSubTitleNOHTML()
- getTableTitle()
- get_price_has_been_fixed()
- i18n_plural_name()
- i18n_singular_name()
- init() — extended in OrderModifier and OrderItem Starts up the order Atribute TODO: introduce system like we have for Controller which makes sure that all parent init methods are called.
- runUpdate()
- set_price_has_been_fixed()