Nizar54 Posted March 23, 2010 Share Posted March 23, 2010 I want to give a condition if the reference of the product i fill is 1, how to make it in php.It's just a simple problem, can someone help me pls. Link to comment Share on other sites More sharing options...
rocky Posted March 23, 2010 Share Posted March 23, 2010 Can you be more specific about what you want? You can use the following code in product.tpl: {if $product->reference == '1'} ... {/if} or the following in product-list.tpl: {if $product.reference == '1'} ... {/if} Link to comment Share on other sites More sharing options...
Nizar54 Posted March 23, 2010 Author Share Posted March 23, 2010 I want to edit classes/tools.php, so i want to give a special price for product that have reference 1 in classes/tools.php. How to give it a conditional code in classes/tools.php? Link to comment Share on other sites More sharing options...
rocky Posted March 23, 2010 Share Posted March 23, 2010 It is not possible to do in classes/Tools.php since you don't have access to the product. I suggest that you instead modify the getPriceStatic function in classes/Product.php. Change line 1247 from: SELECT p.`price`, p.`reduction_price`, p.`reduction_percent`, p.`reduction_from`, p.`reduction_to`, p.`id_tax`, t.`rate`, to: SELECT p.`reference`, p.`price`, p.`reduction_price`, p.`reduction_percent`, p.`reduction_from`, p.`reduction_to`, p.`id_tax`, t.`rate`, to get the reference and then add the following code further down in the function depending on the order you want the discounts to be made: if ($result['reference'] == '1') $price *= 0.2; This code will take 20% off the price if the reference is '1'. Change 0.2 to whatever percentage discount you want to apply. Link to comment Share on other sites More sharing options...
Nizar54 Posted March 23, 2010 Author Share Posted March 23, 2010 How to give a special conversion price to the product that have reference 1? Link to comment Share on other sites More sharing options...
Nizar54 Posted March 23, 2010 Author Share Posted March 23, 2010 I need static conversion rate for specific product, is it possible, help please?That's why i want to use reference but rocky said can't use it in classes.php Link to comment Share on other sites More sharing options...
rocky Posted March 23, 2010 Share Posted March 23, 2010 Sorry, but I don't understand what you mean by "static conversion rate". Do you want to disable the currency conversion for products with reference "1"? My code above is discounting the product by 20% when the reference is "1". Link to comment Share on other sites More sharing options...
Nizar54 Posted March 23, 2010 Author Share Posted March 23, 2010 Yes, that is what i mean Rocky, i want to disable the currency conversion for products with reference “1” Link to comment Share on other sites More sharing options...
Nizar54 Posted March 24, 2010 Author Share Posted March 24, 2010 Anyone please, how to disable the currency conversion for products with reference “1”?Or is it another way to disable currency conversion for particular product? Link to comment Share on other sites More sharing options...
rocky Posted March 24, 2010 Share Posted March 24, 2010 Try changing the contents of the convertPrice function in classes/Product.php to the following: $currency = $smarty->ps_currency; if ($reference == '1') $currency->conversion_rate = 1; return Tools::displayPrice($params['price'], $currency); Link to comment Share on other sites More sharing options...
Nizar54 Posted March 24, 2010 Author Share Posted March 24, 2010 This is my convert price function static function convertPrice($reference, $currency, $params, &$smarty) { $currency = $smarty->ps_currency; if ($reference == '1') $currency->conversion_rate = 1; return Tools::displayPrice($params['price'], $currency); } It doesn't work, all my price going to zero. Link to comment Share on other sites More sharing options...
rocky Posted March 24, 2010 Share Posted March 24, 2010 Sorry, this is just too difficult to do. The price conversion functions are static functions, so they don't have access to the product reference. It might be possible to do by passing the product reference into the convertPrice function, but it would require much messing around with code. I don't think it is worth the effort. Link to comment Share on other sites More sharing options...
Nizar54 Posted March 24, 2010 Author Share Posted March 24, 2010 How about using two currency, is it possible? Link to comment Share on other sites More sharing options...
Nizar54 Posted March 25, 2010 Author Share Posted March 25, 2010 Can i use conditional if for using two currency please? Link to comment Share on other sites More sharing options...
rocky Posted March 25, 2010 Share Posted March 25, 2010 Sorry, I don't understand what it is that you want. You can use code like the following to check the ID of the current currency and do something different for each in a PHP file. if ($smarty->ps_currency->id == 1) { ... } elseif ($smarty->ps_currency->id == 2) { ... } Link to comment Share on other sites More sharing options...
Nizar54 Posted March 25, 2010 Author Share Posted March 25, 2010 Thanks Rocky for helping me until now, i want if conditional like this (using reference) if ($reference == '1') { $smarty->ps_currency->id = 1 } else { $smarty->ps_currency->id = 2 } Is it possible? Link to comment Share on other sites More sharing options...
rocky Posted March 25, 2010 Share Posted March 25, 2010 No, it suffers from the same problem as I previously mentioned. You don't have access to the product reference in the convertPrice function, so you can't change the currency based on it. 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