==== Cart ==== ``store.cart`` provides you the current cart. This variable is only available after the add to cart action. ``store.cart`` allow cart lines with product data, shipping address, delivery mode, Cart is stored and managed directly via odoo. To avoid performance problems, cart data are cached, each cart updating (add new product, set a shipping address…) refresh cached datas via an Odoo API call. Each cart update recalculate grand total, subtotal, shipping cost and VAT amount automatically. To validate a cart you need to have a logged user. Attributes ========== ----------- Cart header ----------- .. csv-table:: store.cart attributes :header: "Name", "Type", "Desciption" :widths: 15, 15, 70 "amount", "Date", "Grand total and taxes, See :ref:`cart_amount` documentation" "date", "Date", "The cart creation date" "lines", "Array", "Cart lines See :ref:`cart_lines` documentation" "id", "Integer", "Cart ID" "invoicing", "Object", "Invoice address, see :ref:`cart_invoicing` doc" "name", "String", "Cart reference" "payment", "Object", "Payment method selected, see :ref:`cart_payment_method` doc" "shipping", "Object", "Shipping address, see :ref:`cart_shipping` doc" "state", "String", "Odoo sale order status" "step", "String", "Cart Step list, see :ref:`cart_checkout` doc" .. _cart_amount: Amout ------ Amout object provide cart Grand total and taxes amount .. csv-table:: store.cart.amount :header: "Name", "Type", "Desciption" :widths: 15, 15, 70 "tax", "Float", "VAT grand total (Item and shipping cost included)" "total", "Float", "Grand total (included taxes)" "untaxed", "Float", "Total amount without taxes" .. _cart_shipping: Shipping --------- Shipping object provide shipping customer address, selected carrier and shipping cost. .. csv-table:: store.cart amount :header: "Name", "Type", "Desciption" :widths: 15, 15, 70 "address", "Object", "Shipping address" "amount.tax", "Float", "Shipping cost's tax" "amount.total", "Float", "Shipping cost taxes included" "amount.untaxed", "Float", "Shipping cost without taxes" "carrier", "Float", "Total amount included taxes" "trackings", "Array", "Parcel tracking URLs, not available for cart." .. _cart_invoicing: Invoicing ---------- Shipping object provide invoicing customer address. .. csv-table:: store.cart amount :header: "Name", "Type", "Desciption" :widths: 15, 15, 70 "address", "Object", "invoicing address" Actions ========== Some actions are available to manage cart content. Cart actions use html form. Each action need form submitting with specific parameters and action attribute value. Usally, we use hidden input to specify these parameters values. You have to use get or post for form method. All actions require ``invader_success_url`` and ``invader_error_url`` parameters to defined URL page use for redirection in case of success or error. The action form attribute is use to specify a Shopinvader controller ( /invader/cart/update, /invader/cart/add_item...) .. note:: POST or GET form method will have the same effect. .. _cart_checkout: ---------------------- Checkout step process ---------------------- Actually Shopinvader use muli-page checkout. To move from one step to the next you need to submit a HTML form with specific parameters to indicate the current and the next checkout step. This process is necessary to ensure the cart data viability. Usally we recommended these cart steps : * Cart summary * Customer login * Select shipping address * Select Shipping mode and payment * order summary You have to set up your cart steps into odoo backend configuration. .. csv-table:: HTML form input :header: "Input name", "Type", "Desciption" :widths: 15, 15, 70 "invader_success_url", "String", "Shopinvader cart controller name" "invader_error_url", "String", "Method on controller" "current_step", "String", "current step ID" "next_step", "String", "next step ID" form submitting on /invader/cart/update may be combined various actions like select shipping address, define shipping method in the same time. HTML form to go to the next step .. code-block:: html
.. _cart_address: ------------------------------------ Select Shipping and billing address ------------------------------------ In your cart a customer can enter two addresses: billing address or shipping address. shipping and billing address are an item of ``store.addresses``. ``store.addresses`` collection (:ref:`see store.addresses documentation `). *Controller* /invader/cart/update .. csv-table:: HTML form input :header: "Input name", "Type", "Desciption" :widths: 15, 15, 70 "invader_success_url", "String", "Shopinvader cart controller name" "invader_error_url", "String", "Method on controller" "partner_shipping", "integer", "Address ID, address list provided by ``store.addresses``" "partner_invoice", "integer", "Address ID, address list provided by ``store.addresses``" HTML form to choose shipping .. code-block:: html

Select shipping address

