• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pricing.get_pricing_module函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中shoop.core.pricing.get_pricing_module函数的典型用法代码示例。如果您正苦于以下问题:Python get_pricing_module函数的具体用法?Python get_pricing_module怎么用?Python get_pricing_module使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_pricing_module函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_price_infos_are_discounted

def test_price_infos_are_discounted(rf):
    request = initialize_test(rf, True)

    price = request.shop.create_price

    product_one = create_product("Product_1", request.shop, default_price=150)
    product_two = create_product("Product_2", request.shop, default_price=250)

    spp = DiscountedProductPrice(product=product_one, shop=request.shop, price_value=100)
    spp.save()

    spp = DiscountedProductPrice(product=product_two, shop=request.shop, price_value=200)
    spp.save()

    product_ids = [product_one.pk, product_two.pk]

    dpm = get_pricing_module()
    pricing_context = dpm.get_context_from_request(request)
    price_infos = dpm.get_price_infos(pricing_context, product_ids)

    assert len(price_infos) == 2
    assert product_one.pk in price_infos
    assert product_two.pk in price_infos

    first_price_info = price_infos[product_one.pk]
    second_price_info = price_infos[product_two.pk]

    assert first_price_info.price == price(100)
    assert first_price_info.base_price == price(150)
    assert first_price_info.is_discounted

    assert second_price_info.price == price(200)
    assert second_price_info.base_price == price(250)
    assert second_price_info.is_discounted
开发者ID:taedori81,项目名称:shoop,代码行数:34,代码来源:test_discount_pricing.py


示例2: test_price_infos

def test_price_infos(rf):
    request, shop, group = initialize_test(rf, True)
    price = shop.create_price

    product_one = create_product("Product_1", shop, default_price=150)
    product_two = create_product("Product_2", shop, default_price=250)

    spp = SimpleProductPrice(product=product_one, shop=shop, group=group, price_value=100)
    spp.save()

    spp = SimpleProductPrice(product=product_two, shop=shop, group=group, price_value=200)
    spp.save()

    product_ids = [product_one.pk, product_two.pk]

    spm = get_pricing_module()
    assert isinstance(spm, SimplePricingModule)
    pricing_context = spm.get_context_from_request(request)
    price_infos = spm.get_price_infos(pricing_context, product_ids)

    assert len(price_infos) == 2
    assert product_one.pk in price_infos
    assert product_two.pk in price_infos

    assert price_infos[product_one.pk].price == price(100)
    assert price_infos[product_two.pk].price == price(200)

    assert price_infos[product_one.pk].base_price == price(100)
    assert price_infos[product_two.pk].base_price == price(200)
开发者ID:taedori81,项目名称:shoop,代码行数:29,代码来源:test_simple_pricing.py


示例3: handle_product_data

 def handle_product_data(self, request):
     product_id = request.GET["id"]
     shop_id = request.GET["shop_id"]
     customer_id = request.GET.get("customer_id")
     product = Product.objects.get(pk=product_id)
     shop = Shop.objects.get(pk=shop_id)
     ctx_request = RequestFactory().get("/")
     ctx_request.shop = shop
     ctx_request.customer = Contact.objects.filter(pk=customer_id).first()
     ctx_request.user = AnonymousUser()
     context = get_pricing_module().get_context_from_request(ctx_request)
     price_info = product.get_price_info(context, quantity=1)
     return {
         "id": product.id,
         "sku": product.sku,
         "name": product.name,
         "taxClass": {
             "id": product.tax_class.id,
             "name": force_text(product.tax_class),
         },
         "unitPrice": {
             "value": price_info.price.value,  # TODO: This is always zero?!
             "includesTax": price_info.price.includes_tax
         }
     }
开发者ID:hitchhooker,项目名称:shoop,代码行数:25,代码来源:create.py


示例4: get_price_info

def get_price_info(shop, customer, product, quantity):
    ctx_request = RequestFactory().get("/")
    ctx_request.shop = shop
    if customer:
        ctx_request.customer = customer
    ctx_request.user = AnonymousUser()
    context = get_pricing_module().get_context_from_request(ctx_request)
    return product.get_price_info(context, quantity=quantity)
开发者ID:sebad78,项目名称:shoop,代码行数:8,代码来源:create.py


示例5: get_price

 def get_price(self, context, quantity=1):
     """
     :type context: shoop.core.contexts.PriceTaxContext
     :rtype: shoop.core.pricing.Price
     """
     from shoop.core.pricing import get_pricing_module
     module = get_pricing_module()
     pricing_context = module.get_context(context)
     return module.get_price(pricing_context, product_id=self.pk, quantity=quantity)
开发者ID:jacobsenanaizabel,项目名称:shoop,代码行数:9,代码来源:products.py


