shop.modules.api ================ .. py:module:: shop.modules.api Attributes ---------- .. autoapisummary:: shop.modules.api.logger Classes ------- .. autoapisummary:: shop.modules.api.Api Module Contents --------------- .. py:data:: logger .. py:class:: Api(moduleName = None, modulePath = None, shop = None, *args, **kwargs) Bases: :py:obj:`viur.shop.modules.abstract.ShopModuleAbstract` 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:property:: json_renderer :type: viur.core.render.json.default.DefaultRender .. py:method:: article_view(article_key, parent_cart_key) View an article in the cart .. py:method:: article_add(*, article_key, quantity = 1, quantity_mode = QuantityMode.REPLACE, parent_cart_key = SENTINEL, **kwargs) Add an article to the cart :param article_key: Key of the article to add. :param quantity: Quantity of the article to add. :param quantity_mode: Behavior of the quantity: absolute or relative valuation :param parent_cart_key: Key of the (sub) cart (node) to which this leaf will be added as a child. Use "BASKET" as key to use the basket of the current session. .. py:method:: article_update(*, article_key, quantity, quantity_mode = QuantityMode.REPLACE, parent_cart_key = SENTINEL, **kwargs) Update an existing article in the cart :param article_key: Key of the article to update. Note: This is not the key of the leaf skel! :param quantity: Quantity of the article to update. :param quantity_mode: Behavior of the quantity: absolute or relative valuation :param parent_cart_key: Optional. Key of the (sub) cart (node) to which this leaf will be moved to as a child. Use "BASKET" as key to use the basket of the current session. .. py:method:: article_remove(*, article_key, parent_cart_key, **kwargs) Remove an article from the cart .. py:method:: article_move(*, article_key, parent_cart_key, new_parent_cart_key) Move an article inside a cart .. py:method:: cart_add(*, parent_cart_key = None, cart_type = SENTINEL, name = SENTINEL, customer_comment = SENTINEL, shipping_address_key = SENTINEL, shipping_key = SENTINEL, discount_key = SENTINEL, **kwargs) Add a new cart node :param parent_cart_key: Key of the parent cart :param cart_type: Type of the cart node, see :class:`CartType` :param name: Optional. Name of the cart node :param customer_comment: Optional. Comment to this node, by customer. :param shipping_address_key: Optional. Key of the address :param shipping_key: Optional. Key of the shipping :param discount_key: Optional. Key of the discount Returns: The created cart node skel .. py:method:: cart_update(*, cart_key, cart_type = SENTINEL, name = SENTINEL, customer_comment = SENTINEL, shipping_address_key = SENTINEL, shipping_key = SENTINEL, discount_key = SENTINEL, **kwargs) Update an existing cart node :param cart_key: Key of the cart node to be updated :param cart_type: Type of the cart node, see :class:`CartType` :param name: Optional. Name of the cart node :param customer_comment: Optional. Comment to this node, by customer. :param shipping_address_key: Optional. Key of the address :param shipping_key: Optional. Key of the shipping :param discount_key: Optional. Key of the discount Returns: The updated cart node skel .. py:method:: cart_remove(*, cart_key) Remove a cart node. Removes itself and all children :param cart_key: Key of the cart node to be removed .. py:method:: cart_clear(*, cart_key = SENTINEL, keep_sub_carts = False) Remove direct or all children :param cart_key: Key of the (sub) cart (node) from which the children should be removed. Use "BASKET" as key to use the basket of the current session. :param keep_sub_carts: Keep child nodes, remove only leafs .. py:method:: basket_list() List the children of the basket (the cart stored in the session) :raises errors.PreconditionFailed: If no basket created yet for this session .. py:method:: basket_view(*, create_if_missing = False) View the basket (the cart stored in the session) itself :param create_if_missing: Create the basket if not already created for this session :raises errors.PreconditionFailed: If no basket created yet for this session (and it should not be created) See also :meth:`basket_view` to view any cart. .. py:method:: cart_list(cart_key = None) List root nodes or children of a cart If a cart key is provided, the direct children (nodes and leafs) will be returned. Otherwise (without a key), the root nodes will be returned. :param cart_key: list direct children (nodes and leafs) of this parent node .. py:method:: cart_view(cart_key) View a cart itself See also :meth:`basket_view` to view the current basket. .. py:method:: order_add(*, cart_key, payment_provider = SENTINEL, billing_address_key = SENTINEL, customer_key = SENTINEL, state_ordered = SENTINEL, state_paid = SENTINEL, state_rts = SENTINEL, **kwargs) .. py:method:: order_update(*, order_key, payment_provider = SENTINEL, billing_address_key = SENTINEL, customer_key = SENTINEL, state_ordered = SENTINEL, state_paid = SENTINEL, state_rts = SENTINEL, **kwargs) .. py:method:: order_remove(*, order_key) .. py:method:: order_list(**kwargs) List the orders of the current user .. py:method:: order_view(order_key = 'SESSION') View an order :param order_key: Key of the order to view. Use "SESSION" as key to view the order of the current session .. py:method:: _get_order_view_result(order_skel) .. py:method:: discount_add(*, code = None, discount_key = None) parameter code xor discount_key: str | db.Key Sucht nach Rabatt mit dem code xor key, je nach Typ (Artikel/Warenkorb) suche ...ende parent_node oder erzeuge eine und setze dort die discount Relation. .. py:method:: discount_remove(*, discount_key) .. py:method:: shipping_list(cart_key) Lists available shipping options for a (sub)cart :param cart_key: Key of the parent cart :returns: list of :class:`ShippingSkel` `SkeletonInstance`s .. py:method:: _normalize_external_key(external_key, parameter_name, can_be_None = False) Convert urlsafe key to db.Key and raise an error on invalid in key.