Jump to content

How I could show the "As Low As" price?


Recommended Posts

Hi,

I have 5 different prices depending of the quantity and I'm looking to show below the products thumbs, the "As Low As" price similar to:

http://www.trophydepot.com/

How I could get show the low price, since the prestashop work basis in a discount way? Example, I have:

1+= $9.37

10+= $ 8.77

75+= $8.17

150+= $7.42

300+= $6.42

I would like to show the $6.42 (low price) in the category page. Any idea?

See attachment.

Thanks!

 

post-743961-0-47391800-1389246013_thumb.jpg

Link to comment
Share on other sites

Hi again:

 

live demo: http://belvg.info/demo/prestashop/facebook_all_15/en/3-music-ipods

 

I override CategoryController::assignProductList()

$this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay);
            foreach($this->cat_products as &$cat_product) {
                if ($specific_prices = SpecificPrice::getByProductId($cat_product['id_product'])) {
                    $min_price = $cat_product['price'];
                    foreach ($specific_prices as $specific_price) {
                        if ($specific_price['price'] < 0) {
                            switch ($specific_price['reduction_type']) {
                                case 'amount':
                                    $tmp_price = $cat_product['price'] - $specific_price['reduction'];
                                    break;
                                case 'percentage':
                                    $tmp_price = $cat_product['price'] * $specific_price['reduction'];
                                    break;
                            }
                        }

                        if ($tmp_price < $min_price) {
                            $min_price = $tmp_price;
                        }
                    }

                    if ($specific_price['price'] < $tmp_price) {
                        $cat_product['from_price'] = $min_price;
                    }
                }
            } 

 

change product-list.tpl with it: 

<div class="content_price">
					{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span><br />{/if}

                    {if isset($product.from_price)}
                        <div class="as_low_as_price">
                            as low as {convertPrice price=$product.from_price}
                        </div>
                    {/if}

                    {if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>{/if}

                </div>

and modify global css:

.as_low_as_price{
    font-size: 13px;
    font-weight: bold;
    color: #07A22C;
}

 

Regards

Edited by Alexander Simonchik (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 11 months later...

But I change all this part with yours ?

	/**
	 * Assign list of products template vars
	 */
	public function assignProductList()
	{
		$hookExecuted = false;
		Hook::exec('actionProductListOverride', array(
			'nbProducts' => &$this->nbProducts,
			'catProducts' => &$this->cat_products,
			'hookExecuted' => &$hookExecuted,
		));

		// The hook was not executed, standard working
		if (!$hookExecuted)
		{
			$this->context->smarty->assign('categoryNameComplement', '');
			$this->nbProducts = $this->category->getProducts(null, null, null, $this->orderBy, $this->orderWay, true);
			$this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts"
			$this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay);
		}
		// Hook executed, use the override
		else
			// Pagination must be call after "getProducts"
			$this->pagination($this->nbProducts);

		foreach ($this->cat_products as &$product)
		{
			if ($product['id_product_attribute'] && isset($product['product_attribute_minimal_quantity']))
				$product['minimal_quantity'] = $product['product_attribute_minimal_quantity'];
		}

		$this->context->smarty->assign('nb_products', $this->nbProducts);
	}
Link to comment
Share on other sites

  • 5 months later...

Good morning, it is working with prestashop 1.6.0.14?

how should it be changed file CategoryController?

 

this is the original.

thanks


 

<?php

 

class CategoryController extends CategoryControllerCore

{

 

public function initContent()

{

    parent::initContent();

     

    if($this->cat_products) {

 

        $id_customer = (isset($this->context->customer) ? (int)$this->context->customer->id : 0);

        $id_group = (isset($this->context->customer) ? $this->context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_);

        $id_country = (int)$id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT');

        $id_currency = (int)$this->context->cookie->id_currency;

        $id_shop = $this->context->shop->id;

 

  

        foreach ($this->cat_products as $key => $product) {

 

            $prices_array = array();

 

            /* For each product, grab quantity discounts */

            $quantity_discounts = SpecificPrice::getQuantityDiscounts($product['id_product'], $id_shop, $id_currency, $id_country, $id_group, null, true);

             

 

 

 

/* Process quantity discounts to get the real price */

 

if ($quantity_discounts)

{

    foreach ($quantity_discounts as $qkey => $discount) {

         

        if (!(float)$discount['reduction'])

            $price = $discount['price'];

        else {

            if ($discount['reduction_type'] == 'percentage')

            {

                $price = $product['price_without_reduction'] - ($product['price_without_reduction'] * $discount['reduction']);

            }

            else {

                $price = $product['price_without_reduction'] - $discount['reduction'];                         

            }

        }

 

        $prices_array[] = $price;

 

    }

 

$this->cat_products[$key]['price'] = min($prices_array);

$this->cat_products[$key]['qt_disc'] = true;

 

} // end if quantity discounts

 

$this->context->smarty->assign('products', $this->cat_products);

        }

    }

}

 

}

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...