示例6: get_price_info

    def get_price_info(self, context, quantity=1):
        """
        returns a `PriceInfo` object for product

        Returned `PriceInfo` object contains calculated `price` and `base_price`.
        The calculation of prices is handled in the current pricing module.

        :type context: shoop.core.contexts.PriceTaxContext
        :rtype: shoop.core.pricing.PriceInfo
        """
        from shoop.core.pricing import get_pricing_module
        module = get_pricing_module()
        pricing_context = module.get_context(context)
        return module.get_price_info(pricing_context, product=self, quantity=quantity)
开发者ID:portlyjent,项目名称:shoop,代码行数:14,代码来源:products.py


示例7: get_price_info

def get_price_info(shop, customer, product, quantity):
    """
    Get price info of given product for given context parameters.

    :type shop: shoop.core.models.Shop
    :type customer: shoop.core.models.Contact
    :type product: shoop.core.models.Product
    :type quantity: numbers.Number
    """
    pricing_mod = get_pricing_module()
    pricing_ctx = pricing_mod.get_context_from_data(
        shop=shop,
        customer=(customer or AnonymousContact()),
    )
    return pricing_mod.get_price_info(pricing_ctx, product, quantity=quantity)
开发者ID:RF-77,项目名称:shoop,代码行数:15,代码来源:create.py


示例8: test_pricing_module_is_active

def test_pricing_module_is_active():
    """
    Make sure that our custom pricing module is active.
    """
    shop = Shop(currency='USD', prices_include_tax=False)
    customer = AnonymousContact()
    product = Product(sku='6.0745')

    pricing_mod = get_pricing_module()
    pricing_ctx = pricing_mod.get_context_from_data(shop, customer)

    pi = product.get_price_info(pricing_ctx, quantity=2)

    price = shop.create_price
    assert pi.price == price('12.149')
    assert pi.base_price == price('48.596')
    assert pi.quantity == 2
    assert pi.discounted_unit_price == price('6.0745')
    assert pi.base_unit_price == price('24.298')
    assert pi.discount_rate == Decimal('0.75')
开发者ID:00WhengWheng,项目名称:shuup,代码行数:20,代码来源:test_price_display.py


示例9: test_module_is_active

def test_module_is_active():  # this test is because we want to make sure `SimplePricing` is active
    module = get_pricing_module()
    assert isinstance(module, DefaultPricingModule)
开发者ID:portlyjent,项目名称:shoop,代码行数:3,代码来源:test_default_pricing.py


示例10: test_module_is_active

def test_module_is_active():
    """
    Check that DiscountPricingModule is active.
    """
    module = get_pricing_module()
    assert isinstance(module, DiscountPricingModule)
开发者ID:taedori81,项目名称:shoop,代码行数:6,代码来源:test_discount_pricing.py


示例11: test_module_is_active

def test_module_is_active():
    """
    Check that SimplePricingModule is active.
    """
    module = get_pricing_module()
    assert isinstance(module, SimplePricingModule)
开发者ID:taedori81,项目名称:shoop,代码行数:6,代码来源:test_simple_pricing.py


示例12: test_module_is_active

def test_module_is_active():
    """
    Check that CustomerGroupPricingModule is active.
    """
    module = get_pricing_module()
    assert isinstance(module, CustomerGroupPricingModule)
开发者ID:00WhengWheng,项目名称:shuup,代码行数:6,代码来源:test_customer_group_pricing.py


示例13: _get_pricing_context

def _get_pricing_context(shop, customer=None):
    return get_pricing_module().get_context_from_data(
        shop=shop,
        customer=(customer or AnonymousContact()),
    )
开发者ID:00WhengWheng,项目名称:shuup,代码行数:5,代码来源:factories.py


示例14: from_request

 def from_request(cls, request):
     return cls(
         pricing_context=get_pricing_module().get_context_from_request(request),
         taxing_context=get_tax_module().get_context_from_request(request),
     )
开发者ID:Jeewes,项目名称:shoop,代码行数:5,代码来源:contexts.py


示例15: get_price_info

def get_price_info(shop, customer, product, quantity):
    ctx_request = RequestFactory().get("/")
    ctx_request.shop = shop
    ctx_request.customer = (customer or AnonymousContact())
    context = get_pricing_module().get_context_from_request(ctx_request)
    return product.get_price_info(context, quantity=quantity)
开发者ID:LuanaF,项目名称:shoop,代码行数:6,代码来源:create.py


示例16: get_base_price

    def get_base_price(self):
        from shoop.core.pricing import get_pricing_module

        module = get_pricing_module()
        return module.get_base_price(product_id=self.pk)
开发者ID:noyonthe1,项目名称:shoop,代码行数:5,代码来源:products.py



注:本文中的shoop.core.pricing.get_pricing_module函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python basket.get_basket函数代码示例发布时间:2022-05-27
下一篇:
Python order_creator.OrderCreator类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap