本文整理匯總了Python中oscar.apps.shipping.methods.FixedPrice.code方法的典型用法代碼示例。如果您正苦於以下問題:Python FixedPrice.code方法的具體用法?Python FixedPrice.code怎麽用?Python FixedPrice.code使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類oscar.apps.shipping.methods.FixedPrice
的用法示例。
在下文中一共展示了FixedPrice.code方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_shipping_method
# 需要導入模塊: from oscar.apps.shipping.methods import FixedPrice [as 別名]
# 或者: from oscar.apps.shipping.methods.FixedPrice import code [as 別名]
def get_shipping_method(self, basket, shipping_address=None, **kwargs):
"""
Return the shipping method used
"""
if not basket.is_shipping_required():
return NoShippingRequired()
# Instantiate a new FixedPrice shipping method instance
charge_incl_tax = D(self.txn.value('PAYMENTREQUEST_0_SHIPPINGAMT'))
# Assume no tax for now
charge_excl_tax = charge_incl_tax
name = self.txn.value('SHIPPINGOPTIONNAME')
session_method = super(SuccessResponseView, self).get_shipping_method(
basket, shipping_address, **kwargs)
if not session_method or (name and name != session_method.name):
if name:
method = self._get_shipping_method_by_name(name, basket, shipping_address)
else:
method = None
if not method:
method = FixedPrice(charge_excl_tax, charge_incl_tax)
if session_method:
method.name = session_method.name
method.code = session_method.code
else:
method = session_method
return method
示例2: FixedPrice
# 需要導入模塊: from oscar.apps.shipping.methods import FixedPrice [as 別名]
# 或者: from oscar.apps.shipping.methods.FixedPrice import code [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 code [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)