Understanding Checkout flow in Django Oscar.

Reading Time : ~ .

If you are new to Django Oscar, then you can read these blog posts to understand how to create your own e-commerce shop using django-oscar and how to customize django oscar models, views and url's.

Django Oscar Checkout Flow covers the most use-cases. You can skip steps you don't need, or just write your own checkout views.

In Oscar the checkout process is laid out like this:

Step 1 - Gateway

    * Logged in users will be automatically redirected to the next step.

    * Anonymous users are prompted to sign in, or to proceed as a guest.

    NOTE: Even as a guest user, oscar still collects their email address.

Step 2 - Collect shipping information

    * Logged in users are offered the choice of either to enter or choose a shipping address from the existing user addresses.

    * Anonymous users are asked to enter shipping address details.

    Info - When the user enters a shipping address, then this address will be saved in the session and later saved as ShippingAddress model instance when the order is successfully submitted.

Step 3 - Choose a shipping method

    * In this step the user is allowed to choose a shipping method. Oscar by default provides only Free shipping method. If you want to add your custom shipping methods, you can add them here in this file in app named shipping by customising 'Repository' class.

    * By default, this view will load all the available shipping methods using the shipping Repository.

    * If there is only one shipping method available then it is automatically seleted and the user is redirected onto the next step. Otherwise, a page is rendered where the user can choose from the available methods.

    NOTE: Before doing all these, this view will check whether shipping is required for the basket or not. If not required, then it directly selects NoShippingRequired method and redirects the user to next step.

Step 4 - Select a payment method and collect payment details.

    * This view should be customised to collect any information like choosing the method of payment plus any allocations if payment is to be split across multiple sources.

    * The oscar default behaviour will directly redirect to next step.

Step 5 - Payment details, Preview an order and confirm.

    * This view should be subclassed and customsied by all django oscar projects because no payment is taken by default.

    * If any sensitive details are required (Ex: bankcard details) are collected in this page. Along with these details billing address details can also be collected here, if required(get_default_billing_address() method can be used to prepopulate the form)

    * If the forms are in-valid then payment-details template is re-rendered with the relevant error messages.

    * Otherwise, if the form data is valid, then the preview template can be rendered with the payment-details forms re-rendered within a hidden div so they can be re-submitted when the 'place order' button is clicked.

    Note: By this process, we avoid writing sensitive data to disk.

Step 6 - Place an Order.

    * This view is called when the user clicks 'place order' button in preview page. If any forms are submitted in payment details page, then you should override handle_place_order_submission() method to re-validate and then build the submission dict using build_submission() method and call submit() method passing this dict.

    * The submit method generates an order number, freeze the basket so it cannot be modified any more and attempts to take the payment for the order by calling handle_payment() method.

    * The handle_payment() method should be overridden for handling payment and recording the payment sources (using the add_payment_source method) and payment events (using add_payment_event) so they can be linked to the order.

    * If payment is successful, then it places the order.

Finally, summary of the order with all details to shown to user using thank-you view and template.

    By Posted On
SENIOR DEVELOPER at MICROPYRAMID

Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Django - migrating from function based views to class based views Anjaneyulu Batta

The single most significant advantage in Django class-based views is inheritance. On a large project it's likely that we will have lots of similar views. ...

Continue Reading...
Django-REST User Level Permissions and Object Level Permissions Anjaneyulu Batta

Django-REST User Level Permissions and Object Level Permissions. User Level Permissions and Object level Permissions allow to serve customers based on their access levels or ...

Continue Reading...
How to Document API Requests using Django Rest Swagger Swetha Naretla

Django Rest Swagger is used to Document your API for eg., Listing all Your project Rest API's in the browser with brief description about the ...

Continue Reading...

Subscribe To our news letter

Subscribe to our news letter to receive latest blog posts into your inbox. Please fill your email address in the below form.
*We don't provide your email contact details to any third parties