Jump to content

price range on product listing and home page for combinations products


Recommended Posts

I tried to displaying the minimum and maximum price for combination not its not working.

Can any one help to display the price in the format of $95 - $102 format for combination products on listing page and on home page

the same hook "hookDisplayProductPriceBlock($params)" has been used in the module attach but issue is its not getting install.

ps_legalcompliance-dev (1).zip

Link to comment
Share on other sites

Backward compatibility Hooks sample:

 

/* ADD to install section
    $this->registerHook('displayProductPriceBlock');
*/

public function hookDisplayProductPriceBlock($params)
{
    $customPages = array('index', 'category');
    
    if (in_array($this->context->controller->php_self, $customPages)){
        $id_product = $params['product']->id;

        $product = new product($id_product); 

        if ($product->hasAttributes()){
            if ($product->hasAttributes() > 1){
                /* More product attributes */
                $attributePriceMin = Db::getInstance()->getValue('SELECT id_product_attribute FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.$id_product.' ORDER BY price ASC');
                $attributePriceMax = Db::getInstance()->getValue('SELECT id_product_attribute FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.$id_product.' ORDER BY price DESC');
                $priceMin = Product::getPriceStatic($id_product);
                $priceMax = $priceMin + Product::getPriceStatic($id_product, true, $attributePriceMin);
            } else {
                /* One attribute for the product */
                $attributePriceMin = Product::getPriceStatic($id_product);
                $attributePriceMax = Db::getInstance()->getValue('SELECT id_product_attribute FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.$id_product.' ORDER BY price ASC');
                $priceMin = Product::getPriceStatic($id_product);
                $priceMax = $priceMin + Product::getPriceStatic($id_product, true, $attributePriceMin);
            }

            /* PS 1.7.8.7 > */
            if ($params['type'] == 'custom_price'){
                return Tools::displayPrice($priceMin).' - '.Tools::displayPrice($priceMax);
            } else {
                if ($params['type'] == 'after_price'){
                    /* PS 1.7.8.8 < */
                    return '<br>'.Tools::displayPrice($priceMin).' - '.Tools::displayPrice($priceMax);
                }
            }
        }
    }
}

 

Edited by prestashopfree.com (see edit history)
Link to comment
Share on other sites

Hi.
I'm not going to edit something that I made for free and for the default template here.

It is necessary to realize how many Prestashop templates there are in the world and it is not possible to edit something extra for each template !!!

You can adjust the style as you need.


For Prestashop > 1.7.8.7 ./modules/psfree_attributepricefromto/views/templates/front/hook/new.tpl
For Prestashop < 1.7.8.8 ./modules/psfree_attributepricefromto/views/templates/front/hook/old.tpl

Update module 1.0.2:

+ added TPL files

 

Edited by prestashopfree.com (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

                      {if }
                       <span class="price">test</span>

                        {else}
                        <span class="price">{$product.price}</span>

                        {/if}

in above if condition I want to check the configuration product present or not, how can I do it which syntax can I handle can you tell me?

 

Link to comment
Share on other sites

  • 2 weeks later...
On 1/18/2023 at 11:19 AM, prestashopfree.com said:

Hi, yes

I tried many things for handling this condition now my localhost is not working so i done one new setup for learning 

But no solution found the prices are displaying both price range  and also simple format.

 

I if try to hide this span class by .css it hide all simple product prices 

 <span class="price">{$product.price}</span>

Edited by Pragati P (see edit history)
Link to comment
Share on other sites

Hi,
first of all, you need at least a little command of PHP and HTML and TPL smarty vars.


You got enough help, including further explanations.

It is not possible for you to do work for free.

Programmers need to eat too.

Using Ctrl + C and Ctrl + V doesn't solve anything because every production solution doesn't have the same results.


Enter your request in the JOB section, as I have suggested several times.


Opening threads with similar content over and over won't solve your problem.

Link to comment
Share on other sites

2 minutes ago, prestashopfree.com said:

Hi,
first of all, you need at least a little command of PHP and HTML and TPL smarty vars.


You got enough help, including further explanations.

It is not possible for you to do work for free.

Programmers need to eat too.

Using Ctrl + C and Ctrl + V doesn't solve anything because every production solution doesn't have the same results.


Enter your request in the JOB section, as I have suggested several times.


Opening threads with similar content over and over won't solve your problem.

In JOB section what it is iam not getting it

 

Link to comment
Share on other sites

 

3 minutes ago, prestashopfree.com said:

Hi,
first of all, you need at least a little command of PHP and HTML and TPL smarty vars.


You got enough help, including further explanations.

It is not possible for you to do work for free.

Programmers need to eat too.

Using Ctrl + C and Ctrl + V doesn't solve anything because every production solution doesn't have the same results.


Enter your request in the JOB section, as I have suggested several times.


Opening threads with similar content over and over won't solve your problem.

Ohh! Got it means if any one wants paid so we an create topic there okay fine thank you.

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...