SilverCart\Model\Order\SubShoppingCart
Used to create a sub shopping cart dependent on the "normal" shopping cart.
A sub shopping cart can be used to apply shopping cart plugins on a subset of
shopping cart positions (e.g. when splitting a single order into multiple orders
dependen on a product's / shopping cart position's distributor).
- Author: Sebastian Diel <sdiel@pixeltricks.de>
- Copyright: 2020 pixeltricks GmbH
- License: see license file in modules root directory
Synopsis
class SubShoppingCart
extends ShoppingCart
{
- // Inherited constants from ShoppingCart
- const SESSION_KEY = 'SilverCart.ShoppingCart';
- // members
- protected ShoppingCart $shoppingCart = NULL;
- protected ArrayList $shoppingCartPositions = NULL;
- // Inherited members from ShoppingCart
- public static array $registeredModules;
- public static boolean $loadModules;
- public static boolean $createForms;
- protected static ShoppingCart $cart;
- protected static bool $clear_checkout_after_write;
- protected Int $paymentMethodID;
- protected Int $shippingMethodID;
- protected array $shippingMethod;
- protected Int $shippingCountry;
- protected DataObject $chargesAndDiscountsForProducts;
- protected DataObject $chargesAndDiscountsForTotal;
- protected array $cacheHashes;
- protected array $taxTotalList;
- protected ArrayList $taxRatesWithFees;
- public static bool $cartCleaningInProgress;
- public static bool $cartCleaningFinished;
- protected ArrayList $registeredModulesSet;
- protected array $deliveryTimeData;
- // methods
- public static SubShoppingCart initBy()
- public void addShoppingCartPosition()
- public SubShoppingCart setShoppingCartPositions()
- public ArrayList ShoppingCartPositions()
- public Member Member()
- public ShoppingCart getShoppingCart()
- public SubShoppingCart setShoppingCart()
- public int write()
- // Inherited methods from ShoppingCart
- public static ShoppingCart|null getCart()
- public static void setClearCheckoutAfterWrite()
- public static bool getClearCheckoutAfterWrite()
- public void __construct()
- protected void cleanUp()
- public string singular_name()
- public string plural_name()
- public array fieldLabels()
- public FieldList getCMSFields()
- protected void onAfterWrite()
- public string Link()
- public bool HasChargesAndDiscountsForProducts()
- public bool HasChargesAndDiscountsForTotal()
- public bool HasMorePositionsThan()
- public bool HasNumberOfPositions()
- public bool HasProductsWithDifferentReleaseDates()
- public bool HasProductWithReleaseDates()
- public ShoppingCart clearPriceCache()
- public ArrayData ChargesAndDiscountsForProducts()
- public ArrayData ChargesAndDiscountsForTotal()
- public static void setLoadShoppingCartModules()
- public static void setCreateShoppingCartForms()
- public static ShoppingCartPosition addProduct()
- public static bool removeProduct()
- public ArrayList addToEditableShoppingCartTable()
- public void delete()
- public float getQuantity()
- public DBMoney getTaxableAmountWithFees()
- public DBMoney getTaxableAmountGrossWithFees()
- public DBMoney getTaxableAmountNetWithFees()
- public DBMoney getTaxableAmountWithoutFees()
- public DBMoney getTaxableAmountGrossWithoutFees()
- public DBMoney getTaxableAmountNetWithoutFees()
- public DBMoney getTaxableAmountWithoutModules()
- public DBMoney getTaxableAmountGrossWithoutModules()
- public DBMoney getTaxableAmountNetWithoutModules()
- public ArrayList getTaxableShoppingcartPositions()
- public DBMoney getTaxableAmountWithoutFeesAndCharges()
- public DBMoney getTaxableAmountGrossWithoutFeesAndCharges()
- public DBMoney getTaxableAmountGrossWithoutFeesAndChargesAndModules()
- public DBMoney getTaxableAmountNetWithoutFeesAndCharges()
- public DBMoney getTaxableAmountNetWithoutFeesAndChargesAndModules()
- public ArrayList getTaxTotal()
- public DBMoney getNonTaxableAmount()
- public DBMoney HandlingCostPayment()
- public DBMoney HandlingCostPaymentNet()
- public DBMoney HandlingCostShipment()
- public bool hasHandlingCostPayment()
- public bool hasHandlingCostShipment()
- public string CarrierAndShippingMethodTitle()
- public PaymentMethod getPayment()
- public ShippingMethod|null getShippingMethod()
- public ShippingMethod|null getCheapestShippingMethod()
- public DropdownField getShippingCountryDropdown()
- public $this setShippingCountry()
- public Country|null getShippingCountry()
- public PaymentMethod|null getPaymentMethod()
- public string MinimumOrderValue()
- public bool IsMinimumOrderValueReached()
- public bool isAvailableInStock()
- public ArrayData getDeliveryTimeData()
- public DBHTMLText getDeliveryTime()
- public string getDeliveryTimeMin()
- public string getDeliveryTimeMax()
- public DBMoney getAmountTotal()
- public DBMoney getAmountTotalGross()
- public DBMoney getAmountTotalNet()
- public DBMoney getAmountTotalNetWithoutVat()
- public DBMoney getAmountTotalWithoutTaxes()
- public DBMoney getAmountTotalWithoutFees()
- public DBMoney getAmountTotalGrossWithoutFees()
- public DBMoney getAmountTotalNetWithoutFees()
- public ArrayList getTaxRatesForFees()
- public ArrayList getTaxRatesWithFees()
- public ArrayList getTaxRatesWithoutFees()
- public ArrayList getTaxRatesWithoutFeesAndCharges()
- public static int get_most_valuable_tax_rate()
- public Tax getMostValuableTaxRate()
- public int|bool getWeightTotal()
- public bool getShowFees()
- public bool getHasFeesOrChargesOrModules()
- public void onBeforeDelete()
- public static void registerModule()
- public ArrayList registeredModules()
- public array callMethodOnRegisteredModules()
- public void setShippingMethodID()
- public void setPaymentMethodID()
- public bool isFilled()
- public void adjustPositionQuantitiesToStockQuantities()
- public void resetPositionMessages()
- public DBHTMLText getShoppingCartPositionNotices()
- public ArrayList getShoppingCartPositionNoticesList()
- public bool hasNotice()
- public DBHTMLText forTemplate()
- // Inherited methods from ExtensibleDataObject
- protected void beforeRequireDefaultRecords()
- protected void beforeUpdateCMSActions()
- protected void beforeUpdateFieldLabels()
- protected void beforeUpdateProvidePermissions()
- public array defaultFieldLabels()
- public static void reset_field_labels()
- protected array scaffoldFieldLabels()
Hierarchy
Constants
Name | Value |
---|---|
SESSION_KEY | 'SilverCart.ShoppingCart' |
Members
protected
- $cacheHashes
—
array
Contains hashes for caching. - $cart
—
SilverCart\Model\Order\ShoppingCart
Global cart context - $chargesAndDiscountsForProducts
—
SilverStripe\ORM\DataObject
Contains the calculated charges and discounts for product values for caching purposes. - $chargesAndDiscountsForTotal
—
SilverStripe\ORM\DataObject
Contains the calculated charges and discounts for the shopping cart total for caching purposes. - $clear_checkout_after_write
—
SilverCart\Model\Order\bool
Determines whether to clear checkout after writing or not. - $defaultFieldLabels
—
array
Default field labels. - $deliveryTimeData
—
array
Delivery time data. - $paymentMethodID
—
SilverCart\Model\Order\Int
Contains the ID of the payment method the customer has chosen. - $registeredModulesSet
—
SilverStripe\ORM\ArrayList
Set of registered modules. - $shippingCountry
—
SilverCart\Model\Order\Int
Shipping country context to show fees for. - $shippingMethod
—
array
List of already loaded shipping methods. - $shippingMethodID
—
SilverCart\Model\Order\Int
Contains the ID of the shipping method the customer has chosen. - $shoppingCart
—
SilverCart\Model\Order\ShoppingCart
The context shopping cart. - $shoppingCartPositions
—
SilverStripe\ORM\ArrayList
List of shopping cart positions to place an order for. - $taxRatesWithFees
—
SilverStripe\ORM\ArrayList
List of already calculated tax rates with fees - $taxTotalList
—
array
List of already calculated tax amounts
public
- $cartCleaningFinished
—
SilverCart\Model\Order\bool
Marker to check whether the cart position cleaning is finished or not. - $cartCleaningInProgress
—
SilverCart\Model\Order\bool
Marker to check whether the cart position cleaning is in progress or not. - $createForms
—
boolean
Indicates wether the registered modules should be loaded. - $loadModules
—
boolean
Indicates wether the registered modules should be loaded. - $registeredModules
—
array
Contains all registered modules that get called when the shoppingcart is displayed.
Methods
public
- Member() — Returns the related member.
- ShoppingCartPositions() — Returns the shopping cart positions.
- addShoppingCartPosition() — Adds the given $position.
- getShoppingCart() — Returns the related shopping cart context.
- initBy() — Initializes a new sub shopping cart by the given $shoppingCart context.
- setShoppingCart() — Sets the related shopping cart context.
- setShoppingCartPositions() — Sets the list of shopping cart positions.
- write() — A sub shopping cart can't be written.
Inherited from SilverCart\Model\Order\ShoppingCart
protected
- cleanUp() — Deletes all shopping cart positions without a product association or with a quantity of 0.
- onAfterWrite() — Clears the checkout session data after updating the shopping cart.
public
- CarrierAndShippingMethodTitle() — Returns the shipping method title.
- ChargesAndDiscountsForProducts() — Returns the charges and discounts for product values.
- ChargesAndDiscountsForTotal() — Returns the charges and discounts for the shopping cart total.
- HandlingCostPayment() — Returns the handling costs for the chosen payment method.
- HandlingCostPaymentNet() — Returns the handling costs for the chosen payment method excluding tax.
- HandlingCostShipment() — Returns the handling costs for the chosen shipping method.
- HasChargesAndDiscountsForProducts() — Indicates wether the cart has charges and discounts for the product values.
- HasChargesAndDiscountsForTotal() — Indicates wether the cart has charges and discounts for the total shopping cart value.
- HasMorePositionsThan() — Returns true if the given value is higher than the number of positions in the cart.
- HasNumberOfPositions() — Returns true if the number of positions in the cart equals the given value.
- HasProductWithReleaseDates() — Returns whether this shopping cart has at least one product with a release date.
- HasProductsWithDifferentReleaseDates() — Returns whether this shopping cart has products with different release dates.
- IsMinimumOrderValueReached() — Indicates wether the minimum order value is reached.
- Link() — Returns the link to the shopping cart page.
- MinimumOrderValue() — Returns the minimum order value.
- addProduct() — adds a product to the cart
- addToEditableShoppingCartTable() — Returns one or more plugged in rows for the shopping carts editable table as a ArrayList
- adjustPositionQuantitiesToStockQuantities() — Decrement all position quantities is they are larger than the related products stock quantities.
- callMethodOnRegisteredModules() — Calls a method on all registered modules and returns its output.
- clearPriceCache() — Clears the price cache.
- delete() — empties cart
- fieldLabels() — Field labels for display in tables.
- forTemplate() — Returns the rendered shopping cart.
- getAmountTotal() — Returns the end sum of the cart (taxable positions + nontaxable positions + fees).
- getAmountTotalGross() — Returns the end sum of the cart (taxable positions + nontaxable positions + fees).
- getAmountTotalGrossWithoutFees() — Returns the end sum of the cart without fees (taxable positions + nontaxable positions).
- getAmountTotalNet() — Returns the end sum of the cart (taxable positions + nontaxable positions + fees) excluding vat.
- getAmountTotalNetWithoutFees() — Returns the end sum of the cart without fees (taxable positions + nontaxable positions).
- getAmountTotalNetWithoutVat() — Returns the end sum of the cart (taxable positions + nontaxable positions + fees) excluding vat.
- getAmountTotalWithoutFees() — Returns the end sum of the cart without fees based on shop settings for net or gross price type
- getAmountTotalWithoutTaxes() — Returns the end sum of the cart (taxable positions + nontaxable positions + fees) without any taxes.
- getCMSFields() — Returns the CMS fields.
- getCart() — Returns the global shopping cart instance.
- getCheapestShippingMethod() — Returns the cheapest shipping method for the current cart context.
- getClearCheckoutAfterWrite() — Returns whether to clear checkout after writing or not.
- getDeliveryTime() — Returns the minimum delivery time as date string YYYY-MM-DD.
- getDeliveryTimeData() — Returns the delivery time as string.
- getDeliveryTimeMax() — Returns the maximum delivery time as date string YYYY-MM-DD.
- getDeliveryTimeMin() — Returns the minimum delivery time as date string YYYY-MM-DD.
- getHasFeesOrChargesOrModules() — Indicates wether the fees for shipping and payment should be shown.
- getMostValuableTaxRate() — Returns the Tax object with the highest tax value for the given taxes.
- getNonTaxableAmount() — Returns the non taxable amount of positions in the shopping cart.
- getPayment() — Returns the payment method object.
- getPaymentMethod() — Returns the payment method
- getQuantity() — returns quantity of all products in the cart
- getShippingCountry() — Returns the shipping country context.
- getShippingCountryDropdown() — Returns a DropdownField to choose a shipping country.
- getShippingMethod() — Returns the shipping method
- getShoppingCartPositionNotices() — returns a string with notices. Notices are seperated by <br />
- getShoppingCartPositionNoticesList() — Returns a list with notices.
- getShowFees() — Indicates wether the fees for shipping and payment should be shown.
- getTaxRatesForFees() — Returns the tax rates for shipping and payment fees.
- getTaxRatesWithFees() — Returns tax amounts included in the shoppingcart separated by tax rates with fee taxes.
- getTaxRatesWithoutFees() — Returns tax amounts included in the shoppingcart separated by tax rates without fee taxes.
- getTaxRatesWithoutFeesAndCharges() — Returns tax amounts included in the shoppingcart separated by tax rates without fee taxes.
- getTaxTotal() — Returns the total amount of all taxes.
- getTaxableAmountGrossWithFees() — Returns the GROSS price of the cart positions + fees, including taxes.
- getTaxableAmountGrossWithoutFees() — Returns the GROSS price of the cart positions, including taxes, excluding fees.
- getTaxableAmountGrossWithoutFeesAndCharges() — Returns the price of the cart positions, including taxes.
- getTaxableAmountGrossWithoutFeesAndChargesAndModules() — Returns the price of the cart positions, including taxes.
- getTaxableAmountGrossWithoutModules() — Returns the GROSS price of the cart positions without modules.
- getTaxableAmountNetWithFees() — Returns the NET price of the cart positions + fees, including taxes.
- getTaxableAmountNetWithoutFees() — Returns the NET price of the cart positions, including taxes, excluding fees.
- getTaxableAmountNetWithoutFeesAndCharges() — Returns the price of the cart positions.
- getTaxableAmountNetWithoutFeesAndChargesAndModules() — Returns the price of the cart positions.
- getTaxableAmountNetWithoutModules() — Returns the NET price of the cart positions without modules.
- getTaxableAmountWithFees() — Returns the price of the cart positions + fees, including taxes.
- getTaxableAmountWithoutFees() — Returns the price of the cart positions, including taxes, excluding fees.
- getTaxableAmountWithoutFeesAndCharges() — Returns the price of the cart positions, including or excluding taxes depending on the current context.
- getTaxableAmountWithoutModules() — Returns the price of the cart positions without modules.
- getTaxableShoppingcartPositions() — Returns all taxable shopping cart positions.
- getWeightTotal() — calculate the carts total weight needed to determin the ShippingFee
- get_most_valuable_tax_rate() — Returns the most valuable tax rate for the current cart.
- hasHandlingCostPayment() — Returns whether there are handling costs for payment.
- hasHandlingCostShipment() — Returns whether there are handling costs for shipment.
- hasNotice() — Is a notice set in the session?
- isAvailableInStock() — In case stock management is enabled: Find out if all positions quantities are still in stock
- isFilled() — determine wether a cart is filled or empty; useful for template conditional
- onBeforeDelete() — deletes all shopping cart positions when cart is deleted
- plural_name() — Returns the translated plural name of the object. If no translation exists the class name will be returned.
- registerModule() — Register a module.
- registeredModules() — Returns all registered modules.
- removeProduct() — Removes a product out of the cart.
- resetPositionMessages() — Reset all message tokens of the related cart positions.
- setClearCheckoutAfterWrite() — Sets whether to clear checkout after writing or not.
- setCreateShoppingCartForms() — Set wether the shopping cart forms should be drawn.
- setLoadShoppingCartModules() — Set wether the registered modules should be loaded and handled.
- setPaymentMethodID() — Set the ID of the payment method the customer has chosen.
- setShippingCountry() — Sets the shipping country.
- setShippingMethodID() — Set the ID of the shipping method the customer has chosen.
- singular_name() — Returns the translated singular name of the object. If no translation exists the class name will be returned.
Inherited from SilverCart\ORM\ExtensibleDataObject
protected
- beforeRequireDefaultRecords() — Allows user code to hook into DataObject::requireDefaultRecords() prior to requireDefaultRecords being called on extensions.
- beforeUpdateCMSActions() — Allows user code to hook into DataObject::getCMSActions prior to updateCMSActions being called on extensions.
- beforeUpdateFieldLabels() — Allows user code to hook into DataObject::fieldLabels() prior to updateFieldLabels being called on extensions.
- beforeUpdateProvidePermissions() — Allows user code to hook into DataObject::updateProvidePermissions() prior to providePermissions being called on extensions.
- scaffoldFieldLabels() — Returns the default field labels for this DataObject.
public
- defaultFieldLabels() — Returns the default field labels.
- reset_field_labels() — Resets the field label cache.