Django-Oscar - Shipping - Part 8

In the previous post we have created methods.py and repository.py in our forked shipping app so we can customize them.
We can open Django-Oscar methods.py and repository.py files to understand how the shipping logic is implemented.

 

mysite/myShipping/shipping

django-oscar-master/src/oscar/apps/shipping

 




Adding alternative shipping methods

 

from decimal import Decimal as D
from oscar.apps.shipping import methods

class Standard(methods.FixedPrice):
    code = 'standard'
    name = 'Standard Shipping'
    charge_excl_tax = D('5.00')
    charge_incl_tax = D('5.00')

class Express(methods.FixedPrice):
    code = 'express'
    name = 'Express Shipping'
    charge_excl_tax = D('10.00')
    charge_incl_tax = D('10.00')

Defining Standard and Express shipping methods(others can be created for custom solutions).

 

from oscar.apps.shipping.repository import Repository
from .methods import *

class Repository(Repository):
    methods = (Standard(), Express(),)

Inherit Repository class into Repository and add the newly created shipping options.