Pragati P Posted January 5, 2023 Share Posted January 5, 2023 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 More sharing options...
Pragati P Posted January 6, 2023 Author Share Posted January 6, 2023 (edited) Hello @prestashopfree.com , Have you gone through the module which I have send in French forum i have used the same hook but it giving issue while installing? Edited January 6, 2023 by Pragati P (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted January 6, 2023 Share Posted January 6, 2023 Hi, didn't check. You need to write what version of Prestashop you have. The sample hook was valid for Prestashop 1.7.8.8 Link to comment Share on other sites More sharing options...
Pragati P Posted January 6, 2023 Author Share Posted January 6, 2023 I think its fine with my version Link to comment Share on other sites More sharing options...
ps8modules Posted January 6, 2023 Share Posted January 6, 2023 Ok, in this case it will be necessary to create a custom hook for older versions of Prestashop. And then make a modification in the TPL templates because there is a lot of rewriting from other price display hooks. Link to comment Share on other sites More sharing options...
Pragati P Posted January 6, 2023 Author Share Posted January 6, 2023 (edited) okay i will try with above suggestions thank you Edited January 6, 2023 by Pragati P (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted January 6, 2023 Share Posted January 6, 2023 (edited) 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 January 6, 2023 by prestashopfree.com (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted January 6, 2023 Share Posted January 6, 2023 If the hook already exists in your module, copy the content and paste it into the existing hook. Link to comment Share on other sites More sharing options...
Pragati P Posted January 6, 2023 Author Share Posted January 6, 2023 (edited) yes it is already present and I had paste the above the code but same installation failed Edited January 6, 2023 by Pragati P (see edit history) Link to comment Share on other sites More sharing options...
Pragati P Posted January 6, 2023 Author Share Posted January 6, 2023 1 Link to comment Share on other sites More sharing options...
ps8modules Posted January 6, 2023 Share Posted January 6, 2023 (edited) It's not the code, you'll have the error elsewhere. Check module here: https://validator.prestashop.com PS 1.7 => https://devdocs.prestashop-project.org/1.7/modules/creation/tutorial/ PS 8 => https://devdocs.prestashop-project.org/8/modules/creation/tutorial/ Edited January 6, 2023 by prestashopfree.com (see edit history) 1 Link to comment Share on other sites More sharing options...
ps8modules Posted January 6, 2023 Share Posted January 6, 2023 (edited) Note that the name of the module folder must be the same as the main PHP file of the module !!! module folder name = ps_legalcompliance module php file = ps_legalcompliance.php module zip name = ps_legalcompliance.zip This is the basis of creating modules !!! Edited January 6, 2023 by prestashopfree.com (see edit history) 1 Link to comment Share on other sites More sharing options...
Pragati P Posted January 6, 2023 Author Share Posted January 6, 2023 Thanks @prestashopfree.com I gone through tutorial and done same thing now its installed but it not showing price range i will check what's issue is 1 Link to comment Share on other sites More sharing options...
Pragati P Posted January 6, 2023 Author Share Posted January 6, 2023 Thanks i will overview both code and will check whats wrong in my code Link to comment Share on other sites More sharing options...
Pragati P Posted January 9, 2023 Author Share Posted January 9, 2023 My price range are displaying like this can we show it below if the combination available than show the price range otherwise we can show normal price. Can we do like this? Link to comment Share on other sites More sharing options...
ps8modules Posted January 9, 2023 Share Posted January 9, 2023 (edited) 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 January 18, 2023 by prestashopfree.com (see edit history) 1 Link to comment Share on other sites More sharing options...
Pragati P Posted January 18, 2023 Author Share Posted January 18, 2023 Hello Having one query that can we handle the condition that if the product is standard than display its normal price but for combination product display only the price range price can it possible? Link to comment Share on other sites More sharing options...
ps8modules Posted January 18, 2023 Share Posted January 18, 2023 Hi, yes Link to comment Share on other sites More sharing options...
Pragati P Posted January 18, 2023 Author Share Posted January 18, 2023 In which file it need to check because I had done the changes in below file but i think its product detail file psroot/themes/classic/templates/catalog/_partials/miniatures/product.tpl Link to comment Share on other sites More sharing options...
Pragati P Posted January 18, 2023 Author Share Posted January 18, 2023 {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 More sharing options...
Pragati P Posted January 27, 2023 Author Share Posted January 27, 2023 (edited) 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 January 27, 2023 by Pragati P (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted January 27, 2023 Share Posted January 27, 2023 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 More sharing options...
Pragati P Posted January 27, 2023 Author Share Posted January 27, 2023 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 More sharing options...
Pragati P Posted January 27, 2023 Author Share Posted January 27, 2023 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 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