shop.skeletons.cart =================== .. py:module:: shop.skeletons.cart Attributes ---------- .. autoapisummary:: shop.skeletons.cart.logger shop.skeletons.cart.Addition Classes ------- .. autoapisummary:: shop.skeletons.cart.TotalFactory shop.skeletons.cart.RelationalBoneShipping shop.skeletons.cart.CartNodeSkel shop.skeletons.cart.CartItemSkel Functions --------- .. autoapisummary:: shop.skeletons.cart.add_discount shop.skeletons.cart.add_shipping shop.skeletons.cart.get_vat_for_node shop.skeletons.cart.get_price_for_leaf shop.skeletons.cart.get_shipping_for_leaf Module Contents --------------- .. py:data:: logger .. py:data:: Addition .. py:class:: TotalFactory(bone_node, bone_leaf, multiply_quantity = True, precision = None, use_cache = True, *, additions = ()) .. py:attribute:: bone_node .. py:attribute:: bone_leaf .. py:attribute:: multiply_quantity :value: True .. py:attribute:: precision :value: None .. py:attribute:: use_cache :value: True .. py:attribute:: additions :value: () .. py:method:: _get_children(parent_cart_key) .. py:method:: __call__(skel, bone, bone_name) Compute the total of *bone_name* by aggregating the children. Frozen carts (``is_frozen``) return the snapshot stored in ``frozen_values`` at freeze time instead of recomputing: totals of an ordered cart must not change anymore when article prices, discounts or shippings change afterwards. (Frozen entries written before ``frozen_values`` existed fall back to live computation.) .. py:function:: add_discount(factory, total, skel, bone) .. py:function:: add_shipping(factory, total, skel, bone) .. py:function:: get_vat_for_node(skel, bone) Compute the VAT shares of a cart node from its children. Frozen carts (``is_frozen``) return the snapshot stored in ``frozen_values`` at freeze time instead of recomputing (see :meth:`TotalFactory.__call__`). .. py:function:: get_price_for_leaf(skel) Compute the price dict of a cart leaf. Frozen leafs (``is_frozen``) return the price snapshot stored in ``frozen_values`` at freeze time instead of recomputing: the price of an ordered item must not change anymore when the article prices or discounts change afterwards. (Frozen entries written before ``frozen_values`` existed fall back to live computation.) .. py:function:: get_shipping_for_leaf(skel) Compute the shipping dict of a cart leaf. Frozen leafs return the snapshot stored in ``frozen_values`` at freeze time (see :func:`get_price_for_leaf`). .. py:class:: RelationalBoneShipping Bases: :py:obj:`RelationalBone` A custom RelationalBone with conditionally compute logic for shipping .. py:method:: unserialize_compute(skel, name) This method implements a conditionally compute. Depending on the value of the 'shipping_status' bone, the cheapest shipping option will be calculated. Otherwise, the shipping method chosen by the user will be unserialized as usual. .. py:method:: _is_valid_user_shipping(skel) Ensure it's still a valid shipping for the cart .. py:class:: CartNodeSkel Bases: :py:obj:`viur.core.prototypes.tree.TreeSkel` .. py:attribute:: kindName :value: '{{viur_shop_modulename}}_cart_node' .. py:attribute:: subSkels .. py:attribute:: is_root_node .. py:attribute:: total .. py:attribute:: total_raw .. py:attribute:: total_discount_price .. py:attribute:: vat .. py:attribute:: total_quantity .. py:attribute:: shipping_address .. py:attribute:: customer_comment .. py:attribute:: name .. py:attribute:: cart_type .. py:attribute:: shipping Selected shipping for this cart node. Uses ``SetNull`` consistency: when the referenced shipping entry gets deleted, the relation is cleared instead of silently keeping a dangling reference with stale ``shipping_cost`` values in the totals. .. py:attribute:: shipping_status Versand bei Warenkorb der einer Bestellung zugehört .. py:attribute:: discount Discount applied to this cart node. Uses ``SetNull`` consistency: when the referenced discount gets deleted, the relation is cleared -- a dangling reference would still be applied with its cached refKey values by ``add_discount`` and crash the discount evaluation in the price calculation. .. py:attribute:: project_data .. py:attribute:: is_frozen .. py:attribute:: frozen_values .. py:method:: refresh_shipping_address(skel) :classmethod: Shorthand to refresh the shipping_address of an CartNodeSkel Due to race-condition and timing issues, the dest values are not always set correctly. This refresh fixes this. .. py:method:: read(skel, *args, **kwargs) :classmethod: .. py:class:: CartItemSkel Bases: :py:obj:`viur.core.prototypes.tree.TreeSkel` .. py:attribute:: kindName :value: '{{viur_shop_modulename}}_cart_leaf' .. py:attribute:: article .. py:attribute:: quantity .. py:attribute:: project_data .. py:attribute:: shop_name .. py:attribute:: shop_description .. py:attribute:: shop_price_retail .. py:attribute:: shop_price_recommended .. py:attribute:: shop_availability .. py:attribute:: shop_listed .. py:attribute:: shop_image .. py:attribute:: shop_art_no_or_gtin .. py:attribute:: shop_vat_rate_category .. py:attribute:: shop_shipping_config .. py:attribute:: shop_is_weee .. py:attribute:: shop_is_low_price .. py:property:: article_skel :type: viur.core.skeleton.SkeletonInstance .. py:property:: article_skel_full :type: viur.shop.types.SkeletonInstance_T[shop.skeletons.article.ArticleAbstractSkel] .. py:method:: get_article_cache() :classmethod: .. py:property:: parent_skel :type: viur.core.skeleton.SkeletonInstance | None Skeleton of the parent cart node of this entry. :return: The parent node skeleton or ``None`` if this entry has no ``parententry`` or the parent node does not exist anymore (orphaned entry). .. py:property:: price_ :type: viur.shop.types.Price .. py:attribute:: price .. py:attribute:: shipping .. py:attribute:: is_frozen .. py:attribute:: frozen_values