♥beerbee Posted October 28, 2020 Share Posted October 28, 2020 Hi, in Germany if selling food, cosmetics etc. we are obliged to to show base prices for products: E.g Green Tea 50g 5,50 € - we have to show makes 11€/100g also. In the livestore (frozen) we use an old contribution which takes also the display of taxes with the products price in to account which we are also obliged to show. So the base_price is simply a numeric DB entry in table products which provides factor which is applied to the price. This is the old one https://apps.oscommerce.com/Get&4L2fE&N3gNj (we use 2.0 which does not take varying attributes prices into account -we dont need it) What was relatively easy´: To create a hook for the admin part creating a new tab in categories edit product. On the shop side I was not successful. As there is already Display Tax Info by raiwa I was thinking I could get the output inside of the hook_shop_siteWide_priceTax provided herein. https://apps.oscommerce.com/6ONOh&display-tax-info-phoenix My problem is: I don't know how to get the $product_id inside the hook which is needed for retrieving the information from table products - apart from a single product shown on product_info which is easily done by using the global $product info. So on product_info everything is fine, but sadly we have to show it everywhere. Thanks in advance! Best regards Christoph Quote Link to comment Share on other sites More sharing options...
burt Posted October 28, 2020 Share Posted October 28, 2020 Would not the simplest option be to add in base data (weight and unit); Unit Weight: X (a number) Unit Type: y (a unit, could be g, kg, liter, gallon, whatever - maybe this always has to be "grams" ? ) The output; Base Price per Xy; price/weight * X Taking your example: Green Tea 50g 5,50 € Assuming here that your products_weight is set at 0.05 ?? If you have input fields where you add: Unit Weight: .1 Unit Type: kg You could then output on product_info; > Base Price per .1kg; 11 € Maybe you also need a multiplier ? Unit Weight: .1 (X) Unit Multiplier: 100 (n) Unit Type: g (y) Which would output Base Price per (X*n)y; price/weight * X > Base Price per 100g; 11 € At this point, you should be getting the architecture in place (as best you can) before building it up. Quote Link to comment Share on other sites More sharing options...
♥beerbee Posted October 28, 2020 Author Share Posted October 28, 2020 Hi Burt. there are three db fields added to product info: the factor for multiplication, which is numeric and is calculated based on the entries made on the admin side and then entered into db. eg factor 0.5 if have 200g or 2 if have 50g. the unit, a text field aka 100 g for displaying the unit aka per 100 g a third one not relevant here, only for googlebase. so that the calculation always fits - price changes or special So architecture/logic is clear, working fine on product_info.php (using global $product_info inside the hook,) getting the products_id for retrieving the fields for factor and unit, but not on any listings be it product or shopping card listing. So naively thinking: the currency class always "knows" the products_id everywhere but I don't get...it. Best regards Christoph Quote Link to comment Share on other sites More sharing options...
♥raiwa Posted October 28, 2020 Share Posted October 28, 2020 (edited) The currency class doesn't "know" the products id. All parameters get passed to the functions from where they are called: public function format_raw($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') { public function display_price($products_price, $products_tax, $quantity = 1) { currencies class is good for the tax info because the products tax and price is known there, but not the id. If you need the product id, you have to extract it from the listing arrays ($listing) in the product listings. Edited October 28, 2020 by raiwa Quote About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
♥beerbee Posted October 30, 2020 Author Share Posted October 30, 2020 Hi, @raiwa thanks for making this clear to me. As far as I understand it now there would be no way around changing every display of price on the shop side which I'd really like to avoid. Best regards Christoph Quote Link to comment Share on other sites More sharing options...
♥raiwa Posted October 30, 2020 Share Posted October 30, 2020 You could inject the code by jquery/javascript but this gets complicate. Also in the latest Phoenix versions, you do not need to modify the core modules. You can overwrite the module template files in templates/ beerbee 1 Quote About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
♥beerbee Posted October 30, 2020 Author Share Posted October 30, 2020 Yes thanks, I'll do it via template for now. Best regards Christoph Quote Link to comment Share on other sites More sharing options...
domiosc Posted November 1, 2020 Share Posted November 1, 2020 I do not remember where, but years ago there was a payment addon for conversions that allowed to show the complete information, both by grouping or packaging at the same time as converting the unit and the price. For example, linear meters with a price per square meter, as you defined the combination. I could even make height x width x depth to calculate areas, also with weights, for example price per kilo, sale per grams or units ... In the end what did was an equivalent conversion and displayed the information for both units of measurement allowing you to use the one you define, by setting minimums, maximums and multiples. It was used for sale in bulk and to cut. I don't know if it will still exist but somebody remembers which one I mean. Quote Link to comment Share on other sites More sharing options...
jonwix Posted November 3, 2020 Share Posted November 3, 2020 On 11/1/2020 at 1:17 PM, domiosc said: I do not remember where, but years ago there was a payment addon for conversions that allowed to show the complete information, both by grouping or packaging at the same time as converting the unit and the price. For example, linear meters with a price per square meter, as you defined the combination. I could even make height x width x depth to calculate areas, also with weights, for example price per kilo, sale per grams or units ... In the end what did was an equivalent conversion and displayed the information for both units of measurement allowing you to use the one you define, by setting minimums, maximums and multiples. It was used for sale in bulk and to cut. I don't know if it will still exist but somebody remembers which one I mean. I used a similar add-on years ago (with OsC 2.2) for a sign shop that sold vinyl material by the square foot. I may be able to find the add-on if I look through some old hard drives. domiosc 1 Quote Link to comment Share on other sites More sharing options...
♥beerbee Posted November 3, 2020 Author Share Posted November 3, 2020 Hi, got it working so far, I'm using https://apps.oscommerce.com/4L2fE&base-price-2-0 partially, which means I use the function that is put in functions general (changed a bit) , and DB entires . To avoid core code changes as far as possible I had to make up a new theme, to change tpl_ files there, and also the includes/components/product:_listing.php. Example: from /includes/modules/content/index/templates/tpl_cm_i_card_products 2.php echo sprintf(IS_PRODUCT_SHOW_PRICE, $currencies->display_price($card_products['products_price'], tep_get_tax_rate($card_products['products_tax_class_id']))); to /templates/mytemplate/includes/modules/content/indextpl_cm_i_card_products 2.php echo sprintf(IS_PRODUCT_SHOW_PRICE, $currencies->display_price($card_products['products_price'], tep_get_tax_rate($card_products['products_tax_class_id'])) . tep_get_products_display_price($card_products['products_id'], true)); Best regards Christoph Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.