當前位置: 首頁>>代碼示例>>Python>>正文


Python methods.FixedPrice類代碼示例

本文整理匯總了Python中oscar.apps.shipping.methods.FixedPrice的典型用法代碼示例。如果您正苦於以下問題:Python FixedPrice類的具體用法?Python FixedPrice怎麽用?Python FixedPrice使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FixedPrice類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_different_values

 def test_different_values(self):
     shipping_values = ['1.00', '5.00', '10.00', '12.00']
     for value in shipping_values:
         basket = Basket()
         method = FixedPrice(D(value))
         method.set_basket(basket)
         self.assertEquals(D(value), method.basket_charge_excl_tax())
開發者ID:AndreaCrotti,項目名稱:django-oscar,代碼行數:7,代碼來源:shipping_tests.py

示例2: get_shipping_method

    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
開發者ID:SalahAdDin,項目名稱:django-oscar-paypal,代碼行數:29,代碼來源:views.py

示例3: get_shipping_method

 def get_shipping_method(self, basket=None):
     """
     Return the shipping method used
     """
     charge = D(self.txn.value('PAYMENTREQUEST_0_SHIPPINGAMT'))
     method = FixedPrice(charge)
     basket = basket if basket else self.request.basket
     method.set_basket(basket)
     method.name = self.txn.value('SHIPPINGOPTIONNAME')
     return method
開發者ID:ComSource,項目名稱:django-oscar-paypal,代碼行數:10,代碼來源:views.py

示例4: get_shipping_method

 def get_shipping_method(self, basket=None):
     """
     Return the shipping method used
     """
     charge = D(self.txn.value('PAYMENTREQUEST_0_SHIPPINGAMT'))
     method = FixedPrice(charge)
     basket = basket if basket else self.request.basket
     method.set_basket(basket)
     name = self.txn.value('SHIPPINGOPTIONNAME')
     if not name:
         # Look to see if there is a method in the session
         session_method = self.checkout_session.shipping_method(basket)
         if session_method:
             method.name = session_method.name
     else:
         method.name = name
     return method
開發者ID:vinnyrose,項目名稱:django-oscar-paypal,代碼行數:17,代碼來源:views.py

示例5: get_shipping_method

    def get_shipping_method(self, basket=None, shipping_address=None, **kwargs):
        """
        Return the shipping method used
        """

        # 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
        method = FixedPrice(charge_excl_tax, charge_incl_tax)
        method.set_basket(basket)
        name = self.txn.value('SHIPPINGOPTIONNAME')
        if not name:
            # Look to see if there is a method in the session
            session_method = super(SuccessResponseView, self).get_shipping_method(basket, shipping_address)
            if session_method:
                method.name = session_method.name
        else:
            method.name = name
        return method
開發者ID:kapt,項目名稱:django-oscar-paypal,代碼行數:20,代碼來源:views.py

示例6: get_shipping_method

    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
        method = FixedPrice(charge_excl_tax, charge_incl_tax)
        method.set_basket(basket)
        name = self.txn.value('SHIPPINGOPTIONNAME')
        if not name:
            # Look to see if there is a method in the session
            session_method = self.checkout_session.shipping_method_code(basket)
            if session_method:
                method.name = session_method #.name
        else:
            method.name = name
        return method
開發者ID:nka11,項目名稱:django-oscar-paypal,代碼行數:22,代碼來源:views.py

示例7: FixedPrice

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)
開發者ID:ArtS,項目名稱:django-oscar,代碼行數:31,代碼來源:repository.py

