Cart Object¶
-
class
shoppingCart.cart.Cart(site=None, customer=None)[source]¶ Collection of
CartItemobjects.-
add_item(product, price=0.0, quantity=1, taxes=[], options={})[source]¶ To add or update product, price, quantity, taxes and options in
CartItemobject.Parameters: - product – Unique id or name of
Productobject or instance ofProduct. - price – Product price.
- quantity – Product quantity(default 1).
- taxes – Taxes of the product(default []).
- options – Options of the product(default {}).
- product – Unique id or name of
-
update_item(product, quantity, option_values=[])[source]¶ To update
CartItemobject quantity.Parameters: - product – Unique id or name of
Productobject or instance ofProduct. - quantity – Updated quantity.
- option_values – Option values of the product(default []).
- product – Unique id or name of
-
remove_item(product, option_values=[])[source]¶ To remove existing
CartItemobject related to product.Parameters: - product – Unique id or name of
Productobject or instance ofProduct. - option_values – Option values of the product(default []).
- product – Unique id or name of
-
find_item(product, option_values=[])[source]¶ To find
CartItemobject related to product.Parameters: - product – Unique id or name of
Productobject or instance ofProduct. - option_values – Option values of the product(default []).
Returns: CartItemobject if cart item is exist else None.- product – Unique id or name of
-
add_discount(amount, type='percentage')[source]¶ To apply discount.
Parameters: - amount – Discount amount.
- type – Discount type like ‘percentage’ or ‘amount’(default amount).
-
add_tax(amount, type='percentage')[source]¶ To apply taxes.
Parameters: - tax – Tax amount according to country region.
- type – Tax type like ‘percentage’ or ‘fixed’(default percentage).
Returns: True if tax is applied and tax is already exist then False.
-
remove_tax(amount, type='percentage')[source]¶ To remove existing tax.
Parameters: - amount – Tax amount according to country region.
- type – Tax type like ‘percentage’ or ‘fixed’(defualt percentage).
-
find_tax(amount, type='percentage')[source]¶ To find applied tax.
Parameters: - amount – Tax amount according to country region.
- type – Tax type like ‘percentage’ or ‘fixed’(defualt percentage).
Returns: True if tax is exist else False.
-
total()[source]¶ Returns: Total amount(tax excluded or tax included) by adding total untaxed amount, total tax and shipping charge.
-
is_empty¶ Returns: True if cart has an item else False.
-
is_discount_applied¶ Returns: True if discount is applied else False.
-
has_taxes¶ Returns: True if tax is applied else False.
-
shipping_charge¶ Returns: Shipping charge.
-