boxtel Posted March 5, 2006 Author Share Posted March 5, 2006 The contrib is here contrib 204 price sensitve discountsthis is an old one but works well for setting % discounts based on set prices - ie spend 200 and get 5% spend 400 get 10% off. I like the easy discount because of the messages you can set in the shopping cart (but you cannot turn them off if you turn off the module in admin - not really an issue though). although for another shop site i am using your category contrib - have questions ! will post in that thread. you can easily enclose the logic in : if (MODULE_EASY_DISCOUNT_STATUS == 'true') { } to turn it off if the module is not active. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
varnco Posted March 5, 2006 Share Posted March 5, 2006 Got it up and running, but I can't for the life of me figure out how to change the formatting, so the discounts show up correctly. did I perhaps add the function to the wrong location on the shopping_cart.php page? Quote Link to comment Share on other sites More sharing options...
varnco Posted March 5, 2006 Share Posted March 5, 2006 Got it up and running, but I can't for the life of me figure out how to change the formatting, so the discounts show up correctly. did I perhaps add the function to the wrong location on the shopping_cart.php page? Okay, got it working, so everything is lined up, so it looks great. i had to take out an extra </td></tr> in shopping_cart.php and in easy_discount under the functions folder, and added in the proper size class. However, the discount isn't being followed through to the checkoutprocess... the discount is getting lost when I log in.... I'll search and see if someone else had the same issue. Quote Link to comment Share on other sites More sharing options...
varnco Posted March 5, 2006 Share Posted March 5, 2006 Okay, I fixed the discount not showing on checkout confirmation page by chaning the order at which the details display. Works great. Has anyone figured out how to apply the discount so the tax calculation is done after the discount is given. I have the discount bofore tax is calculated, but that doesn't matter... it still calulates the tax based on the total, before the discount is applied. I know someone else had this issue (does no one else charge tax for same-state orders?)... Thanks.. great contribution, BTW. CCGV seemed too complex. Quote Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 just got mine to work too :) simply amazing, this does everything i wanted from ccgv without all of the install labor just 1 more question: i use points & rewards to give "credit" to the customer's future order once their items are shipped: http://www.oscommerce.com/community/contri...,points+rewards but they both work together (so the user can get TWO discounts at the same time)... if the customer as discount points available (more than 0.00) in their account, is it possible to hide the discount code box? Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 6, 2006 Author Share Posted March 6, 2006 just got mine to work too :) simply amazing, this does everything i wanted from ccgv without all of the install labor just 1 more question: i use points & rewards to give "credit" to the customer's future order once their items are shipped: http://www.oscommerce.com/community/contri...,points+rewards but they both work together (so the user can get TWO discounts at the same time)... if the customer as discount points available (more than 0.00) in their account, is it possible to hide the discount code box? just like not showing the box if the module is not active: if (MODULE_EASY_DISCOUNT_STATUS == 'true') { box here } you can extend that condition with virually anything. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 i want to keep both of them enabled though, is it possible to set it in a similar fashion to the if ($cart->count_contents() > 0) { function? there's a table in the "customers" database called "customers_shopping_points" and the default value is 0.00 (no points), would i be able to make use of something like ($cart->count_contents() > 0.00) ? if so, would i need to make a separate call to the customers table to grab that info for the account that's logged in? i'm just not sure how to work the if ($cart->count_contents() > 0) to work with what i need it to do Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 6, 2006 Author Share Posted March 6, 2006 i want to keep both of them enabled though, is it possible to set it in a similar fashion to the if ($cart->count_contents() > 0) { function? there's a table in the "customers" database called "customers_shopping_points" and the default value is 0.00 (no points), would i be able to make use of something like ($cart->count_contents() > 0.00) ? if so, would i need to make a separate call to the customers table to grab that info for the account that's logged in? i'm just not sure how to work the if ($cart->count_contents() > 0) to work with what i need it to do I did not mean for you to disable the modules, just an example as to how you can conditionally display or not display the discount box. You can either do a call to the customer table just before the code to determine the points amount or (what I would do) you can add the customers_shopping_points field to your select query of customer information when the customer signs in (that query is done anyway so why not pick that field as well at that time) and register that value as a session variable. It will then be available at all times during the session. you can then use the condition: if (MODULE_EASY_DISCOUNT_STATUS == 'true') { // easy discount module enabled if ($customers_shopping_points == 0) { // no discount points for this customer box here // show the discount box } } assuming that customers_shopping_points is your session variable name. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 please tell me what i did wrong here, i got the error: Parse error: parse error, unexpected '<' in /home/**/public_html/account.php on line 309 (line 309 is bold) <?php $check_points_query = tep_db_query("select customers_shopping_points from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$cID . "'"); if (MODULE_EASY_DISCOUNT_STATUS == 'true') { // easy discount module enabled if ($customers_shopping_points == 0) { // no discount points for this customer <td class="main"> <?php echo tep_draw_form('Coupon', tep_href_link(basename($PHP_SELF), '', 'SSL')); ?> <table cellpadding="2" cellspacing="2"> <tr> <td valign="top" align="left" class="main"><?php echo 'Coupon Code'; ?><br><?php echo tep_draw_input_field('coupon_code', '', ' size="30"'); ?><br> <?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td> </tr> </table> } } ?> Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 6, 2006 Author Share Posted March 6, 2006 please tell me what i did wrong here, i got the error: Parse error: parse error, unexpected '<' in /home/**/public_html/account.php on line 309 (line 309 is bold) if (MODULE_EASY_DISCOUNT_STATUS == 'true') { // easy discount module enabled if ($customers_shopping_points == 0) { // no discount points for this customer ?> <td class="main"> close php tag ?> if you wish to proceed with plain html (php does not understand that). Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 :blush: thank you, i did not know that (been learning all of my php from the forums bit by bit) now i have: <?php$check_points_query = tep_db_query("select customers_shopping_points from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$cID . "'"); if (MODULE_EASY_DISCOUNT_STATUS == 'true') { // easy discount module enabled if ($customers_shopping_points == 0) { // no discount points for this customer ?> <td class="main"> <?php echo tep_draw_form('Coupon', tep_href_link(basename($PHP_SELF), '', 'SSL')); ?> <table cellpadding="2" cellspacing="2"> <tr> <td valign="top" align="left" class="main"><?php echo 'Coupon Code'; ?><br><?php echo tep_draw_input_field('coupon_code', '', ' size="30"'); ?><br> <?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td> </tr> </table> <? } } ?> how can i get this to hide the discount box and/or show something like "Use your credit / discount points before using coupons" Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 6, 2006 Author Share Posted March 6, 2006 :blush: thank you, i did not know that (been learning all of my php from the forums bit by bit) now i have: how can i get this to hide the discount box and/or show something like "Use your credit / discount points before using coupons" <?php $check_points_query = tep_db_query("select customers_shopping_points from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$cID . "'"); $shopping_points_result = tep_db_fetch_array($check_points_query); $customers_shopping_points = $shopping_points_result['customers_shopping_points']; if (MODULE_EASY_DISCOUNT_STATUS == 'true') { // easy discount module enabled if ($customers_shopping_points == 0) { // no discount points for this customer echo '<td class="main">' . tep_draw_form('Coupon', tep_href_link(basename($PHP_SELF), '', 'SSL')); ?> <table cellpadding="2" cellspacing="2"> <tr> <td valign="top" align="left" class="main"><?php echo 'Coupon Code'; ?><br><?php echo tep_draw_input_field('coupon_code', '', ' size="30"'); ?><br> <?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td> </tr> </table> </td> <?php } else { echo '<td><table<tr><td>Use your credit / discount points before using coupons</td></tr></table></td>'; } } ?> ofcourse the message is somewhat trivial because if the points are > 0 they will not see the discount box so they will have no clue as to what you are talking about. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 (edited) thank you so much, that works :) however, i forgot that points usually range between 1.00 and 100.00; so is it possible to make something like if ($customers_shopping_points > 100.00 ? (i tried it, but no matter what point value i use: 500.00, 1000.00 it still tells me to use my points) (at present, i have 100.00 in my test account) ofcourse the message is somewhat trivial because if the points are > 0 they will not see the discount box so they will have no clue as to what you are talking about.i plan to word it more in-depth, i just used that as an example :) Edited March 6, 2006 by eww Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 6, 2006 Author Share Posted March 6, 2006 thank you so much, that works :) however, i forgot that points usually range between 1.00 and 100.00; so is it possible to make something like if ($customers_shopping_points > 100.00 ? (i tried it, but no matter what point value i use: 500.00, 1000.00 it still tells me to use my points) (at present, i have 100.00 in my test account) i plan to word it more in-depth, i just used that as an example :) if they range between 1 and 100 then ($customers_shopping_points > 100.00) would never become true. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 (edited) they're all in dollar digits, so the minimum is 0.00 (default) and run on a 5% incriment (0.05, etc), still not possible? Edited March 6, 2006 by eww Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 6, 2006 Author Share Posted March 6, 2006 they're all in dollar digits, so the minimum is 0.00 (default) and run on a 5% incriment (0.05, etc), still not possible? its always possible. if your current points are 100.00 use something like : if ($customers_shopping_points < 100) { means display the box if points below 100 if (($customers_shopping_points >= 0) and ($customers_shopping_points <= 500)) { means display box if point larger or equal to zero and smaller or equal to 500 if (($customers_shopping_points <= 100) or ($customers_shopping_points >= 500)) { means display box if point smaller or equal to 100 or larger or equal to 500 no limits to the possible conditions Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 do the decimals interfere with the calculation perhaps? no matter which method i try, it doesn't seem to change. Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 6, 2006 Author Share Posted March 6, 2006 do the decimals interfere with the calculation perhaps? no matter which method i try, it doesn't seem to change. no, just put this: echo 'The points are:'.$customers_shopping_points; before this code: if (MODULE_EASY_DISCOUNT_STATUS == 'true') { // easy discount module enabled so you can see what the points are. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
maniac101 Posted March 6, 2006 Share Posted March 6, 2006 you can easily enclose the logic in : if (MODULE_EASY_DISCOUNT_STATUS == 'true') { } to turn it off if the module is not active. cool thanks that works fine. Quote Regards Mark Brindle Link to comment Share on other sites More sharing options...
varnco Posted March 6, 2006 Share Posted March 6, 2006 Hi Amanda,thansk for info. I managed to get the tax calculation working using a bit of code from ot_lev_discount. i had to remove some rounding as that gave me incorrect tax value. The code below is the function 'process' in modules\orders_total\ot_easy_discount.php: function process() { // add global discount_percentage maniac101 global $discount_percentage, $order, $currencies, $ot_subtotal, $cart, $easy_discount; $od_amount = 0; $tod_amount = 0; if ($easy_discount->count() > 0) { $easy_discounts = $easy_discount->get_all(); $n = sizeof($easy_discounts); for ($i=0;$i < $n; $i++) { // mod for allowing text to display without zero value maniac101 if ($easy_discounts[$i]['amount'] > 0) { $this->output[] = array('title' => $easy_discounts[$i]['description'], 'text' => ': <font color="red">- ' . $currencies->format($easy_discounts[$i]['amount']).'</font>', 'value' => $easy_discounts[$i]['amount']); } else { $this->output[] = array('title' => $easy_discounts[$i]['description'], 'text' => '', 'value' => $easy_discounts[$i]['amount']); } // end mod for discount text only when setting discount value to zero $od_amount = $od_amount + $easy_discounts[$i]['amount']; } $this->deduction = $od_amount; // tax calculation based on percentage_discount from ot_lev_discount removed rounding 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; } } // end tax calc $order->info['tax'] = $order->info['tax'] - $tod_amount; $order->info['total'] = $order->info['total'] - $od_amount; if ($this->sort_order < $ot_subtotal->sort_order) $order->info['subtotal'] = $order->info['subtotal'] - $od_amount; } } This uses a new $discount_percentage which I set in application_top.php at the moment based on my rules. This works perfectly for me now . Maniac, Are you saying the above coding works so the discount is calculated before taxes are calculated? I'm thinking the OSC charges taxes based on the items individually rather than on the sub total, which I believe is the problem why easy discount can't discount the taxes. Quote Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 no, just put this: echo 'The points are:'.$customers_shopping_points; before this code: if (MODULE_EASY_DISCOUNT_STATUS == 'true') { // easy discount module enabled so you can see what the points are. that's odd! the points don't display! maybe this is why i've had such a hard time hiding the box from those that have points. what could i have done wrong? it just shows: "The points are:" Quote Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 I tried the install once and got lost so I used my backup file to restore my site and am starting from scratch. I had someone build my site and I'm trying to save money by installing the Easy Discount myself. For the application_top.php file, do I change the one in the admin/includes folder or just the includes folder? Can someone explain what the difference is? Quote Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 installation is a little too simple.. it stumped me first too, because most contributions take an average of 15-20 mins... once i actually figured it out, installation was about 1 minute for the application_top edit, it's in your catalog folder - not admin. the difference is the catalog application_top is used for all of the global functions in your catalog... the admin one is for all global edits in the admin area Quote Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 installation is a little too simple.. it stumped me first too, because most contributions take an average of 15-20 mins... once i actually figured it out, installation was about 1 minutefor the application_top edit, it's in your catalog folder - not admin. the difference is the catalog application_top is used for all of the global functions in your catalog... the admin one is for all global edits in the admin area ahh, thank you. This is the first time I've done a contribution so I'm a little nervous and lost. I'm sure I'll be posting more questions before I finish. Quote Link to comment Share on other sites More sharing options...
Guest Posted March 7, 2006 Share Posted March 7, 2006 if ($cart->count_contents() > 0) { // cart contents $easy_discount->add('OST','10% discount of Sub Total',$cart->show_total()*0.1); // 10% of cart total } else{ $easy_discount->remove_type('OST'); // remove discount if present and cart gets empty } you can put this in application_top. you can also use the order object to calculate the discount but then you cannot set it before going to checkout because the object will not exist until then. Where in application_top do I put this? I want to offer the same discount. -Rochelle 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.