tomten Posted June 29, 2006 Share Posted June 29, 2006 I added the True to the two 'in_cart's in ot_together.php. Where else do I need to change it so that the correct uprid can get passed to the calculate_2gether_discount() function? I'm beginning to think that we have to modify get_quanitity like we modified in_cart so that the get_quantity calls in ot_together's function calculate_2gether_discount can actually find a quantity of an item with attributes. My guess is this call is using the product id without attributes, and since the attributes are not included, the get_quantity function returns 0. Do you think this is correct? If so, how can I modify the get_quantity function in the same way that we modified in_cart? (I don't know how the new in_cart function works, so I have no idea how to modify the get_quantity function so that we can give it to option to check the quantity without attributes). Thanks. Quote Link to comment Share on other sites More sharing options...
tomten Posted June 29, 2006 Share Posted June 29, 2006 I'm beginning to think that we have to modify get_quanitity like we modified in_cart so that the get_quantity calls in ot_together's function calculate_2gether_discount can actually find a quantity of an item with attributes. My guess is this call is using the product id without attributes, and since the attributes are not included, the get_quantity function returns 0. Do you think this is correct? If so, how can I modify the get_quantity function in the same way that we modified in_cart? (I don't know how the new in_cart function works, so I have no idea how to modify the get_quantity function so that we can give it to option to check the quantity without attributes). Thanks. Amanda, I guess I don't need to know what the new in_cart_clean function does. I just modeled its structure and created a get_quantity_clean and changed get_quantity like we changed in_cart, and it appears to work perfectly! You are THE BEST! Thank you so much, and if I happen to run into any issues while I test this thoroughly, I'll be sure to post. Quote Link to comment Share on other sites More sharing options...
trogette Posted July 5, 2006 Share Posted July 5, 2006 Would love to see all the code for this and try to incorporate it with QTPro and Master Products... Quote Link to comment Share on other sites More sharing options...
boxtel Posted July 5, 2006 Author Share Posted July 5, 2006 Amanda, I guess I don't need to know what the new in_cart_clean function does. I just modeled its structure and created a get_quantity_clean and changed get_quantity like we changed in_cart, and it appears to work perfectly! You are THE BEST! Thank you so much, and if I happen to run into any issues while I test this thoroughly, I'll be sure to post. yes, that is correct, the get_quantity function has the same issue as the in_cart function. But test it carefully because in_cart() is pretty straightforward as it either is or is not. quantities might be a little trickier as you can ofcourse have the same product in the cart multiple times with different attributes and you have to make sure that those quantities are correct for the discount. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
bygzee Posted July 27, 2006 Share Posted July 27, 2006 Hi. I was wondering if it was possible to show the total original price it would've cost the customer had he/she purchased these two items seperately right on top of the discount in the product info page. For example: Product A: $100.00 Product B: $200 Original Total Price: $300 Now Only: $250 You Will Save: 17% --------------------------------------------------------------------------- Also, is it possible to only show percentage saved and not dollar amnt (like I displayed above) ? Thank you in advance! Quote Link to comment Share on other sites More sharing options...
boxtel Posted August 3, 2006 Author Share Posted August 3, 2006 Hi. I was wondering if it was possible to show the total original price it would've cost the customer had he/she purchased these two items seperately right on top of the discount in the product info page. For example: Product A: $100.00 Product B: $200 Original Total Price: $300 Now Only: $250 You Will Save: 17% --------------------------------------------------------------------------- Also, is it possible to only show percentage saved and not dollar amnt (like I displayed above) ? Thank you in advance! the code to show the original prices of the individual products is in the module you can simply add them up to show the original total. to show percentages, there are variables in the module : $show_money_savings = true; // show money savings $show_percentage_savings = true; // show percentage savings $show_original_prices = true; // show original prices of the products you can change them at will. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
bygzee Posted August 4, 2006 Share Posted August 4, 2006 (edited) the code to show the original prices of the individual products is in the module you can simply add them up to show the original total. to show percentages, there are variables in the module : $show_money_savings = true; // show money savings $show_percentage_savings = true; // show percentage savings $show_original_prices = true; // show original prices of the products you can change them at will. Thanks. I got it to show only percent saved by changing the amount to false. However, Im having trouble showing the original total price it would've cost on top of the total after savings. I want it to look exactly like this: Product A Product B $100 $200 Original Price = $300 You Pay = $250 Your Savings = 17% Also, how can I make a seperate page showing all the 2gether discounts? I tried what was suggested before but I didn't know how to create a new page. Edited August 4, 2006 by bygzee Quote Link to comment Share on other sites More sharing options...
trogette Posted August 5, 2006 Share Posted August 5, 2006 could the attribute-happy version be posted to the contribution page please? pretty please with a cherry on? Quote Link to comment Share on other sites More sharing options...
Guest Posted August 11, 2006 Share Posted August 11, 2006 Amanda, Tom and you others... I have got so far to add the attributes to the 2gether module. The attributes passes along all the way to checkout_confirmation.php with sucess. HOWEVER the discount doesn't show up. I know Tom had the same problem, but I did not understand what he did. Tom or anyone else, please help me, I can't seem to get further with this. As soon as I get the last information I will put all this forum with attributes together as a module (and ofcourse give Amanda, Tom the credit). thanks so much! Best regards Julian Quote Link to comment Share on other sites More sharing options...
boxtel Posted August 11, 2006 Author Share Posted August 11, 2006 Amanda, Tom and you others... I have got so far to add the attributes to the 2gether module. The attributes passes along all the way to checkout_confirmation.php with sucess. HOWEVER the discount doesn't show up. I know Tom had the same problem, but I did not understand what he did. Tom or anyone else, please help me, I can't seem to get further with this. As soon as I get the last information I will put all this forum with attributes together as a module (and ofcourse give Amanda, Tom the credit). thanks so much! Best regards Julian I think that the person (not remembering who) who implemented the changes can best answer that. I do not use attributes so I have not. The issue is very basic and can be summed up with "how can 2gether discount determine if the products defined for it are in the cart". It uses the standard in_cart function for that but that function simply compares product id's. But when a product has attributes, that product id is never the original one in the cart and onwards. So if you add product 12 to the cart and it has attributes, in the cart the product id becomes 12{2}3 or something like that. In 2gether discount you have product 12 defined. When you use in_cart with product 12 it will not find it because product 12{2}3 is in the cart. So to counter that we created an additional function which determines if product 12 is in the cart regardless of its attributes. That function you should use when using 2gether discount. But in addition to that 2gether also uses the get_quantity function which has the very same behaviour as in_cart. So for that you also have to add the new function as suggested in this thread so it can determine the products quantity in the cart regardless of attributes. Otherwise it will determine that the quantity is zero and then you will also have no discount. So on the one hand this renaming the products id for products with attributes makes sense but it is also a major hangover when trying to handle the cart contents in compares. Basically without these changes you would have to link all possible products id's including their attributes to their counterparts in 2gether discount which is.... not so great. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted August 11, 2006 Share Posted August 11, 2006 Thank you so much Amanda for your reply! I understand that the product ID is changed when the system deals with attributes, but I can't seem to make a code/function that can handle this. It is a function like in_cart that just takes away for example {2}13 from the 12{2}13. So that it "throws away" everything after the 12 (which is an example of the product ID) Am I understanding you right? - Julian P.S. I really do appreciate you have taken the time to make this module and to reply to my post! Quote Link to comment Share on other sites More sharing options...
boxtel Posted August 11, 2006 Author Share Posted August 11, 2006 Thank you so much Amanda for your reply!I understand that the product ID is changed when the system deals with attributes, but I can't seem to make a code/function that can handle this. It is a function like in_cart that just takes away for example {2}13 from the 12{2}13. So that it "throws away" everything after the 12 (which is an example of the product ID) Am I understanding you right? - Julian P.S. I really do appreciate you have taken the time to make this module and to reply to my post! I believe we used these functions in that discussion. function get_quantity_clean($comb_id) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { if ($comb_id == tep_get_prid($products_id)) return $this->contents[$products_id]['qty']; } return 0; } function in_cart_clean($comb_id) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { if ($comb_id == tep_get_prid($products_id)) return true; } return false; } these should be added to the schopping_cart class and while using easy discount you use: in_cart_clean where it says in_cart and get_quantity_clean where it says get_quantity but as I said, I use no attributes so I have not tested it. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Foxtel Posted August 12, 2006 Share Posted August 12, 2006 Amanda, The issue that I'm having is at final checkout when the totals are all added up the tax is taken form the Total and not the Subtotal. Tax rate = 8.75% TAX = $0.94 is taken from the Total 10.70 * 0.0875 = 0.936 ~0.094 The tax should be taken from the Subtotal 8.71 * 0.0875=0.762 (If I can pass the discount of 1.99 to easy discount somehow this should fix my tax issue) To solve my issue I wanted to pass the discount from 2gether to Easy Discount because I have modified ot_easy_discount.php to calculate tax correctly and I also wanted to show the discount in the shopping cart as I do for Volume Discount which uses Easy Discount. Similar as how you show your 2gether discount on your site. Could you please guide me in accomplishing this task? Thank you. Regards, Marizka Quote Link to comment Share on other sites More sharing options...
Foxtel Posted August 12, 2006 Share Posted August 12, 2006 Amanda, The issue that I'm having is at final checkout when the totals are all added up the tax is taken form the Total and not the Subtotal. Tax rate = 8.75% TAX = $0.94 is taken from the Total 10.70 * 0.0875 = 0.936 ~0.094 The tax should be taken from the Subtotal 8.71 * 0.0875=0.762 (If I can pass the discount of 1.99 to easy discount somehow this should fix my tax issue) To solve my issue I wanted to pass the discount from 2gether to Easy Discount because I have modified ot_easy_discount.php to calculate tax correctly and I also wanted to show the discount in the shopping cart as I do for Volume Discount which uses Easy Discount. Similar as how you show your 2gether discount on your site. Could you please guide me in accomplishing this task? Thank you. Regards, Marizka My image did not attache. This was what the image was suppose to show. Total $10.70 Volume Discount $0.00 Your 2gether Discount: 1x(Simple Paths + 10-hour): $-1.99 Sub-Total: $8.71 Tax $0.94 Flat Rate (Best Way): $5.00 Grand Total: $14.65 Regards, Marizka Quote Link to comment Share on other sites More sharing options...
Foxtel Posted August 13, 2006 Share Posted August 13, 2006 Amanda, I was able to fix may tax issue. I just implemented the tax calculation that I have in ot_easy_discount.php to ot_together.php. I would still like to show the 2gether discount in the shopping cart box. (Like you have on your site). How would I accomplish this? Thank you. Regards, Marizka Quote Link to comment Share on other sites More sharing options...
boxtel Posted August 19, 2006 Author Share Posted August 19, 2006 Amanda, I was able to fix may tax issue. I just implemented the tax calculation that I have in ot_easy_discount.php to ot_together.php. I would still like to show the 2gether discount in the shopping cart box. (Like you have on your site). How would I accomplish this? Thank you. Regards, Marizka I use this (focus on 2gether discount but keep the entire structure in mind): <tr> <td> <table width="100%"> <tr> <td align="right" width="85%"><?php echo SUB_TITLE_SUB_TOTAL; ?></td><td align="right"> <?php echo $currencies->format($cart_total); ?> </td> </tr> <?php $new_total = $cart_total; // Category Quantity/Value Breaks Discount if (MODULE_CAT_QVB_DISCOUNT_STATUS) { if (!is_object($cat_qvb_discount)) { include (DIR_WS_MODULES.'order_total/ot_cat_qvb_discount.php'); include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_cat_qvb_discount.php'); $cat_qvb_discount = new ot_cat_qvb_discount; } $cat_deduction = $cat_qvb_discount->display_discounts(); if ($cat_deduction > 0) { $new_total = $new_total - $cat_deduction; } } // Easy Discount if ($easy_discount->count() > 0) { echo $easy_discount->display(); $new_total = $new_total - $easy_discount->total(); } // 2Gether Discount include (DIR_WS_MODULES.'order_total/ot_together.php'); $together = new ot_together; $together_discount = $together->calculate_2gether_discount(); if ($together_discount > 0) { echo '<tr><td align="right"><img src="images/2gether_sm.jpg" border="0" style="vertical-align:middle" alt="2gether discount" title="2gether discount"> Discount:</td><td align="right"><font color="red">-'.$currencies->format($together_discount).'</font></td></tr>'; $new_total = $new_total - $together_discount; } if ($new_total != $cart_total) { if ($new_total == 0) { echo '<tr><td align="right">'.SUB_TITLE_TOTAL.'</td><td align="right">'.FREE_TEXT.'</td></tr>'; } else { echo '<tr><td align="right">'.SUB_TITLE_TOTAL.'</td><td align="right">'.$currencies->format($new_total).'</td></tr>'; } } ?> </table> </td> </tr> Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Foxtel Posted August 20, 2006 Share Posted August 20, 2006 I use this (focus on 2gether discount but keep the entire structure in mind): Amanda, Thank you. Regards, -Marizka Quote Link to comment Share on other sites More sharing options...
Guest Posted August 29, 2006 Share Posted August 29, 2006 Does anyone know where to put the "create the table" and how to exactly write the script? This is basically step 6 inthe install. Thanks Quote Link to comment Share on other sites More sharing options...
user1515 Posted September 5, 2006 Share Posted September 5, 2006 (edited) Amanda, I was able to fix may tax issue. I just implemented the tax calculation that I have in ot_easy_discount.php to ot_together.php. I would still like to show the 2gether discount in the shopping cart box. (Like you have on your site). How would I accomplish this? Thank you. Regards, Marizka Foxtel, Can you tell us how you fixed your tax issue? I am not using "Easy Discount," but the the tax is still calculated BEFORE the discount is taken off, regardeless of which order I set them in. EXAMPLE Product 1: $10 Product 2: $10 ------------------ Subtotal: $20 2Gether DISC: -$5 (New Subtotal): $15 Tax 7%: $1.40 Note: tax on $20, not on the $15 it should be! Total: $16.40 I didn't see a fix for this posted here anywhere... thanks for any help! Edited September 5, 2006 by user1515 Quote Link to comment Share on other sites More sharing options...
Foxtel Posted September 6, 2006 Share Posted September 6, 2006 Foxtel, Can you tell us how you fixed your tax issue? I am not using "Easy Discount," but the the tax is still calculated BEFORE the discount is taken off, regardeless of which order I set them in. EXAMPLE Product 1: $10 Product 2: $10 ------------------ Subtotal: $20 2Gether DISC: -$5 (New Subtotal): $15 Tax 7%: $1.40 Note: tax on $20, not on the $15 it should be! Total: $16.40 I didn't see a fix for this posted here anywhere... thanks for any help! The TAX solution is base on a discussion on the easy discount support forum. I just implement that solution to ot_together.php Here is what I did. In file includes\modules\order_total\ot_together.php make the followig edit to function process(). This is the original function process() without any changes. function process() { global $order, $currencies, $ot_subtotal, $cart, $together_product_names; $od_amount = $this->calculate_2gether_discount(); if ($od_amount > 0) { $this->deduction = $od_amount; $this->output[] = array('title' => sprintf(MODULE_2GETHER_DISCOUNT_FORMATED_TITLE, $together_product_names), 'text' => sprintf(MODULE_2GETHER_DISCOUNT_FORMATED_TEXT, $currencies->format($od_amount)), 'value' => $od_amount); $order->info['total'] -= $this->deduction; if ($this->sort_order < $ot_subtotal->sort_order) $order->info['subtotal'] -= $this->deduction; } } Now, this is function process() with the modifications for TAX. function process() { global $order, $currencies, $ot_subtotal, $cart, $together_product_names; $od_amount = $this->calculate_2gether_discount(); if ($od_amount > 0) { $this->deduction = $od_amount; $this->output[] = array('title' => sprintf(MODULE_2GETHER_DISCOUNT_FORMATED_TITLE, $together_product_names), 'text' => sprintf(MODULE_2GETHER_DISCOUNT_FORMATED_TEXT, $currencies->format($od_amount)), 'value' => $od_amount); /*****START_TAX_CALCULATIONS*****/ $discount_percentage = ($od_amount/$order->info['subtotal']); if ($order->info['tax'] > 0) { $tod_amount = ($order->info['tax'] * $discount_percentage); reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $god_amount = $value * $discount_percentage; $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; } } $order->info['total'] -= $order->info['tax']; $order->info['tax'] -= $tod_amount; $order->info['total'] = ($order->info['total'] - $od_amount) + $order->info['tax']; /*****END_TAX_CALCULATIONS*****/ if ($this->sort_order < $ot_subtotal->sort_order) $order->info['subtotal'] -= $this->deduction; } } I use easy discount to pass all my discounts and use that tax calculation code to take care of any taxes. The same concept that I use for easy discount should work with the function process() in includes\modules\order_total\ot_together.php -Marizka Quote Link to comment Share on other sites More sharing options...
user1515 Posted September 6, 2006 Share Posted September 6, 2006 Thank you, thank you!! -fritz Quote Link to comment Share on other sites More sharing options...
100asa Posted September 19, 2006 Share Posted September 19, 2006 Is it possible have have a suggestion to made a infobox with link to 2gether products? Thank's Quote Skype: centoasa Skype: remigioruberto Link to comment Share on other sites More sharing options...
niviche Posted September 24, 2006 Share Posted September 24, 2006 The TAX solution is base on a discussion on the easy discount support forum. I just implement that solution to ot_together.phpHere is what I did. I applied this modification, but saw that the total price of orders in my store were totally wrong if I had chosen to display the prices with taxes (the "Display Prices with Tax" set to "true" in Configuration -> My Store). Moreover, I was wondering whether the discount amount entered by this contribution was an amount including taxes, or without them. Here is an example that shows the problem: Situation: I have two products: product A: 6.90 Euro (without tax) or 8.00 Euro (with tax) product B: 10.78 Euro (with tax) or 12.50 Euro (with tax) my tax rate is 16% in the admin section, I gave a discount of 5.00 Euro if both products are bought together. buying both products together should bring the following total prices: -15.50 Euro if the discount includes the tax (8+12.50-5) -14.71 Euro if the discount does not include the tax [(6.90 + 10.78 - 5) x 1.16] Case 1: prices are displayed without tax 1 x product A: 6.90 Euro 1 x product B: 10.78 Euro discount: -5 Euro 16% VAT: 2.03 Euro (correct if the discount is 5.00 + tax) Total: 14.71 - > correct: (6.90 + 10.78 - 5) x 1.16 = 14.71 Conclusion: if the prices are displayed without tax, the total is correct. In this case, the discount amount is also without tax. Case 2: prices are displayed with tax 1 x product A: 8.00 Euro 1 x product B: 12.50 Euro discount: -5.00 Euro 16% VAT: 2.14 Euro (correct if the discount is 5.00 including tax) Total: 14.81 Euro (wrong, the total should be 15.50 Euro including tax, or 13.36 without tax) The problem: the tax here is taken on this amount with tax: (price A with tax) + (price B with tax) - (discount taken as with tax): 8 + 12.50-5 = 15.50 16% tax on 15.50 is 2.14 however, when the tax is added to the subtotal, it is added to (price A without tax) + (price B without tax) - (discount taken as without tax) 6.90 + 10.78 - 5 = 12.68 12.68 + 2.14 = 14.82 -> the wrong total The problem here is that the price before tax is calculated with a discount without tax [(price A without tax) + (price B without tax) - (discount taken as without tax)], BUT the taxes are calculated with discount including tax. Therefore, there is a discrepancy of the amount of tax on the discount. If you chose to display the prices with tax in your site, your total is going to be off of the tax amount on the discount. In order to solve this problem: the discount must be used either as including tax, or as without it, but not both. I do not know how osCommerce calculates the taxes (on each item or on the total), and I am a total PhP newbie, but can somebody help to reorganize the calculation of the price? With this problem, this contribution is totally useless... Quote Quick stock update from the product listing page | Customers Drop Down In Orders List Link to comment Share on other sites More sharing options...
boxtel Posted September 24, 2006 Author Share Posted September 24, 2006 I applied this modification, but saw that the total price of orders in my store were totally wrong if I had chosen to display the prices with taxes (the "Display Prices with Tax" set to "true" in Configuration -> My Store). Moreover, I was wondering whether the discount amount entered by this contribution was an amount including taxes, or without them. Here is an example that shows the problem: Situation: I have two products: product A: 6.90 Euro (without tax) or 8.00 Euro (with tax) product B: 10.78 Euro (with tax) or 12.50 Euro (with tax) my tax rate is 16% in the admin section, I gave a discount of 5.00 Euro if both products are bought together. buying both products together should bring the following total prices: -15.50 Euro if the discount includes the tax (8+12.50-5) -14.71 Euro if the discount does not include the tax [(6.90 + 10.78 - 5) x 1.16] Case 1: prices are displayed without tax 1 x product A: 6.90 Euro 1 x product B: 10.78 Euro discount: -5 Euro 16% VAT: 2.03 Euro (correct if the discount is 5.00 + tax) Total: 14.71 - > correct: (6.90 + 10.78 - 5) x 1.16 = 14.71 Conclusion: if the prices are displayed without tax, the total is correct. In this case, the discount amount is also without tax. Case 2: prices are displayed with tax 1 x product A: 8.00 Euro 1 x product B: 12.50 Euro discount: -5.00 Euro 16% VAT: 2.14 Euro (correct if the discount is 5.00 including tax) Total: 14.81 Euro (wrong, the total should be 15.50 Euro including tax, or 13.36 without tax) The problem: the tax here is taken on this amount with tax: (price A with tax) + (price B with tax) - (discount taken as with tax): 8 + 12.50-5 = 15.50 16% tax on 15.50 is 2.14 however, when the tax is added to the subtotal, it is added to (price A without tax) + (price B without tax) - (discount taken as without tax) 6.90 + 10.78 - 5 = 12.68 12.68 + 2.14 = 14.82 -> the wrong total The problem here is that the price before tax is calculated with a discount without tax [(price A without tax) + (price B without tax) - (discount taken as without tax)], BUT the taxes are calculated with discount including tax. Therefore, there is a discrepancy of the amount of tax on the discount. If you chose to display the prices with tax in your site, your total is going to be off of the tax amount on the discount. In order to solve this problem: the discount must be used either as including tax, or as without it, but not both. I do not know how osCommerce calculates the taxes (on each item or on the total), and I am a total PhP newbie, but can somebody help to reorganize the calculation of the price? With this problem, this contribution is totally useless... With this problem, this contribution is totally useless... suggest you write your own. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
niviche Posted September 24, 2006 Share Posted September 24, 2006 sorry if I am thinking loud here, I am just trying to see how to fix this problem... Actually, the same problem happens with the box displayed on Product_info: It doesn't matter whether you display the prices with or without taxes, the saved amount is still the same. This means that you give a bigger rebate to the people buying outside of the tax zone. Argh. Quote Quick stock update from the product listing page | Customers Drop Down In Orders List 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.