SalahAdDin SalahAdDin - 3 months ago 26
Python Question

User cash on delivery in django-oscar

I'm working in e-shop project using

django-oscar
and i trying to add COD support. I'm using
django-oscar-cash-on-delivery
.

I did the steps, you can see my configuration:

THIRD_PARTY_APPS = [
'jet.dashboard',
'jet',

'axes',
'cashondelivery',
'django_extensions',
'oscarapi',
'paypal',
'payu',
'rest_framework',
'robots',
'widget_tweaks',
'webpack_loader',
]


And created an app called
apps
and loaded properly:

INSTALLED_APPS = THIRD_PARTY_APPS + PROJECT_APPS + [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.flatpages',
] + get_core_apps(
[
'apps.shipping'
]
)


In
apps
folder i created an
apps.py
file with this code inside:

from oscar.app import Shop

# from apps.checkout.app import application as checkout_app
from cashondelivery.app import application as checkout_app


class ApplicationShop(Shop):
checkout_app = checkout_app


application = ApplicationShop()


But i can't understand why Oscar doesn't show me the checkout template with cash on delivery method.

This is my structure folder:
enter image description here

Can anyone help me with this?

Answer

There are two ways for integrate cash on delivery in django-oscar project:

  1. Override checkout application:
    In this case is necessary override checkout templates because by default Oscar don't or can't get the cashondelivery checkout templates, at least payment_details. So, first you need override these template file and after create an app and inside it add a app.py file where you override the checkout application as cashondelivery documentation says.

    enter image description here

  2. Create a custom view and checkout app:
    You can see in django-oscar-paypal integration package a sandbox example for integrate paypal with Oscar. You can see in this package that they use a checkout app for replace the defaul checkout app; inside this app they override view.py file and app.view file; override templates and override app.py file.

    So, we can do the same for django-oscar-cash-on-delivery, so:
    a. Create a new application called checkout inside the apps application if you want, or some like you. This application only will contain the views and application file.enter image description here

    b. In views file we'll put the cash-on-delivery views file, now it is in sanbox folder.

    c. In app file inside checkout we declarate the checkout application:

from oscar.apps.checkout import app

from .views import PaymentDetailsView

class CheckoutApplication(app.CheckoutApplication): payment_details_view = PaymentDetailsView

application = CheckoutApplication()

d. Finally, we declarate our checkout app as default checkout app as documentation says.
e. We have ensure that the application override default check out application, in settings:

INSTALLED_APPS = + get_core_apps(
    [
        'apps.checkout',
        'apps.shipping'
    ]
)

You can now pay with cash on delivery method in your Oscar project.
We recommend use the second way because enable you use more than one method for payment.