示例8: test_update_address_book

    def test_update_address_book(self):
        basket = factories.create_basket(empty=True)
        user = factories.UserFactory()
        add_product(basket, D('12.00'))
        shipping_method = FixedPrice(D('5.00'), D('5.00'))

        billing_address = factories.BillingAddressFactory(line1='1 Boardwalk Place',
                                                          line2='Trafalgar Way',
                                                          line3='Tower Hamlets',
                                                          line4='London')
        shipping_address = factories.ShippingAddressFactory(line1='Knightsbridge',
                                                            line2='159',
                                                            line4='London')
        shipping_charge = shipping_method.calculate(basket)
        order_total = OrderTotalCalculator().calculate(basket, shipping_charge)

        order_submission_data = {'user': user,
                                 'order_number': '12345',
                                 'basket': basket,
                                 'shipping_address': shipping_address,
                                 'shipping_method': shipping_method,
                                 'shipping_charge': shipping_charge,
                                 'billing_address': billing_address,
                                 'order_total': order_total}
        OrderPlacementMixin().place_order(**order_submission_data)

        self.assertEqual(user.addresses.filter(hash=billing_address.generate_hash()).count(), 1)
        self.assertEqual(user.addresses.filter(hash=shipping_address.generate_hash()).count(), 1)

        user_billing_address = user.addresses.get(hash=billing_address.generate_hash())
        user_shipping_address = user.addresses.get(hash=shipping_address.generate_hash())
        self.assertEqual(user_billing_address.num_orders_as_billing_address, 1)
        self.assertEqual(user_shipping_address.num_orders_as_shipping_address, 1)

        order_submission_data['order_number'] = '12346'

        OrderPlacementMixin().place_order(**order_submission_data)

        user_billing_address = user.addresses.get(hash=billing_address.generate_hash())
        user_shipping_address = user.addresses.get(hash=shipping_address.generate_hash())
        self.assertEqual(user_billing_address.num_orders_as_billing_address, 2)
        self.assertEqual(user_shipping_address.num_orders_as_shipping_address, 2)

        order_submission_data.pop('billing_address', None)
        order_submission_data['order_number'] = '123457'
        OrderPlacementMixin().place_order(**order_submission_data)

        user_billing_address = user.addresses.get(hash=billing_address.generate_hash())
        user_shipping_address = user.addresses.get(hash=shipping_address.generate_hash())
        self.assertEqual(user_billing_address.num_orders_as_billing_address, 2)
        self.assertEqual(user_shipping_address.num_orders_as_shipping_address, 3)

        shipping_address.line2 = '160'
        order_submission_data['billing_address'] = billing_address
        order_submission_data['order_number'] = '123458'
        OrderPlacementMixin().place_order(**order_submission_data)

        user_billing_address = user.addresses.get(hash=billing_address.generate_hash())
        user_shipping_address = user.addresses.get(hash=shipping_address.generate_hash())
        self.assertEqual(user_billing_address.num_orders_as_billing_address, 3)
        self.assertEqual(user_shipping_address.num_orders_as_shipping_address, 1)
開發者ID:liip-forks,項目名稱:django-oscar,代碼行數:61,代碼來源:test_mixins.py

示例9: test_different_values

 def test_different_values(self, value):
     method = FixedPrice(D(value))
     basket = Basket()
     method.set_basket(basket)
     self.assertEquals(D(value), method.basket_charge_excl_tax())
開發者ID:bakanov,項目名稱:django-oscar,代碼行數:5,代碼來源:shipping_tests.py

示例10: test_fixed_price_shipping_assumes_no_tax

 def test_fixed_price_shipping_assumes_no_tax(self):
     method = FixedPrice(D('10.00'))
     basket = Basket()
     method.set_basket(basket)
     self.assertEquals(D('10.00'), method.basket_charge_excl_tax())
開發者ID:bakanov,項目名稱:django-oscar,代碼行數:5,代碼來源:shipping_tests.py

示例11: test_fixed_price_shipping_charges_for_empty_basket

 def test_fixed_price_shipping_charges_for_empty_basket(self):
     method = FixedPrice(D('10.00'), D('10.00'))
     basket = Basket()
     method.set_basket(basket)
     self.assertEquals(D('10.00'), method.basket_charge_incl_tax())
     self.assertEquals(D('10.00'), method.basket_charge_excl_tax())
開發者ID:bakanov,項目名稱:django-oscar,代碼行數:6,代碼來源:shipping_tests.py

示例12: FixedPrice

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)
開發者ID:jbingham94,項目名稱:django-oscar-accounts,代碼行數:31,代碼來源:repository.py

示例13: FixedPrice

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,)
開發者ID:django-oscar,項目名稱:django-oscar-accounts,代碼行數:17,代碼來源:repository.py


注:本文中的oscar.apps.shipping.methods.FixedPrice類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。