tonisky Posted November 21, 2016 Share Posted November 21, 2016 (edited) Hi, I have a problem here. The prices of my items change according to different volumes. For example, the original price of an item is £10. If you buy one, it is £10; if you buy 2 ~4, it is £9; if you buy 5+, it is £8. I want to show the lowest price (£8 in this example) on home page and product list page. But I don't know which file I should edit and how to. Here is my website: http://www.phonepartsdirect.co.uk/. I am using default theme, on 1.6.1.9 version. Any help will be very much appreciated. Edited November 21, 2016 by tonisky (see edit history) Link to comment Share on other sites More sharing options...
tonisky Posted November 22, 2016 Author Share Posted November 22, 2016 No one can help? Link to comment Share on other sites More sharing options...
maxfox44 Posted November 22, 2016 Share Posted November 22, 2016 Can you add the price to the actual product image? Link to comment Share on other sites More sharing options...
tonisky Posted November 23, 2016 Author Share Posted November 23, 2016 Hi, Can you add the price to the actual product image? Hi, did you mean adding the discounted price (the lowest one) to the product image? If that's what you meant, then every time I adjust prices, I will have to change all the product images? No it's not a good idea. I just want it to get the lowest price for every product and display it on home page and product list page. I know product-list.tpl is the file to edit, but I don't how to coded it. I want something like this website: mengtor.uk. The prices displayed on it's homepage are the lowest ones. Link to comment Share on other sites More sharing options...
sandipchandela Posted November 23, 2016 Share Posted November 23, 2016 (edited) Hi, I have a problem here. The prices of my items change according to different volumes. For example, the original price of an item is £10. If you buy one, it is £10; if you buy 2 ~4, it is £9; if you buy 5+, it is £8. I want to show the lowest price (£8 in this example) on home page and product list page. But I don't know which file I should edit and how to. Here is my website: http://www.phonepartsdirect.co.uk/. I am using default theme, on 1.6.1.9 version. Any help will be very much appreciated. To display on home page, you need to add in product-list.tpl file As you want to show lowest price on home page you can call product object in product-list.tpl file Take reference from product.tpl file and go to around 430 line. {foreach from=$quantity_discounts item='quantity_discount' name='quantity_discounts'} {if $quantity_discount.price >= 0 || $quantity_discount.reduction_type == 'amount'} {$realDiscountPrice=$productPriceWithoutReduction|floatval-$quantity_discount.real_value|floatval} {else} {$realDiscountPrice=$productPriceWithoutReduction|floatval-($productPriceWithoutReduction*$quantity_discount.reduction)|floatval} {/if} <tr id="quantityDiscount_{$quantity_discount.id_product_attribute}" class="quantityDiscount_{$quantity_discount.id_product_attribute}" data-real-discount-value="{convertPrice price = $realDiscountPrice}" data-discount-type="{$quantity_discount.reduction_type}" data-discount="{$quantity_discount.real_value|floatval}" data-discount-quantity="{$quantity_discount.quantity|intval}"> <td> {$quantity_discount.quantity|intval} </td> <td> {if $quantity_discount.price >= 0 || $quantity_discount.reduction_type == 'amount'} {if $display_discount_price} {if $quantity_discount.reduction_tax == 0 && !$quantity_discount.price} {convertPrice price = $productPriceWithoutReduction|floatval-($productPriceWithoutReduction*$quantity_discount.reduction_with_tax)|floatval} {else} {convertPrice price=$productPriceWithoutReduction|floatval-$quantity_discount.real_value|floatval} {/if} {else} {convertPrice price=$quantity_discount.real_value|floatval} {/if} {else} {if $display_discount_price} {if $quantity_discount.reduction_tax == 0} {convertPrice price = $productPriceWithoutReduction|floatval-($productPriceWithoutReduction*$quantity_discount.reduction_with_tax)|floatval} {else} {convertPrice price = $productPriceWithoutReduction|floatval-($productPriceWithoutReduction*$quantity_discount.reduction)|floatval} {/if} {else} {$quantity_discount.real_value|floatval}% {/if} {/if} </td> <td> <span>{l s='Up to'}</span> {if $quantity_discount.price >= 0 || $quantity_discount.reduction_type == 'amount'} {$discountPrice=$productPriceWithoutReduction|floatval-$quantity_discount.real_value|floatval} {else} {$discountPrice=$productPriceWithoutReduction|floatval-($productPriceWithoutReduction*$quantity_discount.reduction)|floatval} {/if} {$discountPrice=$discountPrice * $quantity_discount.quantity} {$qtyProductPrice=$productPriceWithoutReduction|floatval * $quantity_discount.quantity} {convertPrice price=$qtyProductPrice - $discountPrice} </td> </tr> {/foreach} You also need to get bulk discount data from ProductController file and assign $quantity_discounts to your respective template file (new products, best seller, featured etc). $quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true, (int)$this->context->customer->id); foreach ($quantity_discounts as &$quantity_discount) { if ($quantity_discount['id_product_attribute']) { $combination = new Combination((int)$quantity_discount['id_product_attribute']); $attributes = $combination->getAttributesName((int)$this->context->language->id); foreach ($attributes as $attribute) { $quantity_discount['attributes'] = $attribute['name'].' - '; } $quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - '); } if ((int)$quantity_discount['id_currency'] == 0 && $quantity_discount['reduction_type'] == 'amount') { $quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], null, Context::getContext()->currency); } } Hope this helps you a lot. Edited November 23, 2016 by archSandy (see edit history) Link to comment Share on other sites More sharing options...
tonisky Posted November 23, 2016 Author Share Posted November 23, 2016 To display on home page, you need to add in product-list.tpl file As you want to show lowest price on home page you can call product object in product-list.tpl file Take reference from product.tpl file and go to around 430 line. {foreach from=$quantity_discounts item='quantity_discount' name='quantity_discounts'} {if $quantity_discount.price >= 0 || $quantity_discount.reduction_type == 'amount'} {$realDiscountPrice=$productPriceWithoutReduction|floatval-$quantity_discount.real_value|floatval} {else} {$realDiscountPrice=$productPriceWithoutReduction|floatval-($productPriceWithoutReduction*$quantity_discount.reduction)|floatval} {/if} <tr id="quantityDiscount_{$quantity_discount.id_product_attribute}" class="quantityDiscount_{$quantity_discount.id_product_attribute}" data-real-discount-value="{convertPrice price = $realDiscountPrice}" data-discount-type="{$quantity_discount.reduction_type}" data-discount="{$quantity_discount.real_value|floatval}" data-discount-quantity="{$quantity_discount.quantity|intval}"> <td> {$quantity_discount.quantity|intval} </td> <td> {if $quantity_discount.price >= 0 || $quantity_discount.reduction_type == 'amount'} {if $display_discount_price} {if $quantity_discount.reduction_tax == 0 && !$quantity_discount.price} {convertPrice price = $productPriceWithoutReduction|floatval-($productPriceWithoutReduction*$quantity_discount.reduction_with_tax)|floatval} {else} {convertPrice price=$productPriceWithoutReduction|floatval-$quantity_discount.real_value|floatval} {/if} {else} {convertPrice price=$quantity_discount.real_value|floatval} {/if} {else} {if $display_discount_price} {if $quantity_discount.reduction_tax == 0} {convertPrice price = $productPriceWithoutReduction|floatval-($productPriceWithoutReduction*$quantity_discount.reduction_with_tax)|floatval} {else} {convertPrice price = $productPriceWithoutReduction|floatval-($productPriceWithoutReduction*$quantity_discount.reduction)|floatval} {/if} {else} {$quantity_discount.real_value|floatval}% {/if} {/if} </td> <td> <span>{l s='Up to'}</span> {if $quantity_discount.price >= 0 || $quantity_discount.reduction_type == 'amount'} {$discountPrice=$productPriceWithoutReduction|floatval-$quantity_discount.real_value|floatval} {else} {$discountPrice=$productPriceWithoutReduction|floatval-($productPriceWithoutReduction*$quantity_discount.reduction)|floatval} {/if} {$discountPrice=$discountPrice * $quantity_discount.quantity} {$qtyProductPrice=$productPriceWithoutReduction|floatval * $quantity_discount.quantity} {convertPrice price=$qtyProductPrice - $discountPrice} </td> </tr> {/foreach} You also need to get bulk discount data from ProductController file and assign $quantity_discounts to your respective template file (new products, best seller, featured etc). $quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true, (int)$this->context->customer->id); foreach ($quantity_discounts as &$quantity_discount) { if ($quantity_discount['id_product_attribute']) { $combination = new Combination((int)$quantity_discount['id_product_attribute']); $attributes = $combination->getAttributesName((int)$this->context->language->id); foreach ($attributes as $attribute) { $quantity_discount['attributes'] = $attribute['name'].' - '; } $quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - '); } if ((int)$quantity_discount['id_currency'] == 0 && $quantity_discount['reduction_type'] == 'amount') { $quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], null, Context::getContext()->currency); } } Hope this helps you a lot. Hi archSandy, many thanks for your help. Do I need to add bulk discount data from ProductController to product-list.tpl? Similarly, do I need to add the quantity discount project from product.tpl to other templates (new products, best sellers, etc.)? Link to comment Share on other sites More sharing options...
sandipchandela Posted November 23, 2016 Share Posted November 23, 2016 Hi archSandy, many thanks for your help. Do I need to add bulk discount data from ProductController to product-list.tpl? Similarly, do I need to add the quantity discount project from product.tpl to other templates (new products, best sellers, etc.)? Yes both codes you need to add. Then you can change display format as per your need in tpl files. Link to comment Share on other sites More sharing options...
tonisky Posted November 23, 2016 Author Share Posted November 23, 2016 Yes both codes you need to add. Then you can change display format as per your need in tpl files. Hi archSandy, many thanks. I just added both codes to product-list.tpl, unfortunately, it doesn't work. After I added the codes, the home page looks like this (please see the attached picture). the source codes from productcontroller.php were just displayed on the homepage. And it has no effect on the price. Do you have any suggestions? Link to comment Share on other sites More sharing options...
sandipchandela Posted November 24, 2016 Share Posted November 24, 2016 (edited) May be you are wrong doing. Follow these steps: Likewise bulk price table is showing on product page you need to get that code from product.php (this code assign to tpl file) and product.tpl (assigned code will get display ) Now comes to your point, you need to show on home page so need to change blocknewproducts.php , blockbestsellers.php in their module. Things are litte bit tough if you know Smarty and Php very well. Thanks Edited November 24, 2016 by archSandy (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now