当前位置: 首页>>代码示例>>Python>>正文


Python ICurrencyManagement.priceToString方法代码示例

本文整理汇总了Python中easyshop.core.interfaces.ICurrencyManagement.priceToString方法的典型用法代码示例。如果您正苦于以下问题:Python ICurrencyManagement.priceToString方法的具体用法?Python ICurrencyManagement.priceToString怎么用?Python ICurrencyManagement.priceToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在easyshop.core.interfaces.ICurrencyManagement的用法示例。


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

示例1: getRotatingObjects

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
    def getRotatingObjects(self):
        """
        """
        shop = IShopManagement(self.context).getShop()
        cm = ICurrencyManagement(shop)
        
        catalog = getToolByName(self.context, "portal_catalog")
        
        path = self.data.path.encode("utf-8")
        obj = self.context.restrictedTraverse(path)
        
        result = []
        for item in IRotating(obj).getItems(self.data.limit):

            brains = catalog.searchResults(UID = item["uid"])
            product = brains[0].getObject()
            
            standard_price = IPrices(product).getPriceForCustomer(effective=False)
            price = IPrices(product).getPriceForCustomer()
                
            item["for_sale"] = product.getForSale()
            item["standard_price"] = cm.priceToString(standard_price)
            item["price"] = cm.priceToString(price)
            
            result.append(item)
            
        return result
开发者ID:Easyshop,项目名称:Easyshop,代码行数:29,代码来源:portlet.py

示例2: getCartPrice

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
 def getCartPrice(self):
     """
     """
     shop = self._getShop()
     cm = ICurrencyManagement(shop)
     
     if ICartManagement(shop).hasCart():
         cart = self._getCart()
         price = IPrices(cart).getPriceForCustomer()
         return cm.priceToString(price)
     else:
         return cm.priceToString(0.0)
开发者ID:Easyshop,项目名称:Easyshop,代码行数:14,代码来源:cart.py

示例3: getCartItems

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
    def getCartItems(self):
        """
        """    
        shop = IShopManagement(self.context).getShop()        
        cart = self._getCart()

        # If there isn't a cart yet
        if cart is None:
            return []
            
        cm = ICurrencyManagement(self.context)
        
        result = []
        for cart_item in IItemManagement(cart).getItems():
            
            product = cart_item.getProduct()

            product_price = IPrices(cart_item).getPriceForCustomer() / cart_item.getAmount()
            product_price = cm.priceToString(product_price)
            
            price = IPrices(cart_item).getPriceForCustomer()

            # Discount
            total_price = 0
            discount = IDiscountsCalculation(cart_item).getDiscount()
            if discount is not None:
                discount_price = getMultiAdapter((discount, cart_item)).getPriceForCustomer()

                discount = {
                    "title" : discount.Title(),
                    "value" : cm.priceToString(discount_price, prefix="-"),
                }

                total_price = price - discount_price
            
            # Product title
            data = IData(product).asDict()
            title = data["title"]
            
            result.append({
                "id"            : cart_item.getId(),
                "product_title" : title,
                "product_url"   : product.absolute_url(),
                "product_price" : product_price,
                "price"         : cm.priceToString(price),
                "amount"        : cart_item.getAmount(),
                "properties"    : self._getProperties(cart_item),
                "total_price"   : cm.priceToString(total_price),
                "discount"      : discount,
            })
        
        return result
开发者ID:Easyshop,项目名称:Easyshop,代码行数:54,代码来源:cart.py

示例4: getItems

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
    def getItems(self):
        """
        """
        nc = queryUtility(INumberConverter)
        cm = ICurrencyManagement(self.context)

        items = []
        item_manager = IItemManagement(self.context)

        for item in item_manager.getItems():

            product_price_gross = cm.priceToString(item.getProductPriceGross(), suffix=None)
            tax_rate = nc.floatToTaxString(item.getTaxRate())
            tax = cm.priceToString(item.getTax(), suffix=None)
            price_gross = cm.priceToString(item.getPriceGross(), suffix=None)

            # Get url. Takes care of, if the product has been deleted in the
            # meanwhile.
            product = item.getProduct()
            if product is None:
                url = None
                articleId = None
            else:
                url = product.absolute_url()
                articleId = product.getArticleId()

            # Properties
            for property in item.getProperties():
                if IProductVariant.providedBy(product) == True:
                    property["show_price"] = False
                else:
                    property["show_price"] = True

            temp = {
                "product_title"        : item.getProductTitle(),
                "product_quantity"     : "%.0f" % item.getProductQuantity(),
                "product_url"          : url,
                "product_articleid"    : articleId,
                "product_price_gross"  : product_price_gross,
                "price_gross"          : price_gross,
                "tax_rate"             : tax_rate,
                "tax"                  : tax,
                "properties"           : item.getProperties(),
                "has_discount"         : abs(item.getDiscountGross()) > 0,
                "discount_description" : item.getDiscountDescription(),
                "discount"             : cm.priceToString(item.getDiscountGross(), prefix="-", suffix=None),
            }

            items.append(temp)

        return items