{% with_scope address_type: "address" %} {% for address in store.addresses %}
{{address.display_name}}
{% endfor %} {% endwith_scope %}

Select billing address

{% with_scope address_type: "address" %} {% for address in store.addresses %}
{{address.display_name}}
{% endfor %} {% endwith_scope %}
.. _cart_shipping_method: ------------------------ Select shipping method ------------------------ *Controller* /invader/cart/update .. csv-table:: HTML form input :header: "Input name", "Type", "Desciption" :widths: 15, 15, 70 "invader_success_url", "String", "Shopinvader cart controller name" "invader_error_url", "String", "Method on controller" "partner_shipping", "integer", "Address ID, address list provided by ``store.addresses``" "partner_invoice", "integer", "Address ID, address list provided by ``store.addresses``" ``store.cart.available_carriers`` provide carrier list. HTML form to go to the next step .. code-block:: html
{%for carrier in store.cart.available_carriers%}
{{carrier.name}}
{% endfor %}
.. _cart_payment_method: ------------------------ Select payment method ------------------------ *Controller* /invader/cart/update ``store.cart.available_payment_method`` provide carrier list. HTML form to go to the next step .. code-block:: html
{%for payment_method in store.cart.available_payment_method%}
{{payment_method.name}}
{% endfor %}
.. _cart_lines: ========== Cart lines ========== Attributes =========== A line represents a single line in the shopping cart. This object can be accessed in all Liquid templates via ``store.cart.lines.items``. There is one cart line for each product variant added to the shopping cart. Cart and cart lines are stored directly in odoo. This object has the following attributes: .. csv-table:: store.cart.order_line attributes :header: "Name", "Type", "Desciption" :widths: 15, 15, 70 "count", "Integer", "Number of items in cart" "amount", "Object", "subtotal of all products added to cart" "items", "Object", "Collection of lines " .. cart_lines_amount: Amount ------ Amout object provide cart Grand total and taxes amount of all product in cart .. csv-table:: store.cart.amount :header: "Name", "Type", "Desciption" :widths: 15, 15, 70 "tax", "Float", "VAT grand total (Item and shipping cost included)" "total", "Float", "Total amount of products (included taxes)" "untaxed", "Float", "Total amount of products without taxes" .. cart_lines_items: Items ------ Collection of cart line, provide all products added to cart. .. csv-table:: store.cart.amount :header: "Name", "Type", "Desciption" :widths: 15, 15, 70 "amount", "Object", "cart line amount" "product", "Object", "product object (lite version only with sku, name, short_name, images, model, url_key)" "discount", "Object", "Discount object (rate, value...)" *Cart line json* .. code-block:: json { "order_line":[ { "product":{ "images":[ {"small":"" ,"large":"","medium":"","original":""}, {"small":"" ,"large":"","medium":"","original":""} ], "default_code":"SKUPRODUCT", "url_key":"my-product-url", "name":"Great product", "id": 208 }, "price_unit":60, "product_uom_qty":2.0, "price_subtotal":100, "discount":0,"price_subtotal_gross":120, "is_delivery":false, "id": 3008 } ] } *Display lines in template* .. code-block:: liquid {% for line in store.cart.lines %} {% endfor %}
{{line.product.name}} {{line.product_uom_qty}} {{line.price_subtotal | money}}
Actions ========== ------------------- Add product to cart ------------------- *Controller* /invader/cart/add_item .. csv-table:: HTML form input :header: "Input name", "Value", "Desciption" :widths: 15, 15, 70 "invader_success_url", "string", "URL in case of success" "invader_error_url", "string", "URL in case of error" "product_id", "integer", "``ObjectID`` of product added to cart " "item_qty", "integer", "Product quantity added to cart" HTML form to add product in cart .. code-block:: html
...
------------------- Update quantity ------------------- This action is usally used in cart item list. *Controller* /invader/cart/update_item .. csv-table:: HTML form input :header: "Input name", "Value", "Desciption" :widths: 15, 15, 70 "invader_success_url", "string", "URL in case of success" "invader_error_url", "string", "URL in case of error" "item_id", "integer", "cart line ID" "item_qty", "integer", "New product quantity" HTML form to change product quantity .. code-block:: html
...
------------------------ Remove product to cart ------------------------ .. csv-table:: HTML form input :header: "Input name", "Value", "Desciption" :widths: 15, 15, 70 "invader_success_url", "string", "URL in case of success" "invader_error_url", "string", "URL in case of error" "item_id", "integer", "cart line ID" HTML form to remove cart line .. code-block:: html
...