本文整理匯總了Python中oscar.apps.shipping.methods.FixedPrice.description方法的典型用法代碼示例。如果您正苦於以下問題:Python FixedPrice.description方法的具體用法?Python FixedPrice.description怎麽用?Python FixedPrice.description使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類oscar.apps.shipping.methods.FixedPrice
的用法示例。
在下文中一共展示了FixedPrice.description方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: FixedPrice
# 需要導入模塊: from oscar.apps.shipping.methods import FixedPrice [as 別名]
# 或者: from oscar.apps.shipping.methods.FixedPrice import description [as 別名]
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)
示例2: FixedPrice
# 需要導入模塊: from oscar.apps.shipping.methods import FixedPrice [as 別名]
# 或者: from oscar.apps.shipping.methods.FixedPrice import description [as 別名]
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)
示例3: FixedPrice
# 需要導入模塊: from oscar.apps.shipping.methods import FixedPrice [as 別名]
# 或者: from oscar.apps.shipping.methods.FixedPrice import description [as 別名]
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,)