phkr Posted May 9, 2016 Share Posted May 9, 2016 Hello everyone, I want to show the quantity discount table of a certain product on my homepage (not product page). I am a ps module programming beginner and started with the toturial. So I know how to show some content and hook it to display home. However I was not able to figure out how to get or use the variables from product.tpl and related files. I found, that the productcontroller.php governs the generation of the product variables, but that's it. Can you help me? Thanks a million, Philipp Link to comment Share on other sites More sharing options...
vekia Posted May 9, 2016 Share Posted May 9, 2016 to php file of your module you have to add code to get quantity discounts. Add it to home hook function. See productController.php for variable $quantity_discounts you can get there full code to get discounts from database, then in tpl file you have to add code to display table <div id="quantityDiscount"> <table class="std"> <thead> <tr> <th>{l s='Product'}</th> <th>{l s='From (qty)'}</th> <th>{if Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')}{l s='Price'}{else}{l s='Discount'}{/if}</th> </tr> </thead> <tbody> {foreach from=$quantity_discounts item='quantity_discount' name='quantity_discounts'} <tr id="quantityDiscount_{$quantity_discount.id_product_attribute}" class="quantityDiscount_{$quantity_discount.id_product_attribute}"> <td> {if (isset($quantity_discount.attributes) && ($quantity_discount.attributes))} {$product->getProductName($quantity_discount.id_product, $quantity_discount.id_product_attribute)} {else} {$product->getProductName($quantity_discount.id_product)} {/if} </td> <td>{$quantity_discount.quantity|intval}</td> <td> {if $quantity_discount.price >= 0 OR $quantity_discount.reduction_type == 'amount'} {if Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')} {convertPrice price=$productPrice-$quantity_discount.real_value|floatval} {else} -{convertPrice price=$quantity_discount.real_value|floatval} {/if} {else} {if Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')} {convertPrice price = $productPrice-($productPrice*$quantity_discount.reduction)|floatval} {else} -{$quantity_discount.real_value|floatval}% {/if} {/if} </td> </tr> {/foreach} </tbody> </table> </div> Link to comment Share on other sites More sharing options...
phkr Posted May 9, 2016 Author Share Posted May 9, 2016 The tpl part was what I found myself ;-) But fpr the php part, how do I pass the product id? I mean in the tpl, the table is is generated from the variables generated in the controller, right? How do I pass the product id into this get the table of the product with certain ID ? 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