shop.services.hooks¶
Customization / hook service
Register own implementations (Customization) to influence
a specific behavior (Hook) of the viur-shop.
Unlike events, which are just a trigger, hooks can (and usually should) modify objects and return something.
Attributes¶
Classes¶
The hook'able events / actions. |
|
Abstract base class for own implementations. |
|
Note: Methods should be called only with positional arguments. Or keyword-only if really necessary. |
Module Contents¶
- shop.services.hooks.logger¶
- class shop.services.hooks.Hook¶
Bases:
enum.IntEnumThe hook’able events / actions.
Initialize self. See help(type(self)) for accurate signature.
- ORDER_ASSIGN_UID¶
Hook that assign a order id on a OrderSkel type: (order_skel: SkeletonInstance_T[OrderSkel]) -> SkeletonInstance_T[OrderSkel]
- CURRENT_COUNTRY¶
Provide the country of a global site context type: (context: t.Literal[“cart”, “article”, “vat_rate”]) -> str
- ORDER_ADD_ADDITION¶
Do some additional modifications on the OrderSkel on order_add action. Called in
viur.shop.modules.order.Order.order_add()before saving withSkeleton.write(). type: (order_skel: SkeletonInstance_T[OrderSkel]) -> SkeletonInstance_T[OrderSkel]
- ORDER_UPDATE_ADDITION¶
Do some additional modifications on the OrderSkel on order_update action. Called in
viur.shop.modules.order.Order.order_update()before saving withSkeleton.write(). type: (order_skel: SkeletonInstance_T[OrderSkel]) -> SkeletonInstance_T[OrderSkel]
- ORDER_CHECKOUT_START_ADDITION¶
Do some additional modifications on the OrderSkel on checkout_start action. Called in
viur.shop.modules.order.Order.checkout_start()before saving withSkeleton.write(). type: (order_skel: SkeletonInstance_T[OrderSkel]) -> SkeletonInstance_T[OrderSkel]
- PAYMENT_RETURN_HANDLER_SUCCESS¶
The action that is executed after the customer has returned from the payment provider and the payment has been successful. This can be, for example, a rendered template or a redirect to another page. type: (order_skel: SkeletonInstance_T[OrderSkel], payment_data: t.Any) -> t.Any
- PAYMENT_RETURN_HANDLER_ERROR¶
The action that is executed after the customer has returned from the payment provider and the payment has failed. This can be, for example, a rendered template or a redirect to another page. type: (order_skel: SkeletonInstance_T[OrderSkel], payment_data: t.Any) -> t.Any
- class shop.services.hooks.Customization¶
Bases:
abc.ABCAbstract base class for own implementations.
- abstract __call__(*args, **kwargs)¶
The main logic of this implementation
- Return type:
Any
- __repr__()¶
- Return type:
str
- class shop.services.hooks.HookService¶
Note: Methods should be called only with positional arguments. Or keyword-only if really necessary.
- customizations: Final[list[Customization]] = []¶
- register(customization)¶
Register a customization with this service
Can be used as class decorator too
@HOOK_SERVICE.register class MyImplementation(Customization): kind = Hook.ORDER_ASSIGN_UID def __call__(self, *args, **kwargs) -> t.Any: ...
- Parameters:
customization (Customization | Type[Customization])
- Return type:
- unregister(customization)¶
- Parameters:
customization (Customization)
- shop.services.hooks.HOOK_SERVICE¶