shop.modules.cart ================= .. py:module:: shop.modules.cart Attributes ---------- .. autoapisummary:: shop.modules.cart.logger Classes ------- .. autoapisummary:: shop.modules.cart.Cart Functions --------- .. autoapisummary:: shop.modules.cart.delete_guest_cart Module Contents --------------- .. py:data:: logger .. py:class:: Cart(moduleName = None, modulePath = None, shop = None, *args, **kwargs) Bases: :py:obj:`viur.shop.modules.abstract.ShopModuleAbstract`, :py:obj:`viur.core.prototypes.Tree` Abstract Class for all viur-shop sub/nested modules. The implementations should set `moduleName` as class variable, so the final module name for routing it not affected by the name of custom classes. .. py:attribute:: moduleName :value: 'cart' .. py:attribute:: nodeSkelCls .. py:attribute:: leafSkelCls .. py:method:: adminInfo() .. py:method:: baseSkel(skelType, sub_skel = None, *args, **kwargs) Extend default baseSkel() by sub_skel parameter .. py:method:: canView(skelType, skel) .. py:property:: current_session_cart_key :type: viur.core.db.Key | None .. py:method:: get_current_session_cart_key(*, create_if_missing = False) .. py:property:: current_session_cart :type: viur.shop.types.SkeletonInstance_T[shop.skeletons.cart.CartNodeSkel] .. py:method:: _ensure_current_session_cart() .. py:method:: detach_session_cart() .. py:method:: _set_basket_txn(user_key, basket_key) :staticmethod: .. py:method:: get_available_root_nodes(*args, **kwargs) .. py:attribute:: getAvailableRootNodes .. py:method:: listRootNodes(*args, **kwargs) Renders a list of all available repositories for the current user using the modules default renderer. :returns: The rendered representation of the available root-nodes. .. py:method:: is_valid_node(node_key, root_node = False) is this a valid node key for the user? :param node_key: Key of node to check :param root_node: Must this be a root node, or is any node okay? .. py:method:: get_children(parent_cart_key, **filters) .. py:method:: get_children_from_cache(parent_cart_key) .. py:method:: clear_children_cache() .. py:method:: cart_get(cart_key, skel_type) .. py:method:: get_article(article_key, parent_cart_key, *, must_be_listed = True) .. py:method:: add_or_update_article(article_key, parent_cart_key, *, quantity, quantity_mode, **kwargs) .. py:method:: copy_article_values(article_skel, skel) Copy values from the article to the cart leaf .. py:method:: move_article(article_key, parent_cart_key, new_parent_cart_key) .. py:method:: cart_add(*, parent_cart_key = None, cart_type = None, name = SENTINEL, customer_comment = SENTINEL, shipping_address_key = SENTINEL, shipping_key = SENTINEL, discount_key = SENTINEL, **kwargs) .. py:method:: cart_update(cart_key, *, parent_cart_key = SENTINEL, cart_type = None, name = SENTINEL, customer_comment = SENTINEL, shipping_address_key = SENTINEL, shipping_key = SENTINEL, discount_key = SENTINEL, **kwargs) .. py:method:: _cart_set_values(skel, *, parent_cart_key = SENTINEL, cart_type = None, name = SENTINEL, customer_comment = SENTINEL, shipping_address_key = SENTINEL, shipping_key = SENTINEL, discount_key = SENTINEL) .. py:method:: cart_remove(cart_key) .. py:method:: cart_clear(cart_key, *, keep_sub_carts = False) .. py:method:: additional_add_or_update_article(skel, /, **kwargs) Hook method called by :meth:`add_or_update_article` before the skeleton is saved. This method can be overridden in a subclass to implement additional API fields or make further modifications to the cart skeleton (`skel`). By default, it raises an exception if unexpected arguments (``kwargs``) are provided and returns the unchanged `skel` object. :param skel: The current instance of the cart item skeleton. :param kwargs: Additional optional arguments for extended implementations. :raises TooManyArgumentsException: If unexpected arguments are passed in ``kwargs``. :return: The (potentially modified) cart item skeleton. .. py:method:: additional_cart_add(skel, /, **kwargs) Hook method called by :meth:`cart_add` before the skeleton is saved. This method can be overridden in a subclass to implement additional API fields or make further modifications to the cart skeleton (`skel`). By default, it raises an exception if unexpected arguments (``kwargs``) are provided and returns the unchanged `skel` object. :param skel: The current instance of the cart skeleton. :param kwargs: Additional optional arguments for extended implementations. :raises TooManyArgumentsException: If unexpected arguments are passed in ``kwargs``. :return: The (potentially modified) cart skeleton. .. py:method:: additional_cart_update(skel, /, **kwargs) Hook method called by :meth:`cart_update` before the skeleton is saved. This method can be overridden in a subclass to implement additional API fields or make further modifications to the cart skeleton (`skel`). By default, it raises an exception if unexpected arguments (``kwargs``) are provided and returns the unchanged `skel` object. :param skel: The current instance of the cart skeleton. :param kwargs: Additional optional arguments for extended implementations. :raises TooManyArgumentsException: If unexpected arguments are passed in ``kwargs``. :return: The (potentially modified) cart skeleton. .. py:method:: freeze_cart(cart_key) Freeze (lock) cart values and children items. :param cart_key: Key of the (sub-)cart skeleton. :return: The frozen CartNode skeleton. .. py:method:: freeze_leaf(leaf_skel) .. py:method:: get_discount_for_leaf(leaf_key_or_skel) .. py:method:: add_new_parent(leaf_skel, **kwargs) .. py:method:: get_cached_cart_skel(key) .. py:method:: get_closest_node(start, condition = lambda skel: True) .. py:function:: delete_guest_cart(session) Delete carts from guest sessions to avoid orphaned carts