Jack_mcs Posted February 20, 2007 Author Share Posted February 20, 2007 You have them posted outside of the class. Right above this code // BOC Attribute Percentage function format_percentage($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') { global $currency; if (empty($currency_type)) $currency_type = $currency; if ($calculate_currency_value == true) { $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value']; $format_string = number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . "%"; // if the selected currency is in the european euro-conversion and the default currency is euro, // the currency will displayed in the national currency and euro currency if ( (DEFAULT_CURRENCY == 'EUR') && ($currency_type == 'DEM' || $currency_type == 'BEF' || $currency_type == 'LUF' || $currency_type == 'ESP' || $currency_type == 'FRF' || $currency_type == 'IEP' || $currency_type == 'ITL' || $currency_type == 'NLG' || $currency_type == 'ATS' || $currency_type == 'PTE' || $currency_type == 'FIM' || $currency_type == 'GRD') ) { $format_string .= ' <small>[' . $this->format($number, true, 'EUR') . ']</small>'; } } else { $format_string = number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . "%"; } return $format_string; } // EOC Attribute Percentage // BOC Attribute Percentage function display_price_percentage($products_price, $products_tax, $quantity = 1) { return $this->format_percentage(tep_add_tax($products_price, $products_tax) * $quantity); } // EOC Attribute Percentage you will see this } Cut that and paste it right before the ?> at the end. That should fix it. Jack Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
tletourneau Posted February 20, 2007 Share Posted February 20, 2007 Yep, that fixed it. Man, how did I miss that?!? I went over that code at least a dozen times. Thank you very much for all the help! I just have one last question, when the percentages show in the drop down is there a way to make them display as *15% (and so on) instead of *0.15%? I'm just wondering because I'm going to have some items with an increase if over 100% and I think customers might get confused if the see *1.75% instead of *175%. Thanks again for all of the help!!! Tom Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted February 20, 2007 Author Share Posted February 20, 2007 You could try changing the code in the currencies file to display it as you want (multiply it by 100 to move the decimal). I haven't tried it but it might work. Jack Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
Guest Posted March 13, 2007 Share Posted March 13, 2007 Jack, I understand, but i'm not a code jockey like you. If you provide a solution, I'd gladly pay you... do you have paypal or something or could I send you a check? Are you interested? Did we figure out how to do this? I also need to multiply the total price (other attributes included) by a percentage. Maybe it should be a new contribution as this one was not intended for this purpose originally. Quote Link to comment Share on other sites More sharing options...
nkmartin Posted March 19, 2007 Share Posted March 19, 2007 First off, thanks to Jack_mcs for the contribution. I installed this contribution to give the customer an attribute option allowing them to select whether or not to add 17.5% to the products value. Everything seemed to work fine, except for one thing. When a customer adds a product to their Cart, the contribution seems to round the percentage upwards, so instead of calculating a 17.5% percentage, it calculates an 18%. What is even stranger, is it is only the subtotal in the shopping cart page (i.e. shopping_cart.php) and shopping cart box total have the rounded percentage value, everywhere else the totals are fine. Many thanks in advance for any suggestions. Quote Link to comment Share on other sites More sharing options...
68fordxl Posted March 27, 2007 Share Posted March 27, 2007 Hey now, Jack. Took another stab at installing the contribution on my site. Checked functionality after uploading every page, and got no other error messages, until the last step for the product info page. Found line 137, and added the code from the forum page to my product info page to get: 137 | if ($products_options['options_values_price'] != '0') { 138 |// BOC Attribute Percentage 139 | if ($products_options['price_prefix'] == ATTRIBUTE_PERCENTAGE_SYMBOL) 140 | $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies-display_price_percentage($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; 141 | else 142 |// EOC Attribute Percentage (XXX | added for clarity - not part of the code on the page) Now getting a different error message: Parse error: syntax error, unexpected T_IF in /home/kvrperf/public_html/shop/product_info2.php on line 139 This store also has the "Add Quantity Pulldown to Prod Info Page" contribution added to it. Source code of the product_info.php file is available at: http://www.leeper.info/product_info2.php.zip. I have also tried the installation on an "unmolested" page with the same results. Thanks in advance for any help you or the forum members can provide. -- Roger This contribution allows you to add a product attribute that will add a percentage of the products price instead of using the plus or minus. Jack Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted March 27, 2007 Author Share Posted March 27, 2007 If your code really appears as else // EOC Attribute Percentage then that is probably the problem since it is invalid. Jack Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
68fordxl Posted March 27, 2007 Share Posted March 27, 2007 (edited) It does appear that way, just as it was posted. Not knowing how to code, I copy and paste. I've learned some syntax that way, but not enough to know what to do to fix something if the code I copy is invalid. This is what I copied: // BOC Attribute Percentage if ($products_options['price_prefix'] == ATTRIBUTE_PERCENTAGE_SYMBOL) $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price_percentage($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; else // EOC Attribute Percentage Can you please post the corrected, paste-able version? TIA. -- Roger Edited March 27, 2007 by 68fordxl Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted March 27, 2007 Author Share Posted March 27, 2007 Try using the included product_info_.php file. If the problem goes away, then you know it is in that file. You can then compare it with yours to find the mistake. Jack Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
68fordxl Posted March 27, 2007 Share Posted March 27, 2007 Used the included product_info.php file, and that worked.. despite it's having the same code as the instructions here on the forum. Also had to move the curly bracket in the currency class file, and now all appears to be working well. Thanks for the cool contribution, and your help in getting me set up. -- Roger Try using the included product_info_.php file. If the problem goes away, then you know it is in that file. You can then compare it with yours to find the mistake. Jack Quote Link to comment Share on other sites More sharing options...
Guest Posted April 3, 2007 Share Posted April 3, 2007 http://www.oscommerce.com/community/contributions,1119 Jack, Any idea if your contrib will work with the above contrib? Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted April 3, 2007 Author Share Posted April 3, 2007 I doubt it but I haven't tried it. Any attributes contribution that manages attributes would use the stock attribute code, which it should. It wouldn't know about the option added by this one so the percentage option would not display - I'm guessing. Jack Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
scotch33 Posted May 2, 2007 Share Posted May 2, 2007 Hi there, Great contribution idea - just what i needed - but I am getting the following issue... however, i want to take off the price... e.g. if they buy the full product it is 100% of the price (i.e. no price change) if they buy a sample of the product it is 10% of the price. Is it possible to use the contrib in this way? Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted May 2, 2007 Author Share Posted May 2, 2007 Not currently. The percentage is added to the total. Jack Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
Adyx Posted May 17, 2007 Share Posted May 17, 2007 Hi, been looking around for this sort of thing for ages. Well done! :thumbsup: A quick question.. is there an easy way to get this to deduct the percentage value, rather than add it ? I assume it wont work if i give it a duel operator : -* or +* Thank you for your help ;) Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted May 17, 2007 Author Share Posted May 17, 2007 You can try entering a negative percentage. I've never tried it so I can't say if it will work. If the percentage was always going to be negative, then the code could be altered to subtract instead of add in the shopping cart class file. Jack Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
Adyx Posted May 17, 2007 Share Posted May 17, 2007 You can try entering a negative percentage. I've never tried it so I can't say if it will work. If the percentage was always going to be negative, then the code could be altered to subtract instead of add in the shopping cart class file. Jack Thank you for the fast response. I just checked on this... it works ! check it out... Add the * operator as normal, but when you add in your percentage exampe 10% e.g 0.10 Try doing this : -0.10 Worked great for me! :thumbsup: Quote Link to comment Share on other sites More sharing options...
Swami Posted October 2, 2007 Share Posted October 2, 2007 I'd be interested to know how to have more than one attribute with a % assigned to it. How would I go about making each attribute compile a % of the original product price, not daisy chaining off of each other? Example: Product1 = $100, Option1 increases the total 10%, Option2 increases the total 10%, making the total $120. Right now, the module does this: Product1 = $100, Option1 increases the total 10%, Option2 increases the total 10%, making the total $111. Any ideas? This would effectively help to discount attributes when a quantity price break is in effect (since we have a consistent sliding % for the attribute.) Swami Quote Link to comment Share on other sites More sharing options...
mikempn Posted December 10, 2008 Share Posted December 10, 2008 Did anyone have the solution to having multiple attribute % changes? Adding to total cost? I know in math it should be: X + (X * A% ) + (X * B%) = Y I just don't know where this is int he code! mikempn Quote Link to comment Share on other sites More sharing options...
jennyb Posted March 26, 2010 Share Posted March 26, 2010 heya - thanks for contrib, this helps solve the problem of updating prices without having to go back and update attribute increases too! have read through all the forum discussion and managed to debug a few things, but am still coming up with two weird errors : 1) the percentage doesn't stay fixed, but increases as if tax was being added. ie, i input 1.25, and it gives me back 1.32 (i had this problem with regular attributes before the contrib but don't know where it's coming from) 2) the amount isn't multiplied at all, but in fact is subtracted :( i've tried both with * and x and get the same result. not sure what i'm doing wrong. any help would be appreciated. thnx, -jennyb Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted March 26, 2010 Author Share Posted March 26, 2010 Are you saying that if you try it a third time it increases yet again? If not, it is probably due to the tier settings or something along those lines. You will need to figure out where the extra percentage is coming from in order to fix it. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
jennyb Posted March 27, 2010 Share Posted March 27, 2010 Are you saying that if you try it a third time it increases yet again? If not, it is probably due to the tier settings or something along those lines. You will need to figure out where the extra percentage is coming from in order to fix it. well, i figured out that the tax issue is just something i have to deal with by calculating my increases before tax (which i don't usually do). but no, the real problem i was having that instead of multiplying the amount to come with a correct percentage price increase, the amount were being subtracted. i tried with both * and x. nothin doin. i have finally decided to go with the Actual Attribute Price v1.7 because, although it makes more work for me, i find it much nicer for users. but if anyone's up for making a contrib that can do both (calculate increase by percentage & show total price rather than the increase), i'm a taker! thanks, -jennyb Quote Link to comment Share on other sites More sharing options...
craigcoffman Posted May 1, 2013 Share Posted May 1, 2013 Has anyone got this working with OScommerce 2.3.3? Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted May 1, 2013 Author Share Posted May 1, 2013 (edited) It should work in 2.3. The class files that are changed use a different function for pricing than 2.3 uses but the function is still in the oscommerce code. That can be changed if wanted but I don't think it is necessary. I could be wrong, of course, so a backup should be made. I know I've installed it into a 2.3 shop but I don't recall if I used it as is or converted it. Edited May 1, 2013 by Jack_mcs Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
imageset Posted June 15, 2013 Share Posted June 15, 2013 Can someone help making this great add-on work with 2.3.3 ? The problem seems to be in the replacements at classes/shopping_cart.php . The last replacement somehow causes a misconfiguration and the site doesn't load. I am blocked on this, have not been able to test if works at all. Can somebody help? Thanks 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.