shop.skeletons.cart

Attributes

Classes

TotalFactory

RelationalBoneShipping

A custom RelationalBone with conditionally compute logic for shipping

CartNodeSkel

CartItemSkel

Functions

add_discount(factory, total, skel, bone)

add_shipping(factory, total, skel, bone)

get_vat_for_node(skel, bone)

Module Contents

shop.skeletons.cart.logger
shop.skeletons.cart.Addition
class shop.skeletons.cart.TotalFactory(bone_node, bone_leaf, multiply_quantity=True, precision=None, use_cache=True, *, additions=())
Parameters:
  • bone_node (str | viur.shop.types.t.Callable[[viur.core.skeleton.SkeletonInstance], float | int])

  • bone_leaf (str | viur.shop.types.t.Callable[[viur.core.skeleton.SkeletonInstance], float | int])

  • multiply_quantity (bool)

  • precision (int | None)

  • use_cache (bool)

  • additions (list[Addition] | tuple[Addition, Ellipsis])

bone_node
bone_leaf
multiply_quantity = True
precision = None
use_cache = True
additions = ()
_get_children(parent_cart_key)
Parameters:

parent_cart_key (viur.core.db.Key)

Return type:

list[viur.core.skeleton.SkeletonInstance]

__call__(skel, bone)
Parameters:
  • skel (viur.shop.types.SkeletonInstance_T[CartNodeSkel])

  • bone (NumericBone)

shop.skeletons.cart.add_discount(factory, total, skel, bone)
Parameters:
  • factory (TotalFactory)

  • total (float)

  • skel (viur.core.skeleton.SkeletonInstance)

  • bone (BaseBone)

Return type:

float

shop.skeletons.cart.add_shipping(factory, total, skel, bone)
Parameters:
  • factory (TotalFactory)

  • total (float)

  • skel (viur.core.skeleton.SkeletonInstance)

  • bone (BaseBone)

Return type:

float

shop.skeletons.cart.get_vat_for_node(skel, bone)
Parameters:
Return type:

list[dict]

class shop.skeletons.cart.RelationalBoneShipping

Bases: RelationalBone

A custom RelationalBone with conditionally compute logic for shipping

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.

Parameters:
  • skel (viur.core.skeleton.SkeletonInstance)

  • name (str)

Return type:

bool

_is_valid_user_shipping(skel)

Ensure it’s still a valid shipping for the cart

Parameters:

skel (viur.core.skeleton.SkeletonInstance)

Return type:

bool

class shop.skeletons.cart.CartNodeSkel

Bases: viur.core.prototypes.tree.TreeSkel

kindName = '{{viur_shop_modulename}}_cart_node'
subSkels
is_root_node
total
total_raw
total_discount_price
vat
total_quantity
shipping_address
customer_comment
name
cart_type
shipping
shipping_status

Versand bei Warenkorb der einer Bestellung zugehört

discount
project_data
is_frozen
frozen_values
classmethod refresh_shipping_address(skel)

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.

Parameters:

skel (viur.core.skeleton.SkeletonInstance)

Return type:

viur.core.skeleton.SkeletonInstance

classmethod read(skel, *args, **kwargs)
Parameters:

skel (viur.core.skeleton.SkeletonInstance)

Return type:

viur.shop.types.t.Optional[viur.core.skeleton.SkeletonInstance]

class shop.skeletons.cart.CartItemSkel

Bases: viur.core.prototypes.tree.TreeSkel

kindName = '{{viur_shop_modulename}}_cart_leaf'
article
quantity
project_data
shop_name
shop_description
shop_price_retail
shop_availability
shop_listed
shop_image
shop_art_no_or_gtin
shop_vat_rate_category
shop_shipping_config
shop_is_weee
shop_is_low_price
property article_skel: viur.core.skeleton.SkeletonInstance
Return type:

viur.core.skeleton.SkeletonInstance

property article_skel_full: viur.shop.types.SkeletonInstance_T[shop.skeletons.article.ArticleAbstractSkel]
Return type:

viur.shop.types.SkeletonInstance_T[shop.skeletons.article.ArticleAbstractSkel]

classmethod get_article_cache()
Return type:

dict[viur.core.db.Key, viur.shop.types.SkeletonInstance_T[shop.skeletons.article.ArticleAbstractSkel]]

property parent_skel: viur.core.skeleton.SkeletonInstance
Return type:

viur.core.skeleton.SkeletonInstance

property price_: viur.shop.types.Price
Return type:

viur.shop.types.Price

price
shipping
is_frozen
frozen_values