Cart³
Cart3 requires the cart3 Centre Option in order to work
Note: You do not need the new_cart centre option, but new_order_proccess is required.
Overview
Cart3 is the new Core dna eCommerce cart. It was created to combat the problems of the other carts becoming complex and hard to use. It no longer stores it's data in the session, using the database instead. This allows us to retain guest carts and pull out old carts at any time.
On every page load, Cart3 is assigned - so no matter where you are you will have access to the Cart3 object. It's called $cart3.
Every load of Cart3 will also load all the current Discounts and Vouchers. We no longer insert this data into the checkout screen in one go - but allow this information to be passed at anytime, anywhere.
Every Cart3 is loaded by what is called the Cart Key. This is a salt of the centre_id, session_id and user_id. This is unique to every Cart3 instance.
New Features
- Store Cart in the DB.
- Cart3 supports AJAX calls. No longer needing to submit a form for every action.
- OmniPayment - A payment gateway library which support many gateways. Adding any of these gateways listed is just a question of passing the correct data.
- Paying Instalments. Cart3 Allows you to partially pay off an order.
- Cart3 supports Zone Based Shipping
- Discounts for Cart3. They discount the cart total based on their own conditions and action.
- Cart3 supports Agents. Which is a role based sales module, used for managing sales and quotes.
- Cart3 supports Quotes, saving the current cart into the DB to be loaded at a later date.
- Cart3 can restore an older completed Order.
- Cart3 records every transaction made with any gateway.
How to Access Cart3
On any page, you can access Cart3 using the variable $cart3. This is the cart at the time of page load.
Cart3 Functions
Listed below are the functions available to use for Cart3.
getKey() // Get unique cart3 identifier (string) getMerchantId() // Get the MerchantId for this Cart (int) getCentreId() // Return the Centre ID for the Cart (int) getUserId() // Return the User Id for this Cart (int) getDefaultTax() // This is the default tax set in the DXP config. i.e: 10% (string) isTaxInclusive() // Return Boolean if Tax is Inclusive or not (boolean) getSubTotal() // Get the Cart SubTotal (float) describe() // Function which returns a short summary of the cart contents (string) getTax() // Get tax total (float) getSurcharge() // Get the surcharge price (float) getDiscountTotal() // Get the discount total (float) getShippingTotal() // Get the shipping total (float) getTotal() // Get the final price of this cart (float) getTotalWithoutDiscount() // Get the Cart price without discount if any (float) countItems() // Count everything in the cart (int) countProducts() // Count all the Products in the cart (int) countBundles() // Count all the BUndles in the cart (int) getProductIds() // Get ids from all cart products (array) getBundleIds() // Get ids from all cart bundles (array) getProducts() // Get array of CatProduct Objects in cart (array) getBundles() // Get array of Bundle Objects in cart (array) getVoucherCode() // Return Voucher Code loaded, if any (string) getQuantity() // Return the total Quantity of the Cart (int) getVoucher() // Get the Voucher object if any used (obj) getVoucherTotal() // Get the total voucher amount discounted (float) |
Adding a Product to Cart3
to add a product to cart3 you can make a post or an ajax query to form_name='action3' with form_action='add_product'
the following are expected:
- 'product_id' => id of the product you are adding
- 'variant_id' => id of the variant you are adding
- 'bundle_id' => id of the bundle you are adding
- 'quantity' => the quantity of this cart item
- 'attrib' => the options for this item, passed like so: array [optionId:int => selectedValueId:int, optionId:int => selectedValueId:int, ...]