Exemple #1
0
from decimal import Decimal as D
from oscar.apps.shipping.methods import FixedPrice, NoShippingRequired
from oscar.apps.shipping.repository import Repository as CoreRepository

# Dummy shipping methods
method1 = FixedPrice(D('12.00'))
method1.code = 'method1'
method1.name = 'Ship by van'

method2 = FixedPrice(D('24.00'))
method2.code = 'method2'
method2.name = 'Ship by pigeon'
method2.description = 'Here is a description of this shipping method'


class Repository(CoreRepository):
    methods = {
        method1.code: method1,
        method2.code: method2,
    }

    def get_shipping_methods(self, user, basket, shipping_addr=None, **kwargs):
        methods = self.methods.values()
        return self.prime_methods(basket, methods)

    def find_by_code(self, code, basket):
        if code == NoShippingRequired.code:
            method = NoShippingRequired()
        else:
            method = self.methods.get(code, None)
        return self.prime_method(basket, method)
Exemple #2
0
from decimal import Decimal as D

from oscar.apps.shipping.methods import FixedPrice, NoShippingRequired
from oscar.apps.shipping.repository import Repository as CoreRepository

# Dummy shipping methods
method1 = FixedPrice(D('10.00'))
method1.code = 'method1'
method1.description = 'Ship by van'

method2 = FixedPrice(D('20.00'))
method2.code = 'method2'
method2.description = 'Ship by boat'


class Repository(CoreRepository):
    methods = (
        method1,
        method2,
    )
from decimal import Decimal as D

from oscar.apps.shipping.methods import FixedPrice, NoShippingRequired
from oscar.apps.shipping.repository import Repository as CoreRepository

# Dummy shipping methods
method1 = FixedPrice(charge_excl_tax=D('10.00'), charge_incl_tax=D('10.00'))
method1.code = 'method1'
method1.description = 'Ship by van'

method2 = FixedPrice(charge_excl_tax=D('20.00'), charge_incl_tax=D('20.00'))
method2.code = 'method2'
method2.description = 'Ship by boat'


class Repository(CoreRepository):
    methods = (method1, method2,)
from decimal import Decimal as D
from oscar.apps.shipping.methods import FixedPrice, NoShippingRequired
from oscar.apps.shipping.repository import Repository as CoreRepository

# Dummy shipping methods
method1 = FixedPrice(D("10.00"))
method1.code = "method1"
method1.description = "Ship by van"

method2 = FixedPrice(D("20.00"))
method2.code = "method2"
method2.description = "Ship by boat"

METHODS = (method1, method2)


class Repository(CoreRepository):
    def get_shipping_methods(self, user, basket, shipping_addr=None, **kwargs):
        return self.prime_methods(basket, METHODS)

    def find_by_code(self, code, basket):
        if code == NoShippingRequired.code:
            method = NoShippingRequired()
        else:
            method = None
            for method_ in METHODS:
                if method_.code == code:
                    method = method_
            if method is None:
                raise ValueError("No shipping method found with code '%s'" % code)
        return self.prime_method(basket, method)
from decimal import Decimal as D

from oscar.apps.shipping.methods import FixedPrice
from oscar.apps.shipping.repository import Repository as CoreRepository

# Dummy shipping methods
method1 = FixedPrice(charge_excl_tax=D("10.00"), charge_incl_tax=D("10.00"))
method1.code = "method1"
method1.description = "Ship by van"

method2 = FixedPrice(charge_excl_tax=D("20.00"), charge_incl_tax=D("20.00"))
method2.code = "method2"
method2.description = "Ship by boat"


class Repository(CoreRepository):
    methods = (
        method1,
        method2,
    )