Пример #1
0
 def __call__(self, context, item, quantity=1):
     options = PriceDisplayOptions.from_context(context)
     if options.hide_prices:
         return ""
     request = context.get('request')
     orig_priceful = _get_priceful(request, item, quantity)
     if not orig_priceful:
         return ""
     priceful = convert_taxness(
         request, item, orig_priceful, options.include_taxes)
     price_value = getattr(priceful, self.property_name)
     return money(price_value)
Пример #2
0
def render_price_property(request, item, priceful, property_name='price'):
    """
    Render price property of a Priceful object.

    :type request: django.http.HttpRequest
    :type item: shoop.core.taxing.TaxableItem
    :type priceful: shoop.core.pricing.Priceful
    :type propert_name: str
    :rtype: str
    """
    options = PriceDisplayOptions.from_context({'request': request})
    if options.hide_prices:
        return ""
    new_priceful = convert_taxness(
        request, item, priceful, options.include_taxes)
    price_value = getattr(new_priceful, property_name)
    return money(price_value)
Пример #3
0
 def __call__(self, context, source):
     """
     :type source: shoop.core.order_creator.OrderSource|
                   shoop.core.models.Order
     """
     options = PriceDisplayOptions.from_context(context)
     if options.hide_prices:
         return ""
     try:
         if options.include_taxes is None:
             total = source.total_price
         elif options.include_taxes:
             total = source.taxful_total_price
         else:
             total = source.taxless_total_price
     except TypeError:
         total = source.total_price
     return money(total)
Пример #4
0
    def __call__(self, context, product, quantity=1):
        """
        :type product: shoop.core.models.Product
        """
        options = PriceDisplayOptions.from_context(context)
        if options.hide_prices:
            return ("", "")
        request = context.get('request')
        priced_children = product.get_priced_children(request, quantity)
        priced_products = priced_children if priced_children else [
            (product, _get_priceful(request, product, quantity))]

        def get_formatted_price(priced_product):
            (prod, price_info) = priced_product
            if not price_info:
                return ""
            pf = convert_taxness(
                request, prod, price_info, options.include_taxes)
            return money(pf.price)

        min_max = (priced_products[0], priced_products[-1])
        return tuple(get_formatted_price(x) for x in min_max)