# 在购物车中显示5个小数 -- views 领域 和 commerce 领域 和 rules 领域 drupal 相关 的问题

## Displaying 5 decimals in shopping cart

0

### 问题

• €124.44 / km，它显示
• 产品显示节点中
• €0.12444 / m，但
• 购物车中
• €0.12000 / m

I'm developing a website that mostly sells electrical wire. Prices are per kilometer and imported into commerce with 2 decimal places. Order amounts are per meter though, so in a rule I divide the price by 1000 when calculating the unit price. I use the following module for formatting the price with 5 decimals after the decimal point: https://drupal.org/project/commerce_price_decimals_formatter . In the display node this renders the price per meter correctly.

In the shopping cart view, I can also choose to format the price with 5 decimals, but the extra decimals are not shown, and simply show zeros.

So if I have a cable that's priced at

• xe2x82xac 124.44 / km, it shows
• xe2x82xac 0.12444 / m in the product display node, but
• xe2x82xac 0.12000 / m in the shopping cart

The totals in the shopping cart are correct. I'm guessing views is only getting the unit price up to 2 decimals out of commerce. What can be done to fix this?

## 回答列表

1

Prices are always going to be rounded when saved unless you've updated the definition of the currency itself to support storage to the 5th decimal place. It sounds like that module is simply offering part of the solution, while the whole solution will involve hooking into the currency info array and then updating whatever prices you've already entered to be saved with the new precision.

0

• 包括与产​​品的关系
• 打印个性化产品价格而不是线项价格，格式化为5位小数

I ended up soling this problem in a stupid straightforward way:

I edited the shopping cart and order summary view to

• include a relation to the product
• print the personalized product price instead of the line item price, formatted to 5 decimals

Obviously this is going to be trouble when I start including non-product line items, but for the time being I don't.

## 相关问题

0  根据另一个视图的结果，避免在视图上进行重复  ( Avoid duplicates on a view based on results from another view )

2  我如何做一个简单的群体？  ( How do i do a simple group by )

2  如何将数据从Google Analytics将数据转换为图表？  ( How to transform data from the google analytics reports module into charts )

1  查看最新版本VID  ( Get latest revision vid in views )

0  如何将active-trail类添加到视图中的链接？  ( How to add active trail class to a links in a view )

0  基于Drupal 6学期的视图未翻译词汇术语  ( Drupal 6 term based view not translating vocabulary terms )

0  从结果中单独的Drupal视图过滤器  ( Separate drupal view filters from the results )

2  如何在他的个人资料页面上显示用户按用户显示所有节点  ( How to display all nodes by user on his profile page )

1  如何向这本书添加审查  ( How to add reviews to the book )

0  表太宽了视图  ( Table too wide for view )

1  更改寻呼机和特定视图的每页元素数  ( Change the pager and the number of elements per page of a specific view )

0  复杂视图涉及单独实体/分类词汇/内容 - 独特  ( Complex view involving separate entities taxonomy vocabulary content disti )

0  视图：通过两个分类术语过滤内容  ( Views filter content by two taxonomy terms )

1  内容：具有分类项ID深度修饰符  ( Content has taxonomy term id depth modifier )

0  如何在自定义模块中从视图中执行查询  ( How to execute a query taken from views in custom module )

1  视图显示的含义是什么？ [复制]  ( What is the meaning of views displays )

0  列出所有词汇及其条款  ( List all vocabularies and their terms )

0  一个视图页面为块中的“将此字段作为链接输出”（Drupal）  ( A views page as output this field as a link in a block drupal )

0  增加搜索查询限制（apache solr）  ( Increasing the search query limit apache solr )

6  如何为视图上设置多个参数上下文过滤器  ( How to set programmatically multiple arguments for views contextual filters )