artmaxi Posted March 9, 2012 Report Share Posted March 9, 2012 Есть старая цена, есть цена новая. Как вывести процент, на который опустилась новая цена? Большое спасибо за помощь! Quote Link to post Share on other sites
aNbY Posted March 19, 2012 Report Share Posted March 19, 2012 100 (новая * 100 / старая) Quote Link to post Share on other sites
Sudba Posted March 19, 2012 Report Share Posted March 19, 2012 а как вывести в шаблоне % скидки? Quote Link to post Share on other sites
ripiko Posted March 19, 2012 Report Share Posted March 19, 2012 Да, было бы не плохо реализовать. Quote Link to post Share on other sites
ripiko Posted March 19, 2012 Report Share Posted March 19, 2012 У меня вот так заработало: {if $product->variant->compare_price > 0} <div class="skidka-catalog"> Скидка {floor(abs(100-{$product->variant->compare_price}/($product->variant->price)*100))}% </div> {/if}Выводить можно как и хит продаж из другой темы, т.е. прямо на картинку.Например так:.skidka { background: none repeat scroll 0 0 red; bottom: 0; color: #FFFFFF; font-size: 24px; height: 28px; line-height: 28px; padding: 4px 13px; position: absolute; right: 0; z-index: 1;}Не забудьте только прописать к классу image position: relative; Quote Link to post Share on other sites
artmaxi Posted March 19, 2012 Author Report Share Posted March 19, 2012 Отлично, только делить нужно новую цену на старую, а не наоборот.Чтобы вывести правильный процент, вставляем:{if $product->variant->compare_price > 0}Скидка: {floor(abs(100-{$product->variant->price}/($product->variant->compare_price)*100))}%{/if} Quote Link to post Share on other sites
artmaxi Posted March 19, 2012 Author Report Share Posted March 19, 2012 ripiko, спасибо за помощь! Quote Link to post Share on other sites
igoryk Posted March 19, 2012 Report Share Posted March 19, 2012 Прикольно, а если вместо {floor(abs(100-{$product->variant->price}/($product->variant->compare_price)*100))}% вставить <div class="aktion_b"><div><span class="diskont">- {floor(abs(100-{$product->variant->price}/($product->variant->compare_price)*100))}<span class="proc">%</span></span></div></div> и поколдовать с css - то будет выводиться иконка и значение скидки, вот так: Quote Link to post Share on other sites
artmaxi Posted March 19, 2012 Author Report Share Posted March 19, 2012 Это можно сверстать и без всяких спанов с дивами. Одного дива и спана с процентом будет достаточно. Quote Link to post Share on other sites
igoryk Posted March 19, 2012 Report Share Posted March 19, 2012 Если можно - поподробней, с примером кода, а то я сколько не бился - не выходит .. буду рад помощи. Quote Link to post Share on other sites
artmaxi Posted March 19, 2012 Author Report Share Posted March 19, 2012 Можно, но завтра уже. Quote Link to post Share on other sites
artmaxi Posted March 19, 2012 Author Report Share Posted March 19, 2012 Дайте ссыль на свой ресурс Quote Link to post Share on other sites
igoryk Posted March 19, 2012 Report Share Posted March 19, 2012 тестю на локалке... Quote Link to post Share on other sites
artmaxi Posted March 19, 2012 Author Report Share Posted March 19, 2012 Тогда дайте код и картинки того, что есть Quote Link to post Share on other sites
igoryk Posted March 19, 2012 Report Share Posted March 19, 2012 куда выслать? Quote Link to post Share on other sites
artmaxi Posted March 19, 2012 Author Report Share Posted March 19, 2012 Mail@udaff.com Quote Link to post Share on other sites
igoryk Posted March 19, 2012 Report Share Posted March 19, 2012 ок - сейчас отправлю Quote Link to post Share on other sites
igoryk Posted March 19, 2012 Report Share Posted March 19, 2012 ушло Quote Link to post Share on other sites
artmaxi Posted March 20, 2012 Author Report Share Posted March 20, 2012 Отправил Quote Link to post Share on other sites
Maksclub Posted July 7, 2014 Report Share Posted July 7, 2014 ОтправилА можно ли через теги smarty сортировку по величине скидки сделать? (или даже не сортировку а выборку - так наверное точнее сказать) Подробно:допустим есть страница с акционными товарами : /salesЯ прописал к ней определенный шаблон.tpl, в этом шаблоне я сделал блоки с поводами акцийБлок1: "В честь меня 30% скидка" и сюда вывести все товары, у которых результат по формуле (котрая выша в теме) 30%Блок2: "В честь мамы 50% скидка" и сюда вывести все товары, у которых результат по формуле (котрая выша в теме) 50% Quote Link to post Share on other sites
alexandr_azd Posted December 23, 2016 Report Share Posted December 23, 2016 Подскажите где и что изменить чтобы процент не скидки не вычитался, а прибавлялся? ОЧЕНЬ буду благодарен!Всех с наступающим! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.