HairyJim Posted July 12, 2005 Share Posted July 12, 2005 Anyone know of an easy way to get the product id of a product available to the currency class? Jim Link to comment Share on other sites More sharing options...
HairyJim Posted July 13, 2005 Author Share Posted July 13, 2005 I was thinking of changing the display_price function to accept the product id but I am wondering if there is perhaps a better way of doing this? All I want to be able to do is query the products table from within the currency class and I need the product_id to be able to do this accuratly. Anyone got thoughts on this? Link to comment Share on other sites More sharing options...
boxtel Posted July 13, 2005 Share Posted July 13, 2005 I was thinking of changing the display_price function to accept the product id but I am wondering if there is perhaps a better way of doing this? All I want to be able to do is query the products table from within the currency class and I need the product_id to be able to do this accuratly. Anyone got thoughts on this? <{POST_SNAPBACK}> the currencies class is there to display any number in the right currency format with/without tax and as such has nothing to do with products. What are you trying to do ? Treasurer MFC Link to comment Share on other sites More sharing options...
HairyJim Posted July 13, 2005 Author Share Posted July 13, 2005 the currencies class is there to display any number in the right currency format with/without tax and as such has nothing to do with products.What are you trying to do ? <{POST_SNAPBACK}> HI, Once again you reply to my posts - are you the only user :thumbsup: I do not wish to use the currency conversion. Basically I want my products to have three prices; GBP, EUR and USD. When the user changes currency I want the system to choose the price from the table not return the GBP * Exchange rate. Link to comment Share on other sites More sharing options...
boxtel Posted July 13, 2005 Share Posted July 13, 2005 HI, Once again you reply to my posts - are you the only user :thumbsup: I do not wish to use the currency conversion. Basically I want my products to have three prices; GBP, EUR and USD. When the user changes currency I want the system to choose the price from the table not return the GBP * Exchange rate. <{POST_SNAPBACK}> well, then I would make a separate function called get_product_price ($products_id) in that function you query the products table for the price given the current currency setting, so either your retrieve the USD price or the EUR price, etc. Then you have that function return the $currency->display_price($the_retrieved_price) result. the display_price function in the class currencies: function display_price($products_price, $products_tax, $quantity = 1) { return $this->format(tep_add_tax($products_price, $products_tax) * $quantity); } calls the format function in the same class. That function has more parameters: function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') { so you could change the function display_price to : function display_price($products_price, $products_tax, $quantity = 1) { return $this->format(tep_add_tax($products_price, $products_tax) * $quantity, false); } which would prevent the exchange rate calculation. And last in your common code you can just state : echo 'Price: ' . get_price($products_id); ofcourse you could add all this to the class itself but that would eliminate the meaning of using classes (separation of function) and would result in much more messy and more difficult to maintain code. Certainly if that class is used in many locations for a variety of reasons and purposes. Treasurer MFC Link to comment Share on other sites More sharing options...
HairyJim Posted July 13, 2005 Author Share Posted July 13, 2005 Oh - excellent even more than what I was asking for. I understood it all - big thankyou. Just got to make it work with Quantity price breaks also! Jim Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.