Shop(contact_model, order_model, discount_model, default_currency=None, **kwargs)
Plata’s view and shop processing logic is contained inside this class.
Shop needs a few model classes with relations between them:
- Contact model linking to Django’s auth.user
- Order model with order items and an applied discount model
- Discount model
- Default currency for the shop (if you do not override default_currency in your own Shop subclass)
shop_instance = Shop(Contact, Order, Discount) urlpatterns = [ url(r'^shop/', include(shop_instance.urls)), ]
The base template used in all default checkout templates
Handles the order confirmation and payment module selection checkout step
Hands off processing to the selected payment module if confirmation was successful.
Return the contact object bound to the current user if the user is authenticated. Returns
Noneif no contact exists.
Return the default currency for instantiating new orders
Override this with your own implementation if you have a multi-currency shop with auto-detection of currencies.
get_context(request, context, **kwargs)
Helper method returning a context dict. Override this if you need additional context variables.
Import and return all payment modules defined in
If request is given only applicable modules are loaded.
Instantiate the order instance for the current session. Optionally creates a new order instance if
Noneif unable to find an offer.
Forcibly create a new order and redirect user either to the frontpage or to the URL passed as
Handles order successes for invoice payments where payment is still pending.
Return if the shop should show prices including tax
This returns the PLATA_PRICE_INCLUDES_TAX settings by default and is meant to be overridden by subclassing the Shop.
redirect(url_name, *args, **kwargs)
Hook for customizing the redirect function when used as application content
render(request, template, context)
Helper which just passes everything on to
Helper method encapsulating the process of setting the current order in the session. Pass
Noneif you want to remove any defined order from the session.
Property offering access to the Shop-managed URL patterns
cart_not_empty(order, shop, request, **kwargs)
Redirect to cart if later in checkout process and cart empty
Calls all passed checkout process decorators in turn:
All checkout process decorators are called with the order, the shop instance and the request as keyword arguments. In the future, additional keywords might be added, your decorators should accept
**kwargsas well for future compatibility.
order_already_confirmed(order, shop, request, **kwargs)
Redirect to confirmation or already paid view if the order is already confirmed
order_cart_validates(order, shop, request, **kwargs)
Redirect to cart if stock is insufficient and display an error message
order_cart_warnings(order, shop, request, **kwargs)
Show warnings in cart, but don’t redirect (meant as a replacement for
order_cart_validates, but usable on the cart view itself)