开发者ID:Easyshop,项目名称:Easyshop,代码行数:53,代码来源:order_view.py

示例5: asDict

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
    def asDict(self):
        """
        """
        pvm = IProductVariantsManagement(self.context)
        
        if pvm.hasVariants() == True:
            variant = pvm.getSelectedVariant() or pvm.getDefaultVariant()
            return IData(variant).asDict()
        else:
            # price
            cm    = ICurrencyManagement(self.context)
            price = IPrices(self.context).getPriceForCustomer()
            price = cm.priceToString(price)

            # image
            image = IImageManagement(self.context).getMainImage()
            if image is not None:
                image = "%s/image_%s" % (image.absolute_url(), "preview")

            images = []
            for temp in IImageManagement(self.context).getImages():
                images.append("%s/image_tile" % temp.absolute_url())
            
            return {
                "article_id"  : self.context.getArticleId(),                
                "title"       : self.context.Title(),
                "short_title" : self.context.getShortTitle() or self.context.Title(),
                "description" : self.context.Description(),
                "url"         : self.context.absolute_url(),
                "price"       : price,
                "image"       : image,
                "images"      : images,
                "text"        : self.context.getText(),
                "short_text"  : self.context.getShortText(),
            }        
开发者ID:Easyshop,项目名称:Easyshop,代码行数:37,代码来源:data.py

示例6: _data

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
 def _data(self):
     """
     """
     limit = self.data.count
     if limit != 0:
         products = self.context.getRefs("products_products")[:limit]
     else:
         products = self.context.getRefs("products_products")
         
     result = []
     for product in products:
         
         mtool = getToolByName(self.context, "portal_membership")
         if mtool.checkPermission("View", product) == True:
             
             # Image
             image = IImageManagement(product).getMainImage()
             image_url = image.absolute_url() + "/image_thumb"
         
             # Price
             price = IPrices(product).getPriceGross()
             cm = ICurrencyManagement(product)
             price = cm.priceToString(price)
                     
             result.append({
                 "title"     : product.Title(),
                 "url"       : product.absolute_url(),
                 "image_url" : image_url,
                 "price"     : price,
             })
         
     return result
开发者ID:Easyshop,项目名称:Easyshop,代码行数:34,代码来源:related_products.py

示例7: getPaymentPrices

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
    def getPaymentPrices(self):
        """
        """
        shop = IShopManagement(self.context).getShop()
        pp = IPaymentPriceManagement(shop)
        cm = ICurrencyManagement(shop)

        result = []
        for payment_price in pp.getPaymentPrices():

            price = cm.priceToString(payment_price.getPrice())

            result.append(
                {
                    "id": payment_price.getId(),
                    "title": payment_price.Title(),
                    "price": price,
                    "url": payment_price.absolute_url(),
                    "up_url": "%s/es_folder_position?position=up&id=%s"
                    % (self.context.absolute_url(), payment_price.getId()),
                    "down_url": "%s/es_folder_position?position=down&id=%s"
                    % (self.context.absolute_url(), payment_price.getId()),
                    "amount_of_criteria": self._getAmountOfCriteria(payment_price.getId()),
                }
            )

        return result
开发者ID:ned14,项目名称:Easyshop,代码行数:29,代码来源:payment_prices.py

示例8: getShipping

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
    def getShipping(self):
        """
        """
        nc = queryUtility(INumberConverter)
        cm = ICurrencyManagement(self.context)

        price_net = cm.priceToString(self.context.getShippingPriceNet(), suffix=None)
        price_gross = cm.priceToString(self.context.getShippingPriceGross(), suffix=None)
        tax_rate = nc.floatToTaxString(self.context.getShippingTaxRate())
        tax = cm.priceToString(self.context.getShippingTax(), suffix=None)

        return {
            "price_net" : price_net,
            "price_gross" : price_gross,
            "tax_rate" : tax_rate,
            "tax" : tax,
        }
开发者ID:Easyshop,项目名称:Easyshop,代码行数:19,代码来源:order_view.py

示例9: getTotalTax

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
    def getTotalTax(self):
        """
        """
        cart = self._getCart()
        total = ITaxes(cart).getTaxForCustomer()

        cm = ICurrencyManagement(self.context)
        return cm.priceToString(total)
开发者ID:Easyshop,项目名称:Easyshop,代码行数:10,代码来源:order_preview.py

示例10: getPriceForCustomer

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
    def getPriceForCustomer(self):
        """
        """
        p = IPrices(self.context)
        price = p.getPriceForCustomer()

        cm = ICurrencyManagement(self.context)
        return cm.priceToString(price, suffix=None)
