Ejemplo n.º 1
0
 def items(self):
     context = aq_inner(self.context)
     properties = getToolByName(context, "portal_properties")
     pcp = IPortalCartProperties(properties)
     product = IProduct(context)
     res = dict(
         uid=product.uid,
         html_quantity=product.html_quantity,
         price_with_currency=pcp.price_with_currency(product.price),
     )
     return res
Ejemplo n.º 2
0
 def products(self):
     context = aq_inner(self.context)
     cart = IPortal(context).cart
     if cart is not None:
         products = ICart(cart).products
         if products:
             properties = getToolByName(context, 'portal_properties')
             pcp = IPortalCartProperties(properties)
             res = []
             for product in products:
                 cproduct = ICartProduct(product)
                 item = dict(
                     uid=product.uid,
                     title=product.title,
                     quantity=product.quantity,
                     url=cproduct.product.url,
                     price_with_currency=pcp.price_with_currency(cproduct.price),
                     html_quantity=cproduct.html_quantity,
                     subtotal_with_currency=pcp.price_with_currency(cproduct.subtotal),
                 )
                 res.append(item)
             return res
Ejemplo n.º 3
0
 def products(self):
     context = aq_inner(self.context)
     cart = IPortal(context).cart
     if cart is not None:
         products = ICart(cart).products
         if products:
             properties = getToolByName(context, 'portal_properties')
             pcp = IPortalCartProperties(properties)
             res = []
             for product in products:
                 cproduct = ICartProduct(product)
                 item = dict(
                     uid=product.uid,
                     title=product.title,
                     quantity=product.quantity,
                     url=cproduct.product.url,
                     price_with_currency=pcp.price_with_currency(
                         cproduct.price),
                     html_quantity=cproduct.html_quantity,
                     subtotal_with_currency=pcp.price_with_currency(
                         cproduct.subtotal),
                 )
                 res.append(item)
             return res
Ejemplo n.º 4
0
 def decimal_price(self, price):
     currency = IPortalCartProperties(self.properties).currency
     places = getUtility(IDecimalPlaces)(currency)
     decimal_price = getUtility(IPrice, name="decimal")
     return decimal_price(price, places)
Ejemplo n.º 5
0
 def cart_properties(self):
     return IPortalCartProperties(self.properties)