本文整理汇总了Python中easyshop.core.interfaces.ICurrencyManagement类的典型用法代码示例。如果您正苦于以下问题:Python ICurrencyManagement类的具体用法?Python ICurrencyManagement怎么用?Python ICurrencyManagement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ICurrencyManagement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: asDict
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(),
}
示例2: getPaymentPrices
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
示例3: _data
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
示例4: getRotatingObjects
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
示例5: getPriceForCustomer
def getPriceForCustomer(self):
"""
"""
p = IPrices(self.context)
price = p.getPriceForCustomer()
cm = ICurrencyManagement(self.context)
return cm.priceToString(price, suffix=None)
示例6: getTotalTax
def getTotalTax(self):
"""
"""
cart = self._getCart()
total = ITaxes(cart).getTaxForCustomer()
cm = ICurrencyManagement(self.context)
return cm.priceToString(total)
示例7: _getPropertiesForConfiguration
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
示例8: getValue
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())
示例9: getTotalPrice
def getTotalPrice(self):
"""
"""
cart = self._getCart()
pm = IPrices(cart)
total = pm.getPriceForCustomer()
cm = ICurrencyManagement(self.context)
return cm.priceToString(total)
示例10: _getPropertiesForConfiguration
def _getPropertiesForConfiguration(self, cart_item):
"""
"""
u = getUtility(INumberConverter)
cm = ICurrencyManagement(self.context)
# Store all selected options for lookup below
selected_options = {}
for property in cart_item.getProperties():
selected_options[property["id"]] = property["selected_option"]
product = cart_item.getProduct()
pm = IPropertyManagement(product)
result = []
for property in pm.getProperties():
# Only properties with at least one option are displayed.
if len(property.getOptions()) == 0:
continue
options = []
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" % (product.UID(), property.getId()),
"title" : property.Title(),
"options" : options,
})
return result
示例11: getCartPrice
def getCartPrice(self):
"""Returns the price of the current cart.
"""
cart = self._getCart()
if cart is None:
price = 0.0
else:
price = IPrices(cart).getPriceForCustomer()
cm = ICurrencyManagement(self.context)
return cm.priceToString(price, suffix=None)
示例12: getTaxForCustomer
def getTaxForCustomer(self):
"""
"""
cm = ICurrencyManagement(self.context)
cart = self._getCart()
if cart is None:
tax = 0.0
else:
tax = ITaxes(cart).getTaxForCustomer()
return cm.priceToString(tax, suffix=None)
示例13: getCartItems
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
示例14: getItems
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
示例15: getSearchPrice
def getSearchPrice(self, product):
"""
"""
product = product.getObject()
# Price
cm = ICurrencyManagement(product)
p = IPrices(product)
# Effective price
price = p.getPriceForCustomer()
price = cm.priceToString(price)
return price