from decimal import Decimal as from oscar apps shipping import reposit

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from decimal import Decimal as D
from oscar.apps.shipping import repository, methods
# We create subclasses so we can give them different codes and names
class Standard(methods.Free):
code = 'standard'
name = "Standard shipping"
class Express(methods.Free):
code = 'express'
name = "Express shipping"
class Repository(repository.Repository):
methods = [Standard(), Express()]
def get_shipping_methods(self, user, basket, shipping_addr=None, **kwargs):
return self.prime_methods(basket, self.methods)
def find_by_code(self, code, basket):
for method in self.methods:
if code == method.code:
return self.prime_method(basket, method)