开发者ID:Easyshop,项目名称:Easyshop,代码行数:10,代码来源:order_view.py

示例11: _getPropertiesForConfiguration

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
    def _getPropertiesForConfiguration(self):
        """
        """
        u = queryUtility(INumberConverter)
        cm = ICurrencyManagement(self.context)

        selected_options = {}
        for name, value in self.request.items():
            if name.startswith("property"):
                selected_options[name[42:]] = value

        pm = IPropertyManagement(self.context)

        result = []
        for property in pm.getProperties():

            # Only properties with at least one option are displayed.
            if len(property.getOptions()) == 0:
                continue

            # Preset with select option
            options = [{
                "id"       : "select",
                "title"    : _(u"Select"),
                "selected" : False,
            }]

            for option in property.getOptions():

                # generate value string
                option_id    = option["id"]
                option_name  = option["name"]
                option_price = option["price"]

                if option_price != "0.0":
                    option_price = u.stringToFloat(option_price)
                    option_price = cm.priceToString(option_price, "long", "after", suffix=None)
                    content = "%s %s" % (option_name, option_price)
                else:
                    content = option_name

                # is option selected?
                selected_option = selected_options.get(property.getId(), "")
                selected = option_id == selected_option

                options.append({
                    "id"       : option_id,
                    "title"    : content,
                    "selected" : selected,
                })

            result.append({
                "id"      : "property_%s_%s" % (self.context.UID(), property.getId()),
                "title"   : property.Title(),
                "options" : options,
            })

        return result
开发者ID:Easyshop,项目名称:Easyshop,代码行数:60,代码来源:product.py

示例12: getValue

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
 def getValue(self):
     """
     """
     if self.context.getType() == "absolute":
         cm = ICurrencyManagement(IShopManagement(self.context).getShop())
         return cm.priceToString(self.context.getValue())
     else:
         c = getUtility(INumberConverter)
         return c.floatToTaxString(self.context.getValue())
开发者ID:ned14,项目名称:Easyshop,代码行数:11,代码来源:discount.py

示例13: getTotalPrice

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
    def getTotalPrice(self):
        """
        """
        cart = self._getCart()

        pm = IPrices(cart)
        total = pm.getPriceForCustomer()

        cm = ICurrencyManagement(self.context)
        return cm.priceToString(total)
开发者ID:Easyshop,项目名称:Easyshop,代码行数:12,代码来源:order_preview.py

示例14: TestCurrencyManagementUSD

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
class TestCurrencyManagementUSD(EasyShopTestCase):
    """
    """
    def afterSetUp(self):
        """
        """
        super(TestCurrencyManagementUSD, self).afterSetUp()
        self.shop.setCurrency("usd")
        
        self.cm = ICurrencyManagement(self.shop)
        
    def testGetLongName(self):
        """
        """
        self.assertEqual(self.cm.getLongName(), "US-Dollar")
        
    def testGetShortName(self):
        """
        """
        self.assertEqual(self.cm.getShortName(), "USD")
        
    def testGetSymbol(self):
        """
        """
        self.assertEqual(self.cm.getSymbol(), "$")
                
    def testPriceToString(self):
        """
        """
        price = 42.0
        
        string = self.cm.priceToString(price)
        self.assertEqual(string, "$ 42,00*")
        
        string = self.cm.priceToString(price, "short")
        self.assertEqual(string, "USD 42,00*")
        
        string = self.cm.priceToString(price, "long")
        self.assertEqual(string, "US-Dollar 42,00*")

        string = self.cm.priceToString(price, "long", "after")
        self.assertEqual(string, "42,00* US-Dollar")
开发者ID:Easyshop,项目名称:Easyshop,代码行数:44,代码来源:test_adapter_shop_currency.py

示例15: getPaymentValues

# 需要导入模块: from easyshop.core.interfaces import ICurrencyManagement [as 别名]
# 或者: from easyshop.core.interfaces.ICurrencyManagement import priceToString [as 别名]
    def getPaymentValues(self):
        """
        """
        nc = queryUtility(INumberConverter)
        cm = ICurrencyManagement(self.context)

        price_net = cm.priceToString(self.context.getPaymentPriceNet(), suffix=None)
        price_gross = cm.priceToString(self.context.getPaymentPriceGross(), suffix=None)
        tax_rate = nc.floatToTaxString(self.context.getPaymentTaxRate())
        tax = cm.priceToString(self.context.getPaymentTax(), suffix=None)

        transtool = getToolByName(self.context, 'translation_service')
        return {
            "display" : self.context.getPaymentPriceGross() != 0,
            "price_net" : price_net,
            "price_gross" : price_gross,
            "tax_rate" : tax_rate,
            "tax" : tax,
            "title" : transtool.utranslate("plone", u"Cash on Delivery").encode('utf-8')
        }
开发者ID:Easyshop,项目名称:Easyshop,代码行数:22,代码来源:order_view.py


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