提问人:RCI 提问时间:9/25/2023 更新时间:9/26/2023 访问量:31
降低价格变量的百分比 - OpenCart
Decrease percentage of the price variable - OpenCart
问:
我对一个方面感兴趣, 我想在 OpenCart 产品页面上显示价格,价格为最终价格的 -11.76470588%。 艺术 我需要显示两种类型的价格。
那么有没有办法呢?变量: {{ price }} 或者像这样的东西:1 - ({{ price }} / 1.19 * 1.05) / X
谢谢!
我的代码:
{% if category_id=='69' %}
<div class="pret-cu-tva5">Preț cu TVA 5%: {% if price %}
{#========= Product - Price ========= #}
<div class="product_page_price price" itemprop="offerDetails" itemscope itemtype="http://data-vocabulary.org/Offer">
{% if not special %}
<span class="price-new"><span itemprop="price" id="price-old">{{ price }}</span></span>
{% else %}
<span class="price-new"><span itemprop="price" id="price-special">{{ special }}</span></span>
<span class="price-old" id="price-old">{{ price }}</span>
{% endif %}
{% if special and soconfig.get_settings('listing_discount_status') %}
{#=======Discount Label======= #}
<span class="label-product label-sale">
{{ discount }}
</span>
{% endif %}
{% if tax %}
<div class="price-tax"><span>{{ text_tax }}</span> <span id="price-tax"> {{ tax }} </span></div>
{% endif %}
</div>
{% endif %}
{% if discounts %}
<ul class="list-unstyled text-success">
{% for discount in discounts %}
<li><strong>{{ discount.quantity }} {{ text_discount }} {{ discount.price }}</strong> </li>
{% endfor %}
</ul>
{% endif %} </div>
没有结果,尝试$percent = (($rowx->Orgprice - $rowx->SalePrice)*100) /$rowx->Orgprice ;
答:
1赞
redwards
9/26/2023
#1
在 Opencart 使用的 PHP 模板中, {{ price }} 是表达式。所有内容都必须在 {{ }} 范围内才能进行计算。 因此,请按如下方式应用调整:
{{ price * .88235 }} 或 {{ 1 - (价格/ 1.19 * 1.05) }}/X
在您非常具体的情况下。
评论
0赞
RCI
9/26/2023
呜,非常好。谢谢,我已经放了这个,它给了我我想要的值 {{ price/ 1.19 * 1.05 }},但它现在有很多小数。有一个代码我可以用来显示 2?
0赞
redwards
9/26/2023
你可以使用 round(),如 {{ round(1 - (price/ 1.19 * 1.05), 2)}}/X
0赞
redwards
9/26/2023
如果您相信,请标记为正确答案。谢谢。
0赞
RCI
9/26/2023
好吧,我收到这个错误未知的“round”函数,但我会尝试更多。我认为 OpenCart 不允许 () - 我实际上需要 3 位小数 x.yyy,但无论如何,您为我指出了好的方向,以解决多个 OpenCart 分辨率,所以非常感谢!
1赞
RCI
9/26/2023
肮脏的修复,直到我找到解决方案,通过css .pret-cu-tva5-pret-numar { text-overflow: ellipsis; white-space: nowrap; display: block; overflow: hidden; width: 4em; }
评论