yummy_tummy6 Posted May 6, 2006 Share Posted May 6, 2006 Okay I got the thing to work finally... perhaps an easy lame-mans manual might be handy?? If I was fluent enough in what I just did to get it to work I would write one.... LOL! But I do have two more questions.... Swear they should be my last.... I used Elementdirects promo code with the easy discount. But after I log out and then log back in... even if it in another account. The discount code is already in the form field from the previous use. So... how can this be prevented? Second... While testing in Firefox the code works but in IE it doesn't since almost all my customers will be using IE I need it to work What is the possible reason for it..... Im off to reinstall IE just in case it is my browser. Thanks. Quote Link to comment Share on other sites More sharing options...
radders Posted May 6, 2006 Share Posted May 6, 2006 Did you remember to unregister the variable in logoff.php? Quote Link to comment Share on other sites More sharing options...
Guest Posted May 8, 2006 Share Posted May 8, 2006 Hi All, I am another newbie trying to get this working I'm afraid. Any help would be greatly appreciated as I'm not very technical. I have installed Easy Discount Version2 (to the best of my ability). I am trying to implement a discount when the customer enters a Code into a box. From some of the earlier posts in this thread I have got the code for the shopping cart, the input box and the button to calculate the discount. These are now displaying on my shopping_cart.php but when I enter the Discount Code and click the button, the page does a postback but nothing else happens. No discount amount appears, no errors - nothing!! This is what I have done: Step 1: Added the files to their relevant directories. Step 2: In application_top.php after : // include shopping cart class require(DIR_WS_CLASSES . 'shopping_cart.php'); added: // include easy discount products class require(DIR_WS_CLASSES . 'easy_discount.php'); after: // include currencies class and create an instance require(DIR_WS_CLASSES . 'currencies.php'); $currencies = new currencies(); added: if (!tep_session_is_registered('easy_discount')) { tep_session_register('easy_discount'); $easy_discount = new easy_discount(); } Step 3: Added "Easy Discount" in my admin modules->order totals. Step 4: Added the following code to shopping_cart_php after "require("includes/application_top.php");" include_once (DIR_WS_FUNCTIONS. 'easy_discount.php'); if (MODULE_EASY_DISCOUNT_STATUS == 'true') { if ((isset($_POST['coupon_code'])) and ($_POST['coupon_code'] != '')) { $coupon_code = $_POST['coupon_code']; if (!tep_session_is_registered('coupon_code')) tep_session_register('coupon_code'); } if ($cart->count_contents() > 0) { switch (strtolower($coupon_code)) { case 'osc' : $new_discount = $cart->show_total() * 0.01; $easy_discount->set('COUPON1','1% OSC Coupon Discount', $new_discount); break; case 'xxx' : $easy_discount->reset(); break; default : if (isset($_POST['coupon_code'])) $systemMessage = 'Unknown Coupon Code: '.$coupon_code ; $coupon_code = ''; } } else { $easy_discount->reset(); } } Step 5: Added the following code at the bottom of shopping_cart.php <tr> <td width="100%" align="center"> <?php echo tep_draw_form('Coupon', tep_href_link(basename($PHP_SELF), '', 'NONSSL')); ?> <table> <tr> <td valign="top" align="center"><?php echo 'Coupon Code'; ?><br><?php echo tep_draw_input_field('coupon_code', '', ' size="30" class="inputbox" '); ?><br><?php echo tep_hide_session_id() . tep_image_submit('button_cash_in.gif', 'Cash in Coupon'); ?></td> </tr> </table> </form> </td> </tr> Step 6: Seek help!!! That is all I have done. Should this be working? Do I need to do anything else? In the instructions for Easy Discount at says to add $easy_discount to your global variable definitions. Is this what I'm missing? Where do I do this? Thank you in advance!! Feeefeee Quote Link to comment Share on other sites More sharing options...
boxtel Posted May 8, 2006 Author Share Posted May 8, 2006 Hi All, I am another newbie trying to get this working I'm afraid. Any help would be greatly appreciated as I'm not very technical. I have installed Easy Discount Version2 (to the best of my ability). I am trying to implement a discount when the customer enters a Code into a box. From some of the earlier posts in this thread I have got the code for the shopping cart, the input box and the button to calculate the discount. These are now displaying on my shopping_cart.php but when I enter the Discount Code and click the button, the page does a postback but nothing else happens. No discount amount appears, no errors - nothing!! This is what I have done: Step 1: Added the files to their relevant directories. Step 2: In application_top.php after : // include shopping cart class require(DIR_WS_CLASSES . 'shopping_cart.php'); added: // include easy discount products class require(DIR_WS_CLASSES . 'easy_discount.php'); after: // include currencies class and create an instance require(DIR_WS_CLASSES . 'currencies.php'); $currencies = new currencies(); added: if (!tep_session_is_registered('easy_discount')) { tep_session_register('easy_discount'); $easy_discount = new easy_discount(); } Step 3: Added "Easy Discount" in my admin modules->order totals. Step 4: Added the following code to shopping_cart_php after "require("includes/application_top.php");" include_once (DIR_WS_FUNCTIONS. 'easy_discount.php'); if (MODULE_EASY_DISCOUNT_STATUS == 'true') { if ((isset($_POST['coupon_code'])) and ($_POST['coupon_code'] != '')) { $coupon_code = $_POST['coupon_code']; if (!tep_session_is_registered('coupon_code')) tep_session_register('coupon_code'); } if ($cart->count_contents() > 0) { switch (strtolower($coupon_code)) { case 'osc' : $new_discount = $cart->show_total() * 0.01; $easy_discount->set('COUPON1','1% OSC Coupon Discount', $new_discount); break; case 'xxx' : $easy_discount->reset(); break; default : if (isset($_POST['coupon_code'])) $systemMessage = 'Unknown Coupon Code: '.$coupon_code ; $coupon_code = ''; } } else { $easy_discount->reset(); } } Step 5: Added the following code at the bottom of shopping_cart.php <tr> <td width="100%" align="center"> <?php echo tep_draw_form('Coupon', tep_href_link(basename($PHP_SELF), '', 'NONSSL')); ?> <table> <tr> <td valign="top" align="center"><?php echo 'Coupon Code'; ?><br><?php echo tep_draw_input_field('coupon_code', '', ' size="30" class="inputbox" '); ?><br><?php echo tep_hide_session_id() . tep_image_submit('button_cash_in.gif', 'Cash in Coupon'); ?></td> </tr> </table> </form> </td> </tr> Step 6: Seek help!!! That is all I have done. Should this be working? Do I need to do anything else? In the instructions for Easy Discount at says to add $easy_discount to your global variable definitions. Is this what I'm missing? Where do I do this? Thank you in advance!! Feeefeee the instruction says "if you want to use $easy_discount in a function....." like : my_function () { $easy_discount->add(......... } then you have to add the session variable in the global definition of the function as in: my_function () { global $easy_discount; $easy_discount->add(......... } otherwise the function cannot access that variable. Should this be working? Do I need to do anything else? well, does it? Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted May 8, 2006 Share Posted May 8, 2006 Thanks for replying!! Sorry but I still don't understand. I have just copied all your code from the instructions and from other posts. I don't really have much idea what I'm doing. Do I have a function where I need to declare this???? If so, can you advise where this is? Or am I meant to create this? No, it's not working. The button and box display, but nothing happens when the button is clicked. Quote Link to comment Share on other sites More sharing options...
boxtel Posted May 8, 2006 Author Share Posted May 8, 2006 Thanks for replying!! Sorry but I still don't understand. I have just copied all your code from the instructions and from other posts. I don't really have much idea what I'm doing. Do I have a function where I need to declare this???? If so, can you advise where this is? Or am I meant to create this? No, it's not working. The button and box display, but nothing happens when the button is clicked. no, forget the function part, that is for developers who wish to use $easy_discount in their own functions. You see, easy discount is a general discount basket and as such can be used for any discount you like without having to install additional order total modules etc. But it is default not a coupon discount facility. The conditions and discount calculations are not part of the facility. however, did you make sure you put that box code OUTSIDE any existing form ? Do you see any </form> after the box code you inserted? Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted May 8, 2006 Share Posted May 8, 2006 Do you see any </form> after the box code you inserted? Yes it was inside the form. I have now moved it outside, but it still doesn't work. This is now the code at the botton of my shopping_cart.php <?php } ?> </table></form></td> <tr> <td width="100%" align="center"> <?php echo tep_draw_form('Coupon', tep_href_link(basename($PHP_SELF), '', 'NONSSL')); ?> <table> <tr> <td valign="top" align="center"><?php echo 'Coupon Code'; ?><br><?php echo tep_draw_input_field('coupon_code', '', ' size="30" class="inputbox" '); ?><br><?php echo tep_hide_session_id() . tep_image_submit('button_cash_in.gif', 'Cash in Coupon'); ?></td> </tr> </table> </form> </td> </tr> <!-- body_text_eof //--> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> </table></td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> The actual code to make it work is COUPON1, right? Any other advice welcome please!! Quote Link to comment Share on other sites More sharing options...
boxtel Posted May 8, 2006 Author Share Posted May 8, 2006 Yes it was inside the form. I have now moved it outside, but it still doesn't work. This is now the code at the botton of my shopping_cart.php <?php } ?> </table></form></td> <tr> <td width="100%" align="center"> <?php echo tep_draw_form('Coupon', tep_href_link(basename($PHP_SELF), '', 'NONSSL')); ?> <table> <tr> <td valign="top" align="center"><?php echo 'Coupon Code'; ?><br><?php echo tep_draw_input_field('coupon_code', '', ' size="30" class="inputbox" '); ?><br><?php echo tep_hide_session_id() . tep_image_submit('button_cash_in.gif', 'Cash in Coupon'); ?></td> </tr> </table> </form> </td> </tr> <!-- body_text_eof //--> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> </table></td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> The actual code to make it work is COUPON1, right? Any other advice welcome please!! COUPON1 is just the name of that particular discount entry. You can name it whatever you like. Discounts with the same name overwrite eachother, discounts with different names can co-exist. the codes to be entered by the customer is: case 'osc' : .... so the customer enters "osc" or "OSC" or "Osc" or.. you can also set that to whatever you like. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted May 8, 2006 Share Posted May 8, 2006 OK it's working now!!!!! Thank you so much for all your help. I really appreciate it. Quote Link to comment Share on other sites More sharing options...
yummy_tummy6 Posted May 8, 2006 Share Posted May 8, 2006 Did you remember to unregister the variable in logoff.php? Could you explain a wee bit more?? Im awsome at HTML just not at PHP....LOL Thank you.... Quote Link to comment Share on other sites More sharing options...
itdeal Posted May 8, 2006 Share Posted May 8, 2006 Sorry people, I'm not used to this forum's posting rules, so please forgive me for *bumping* my earlier question... Hello people, I'm currently working on a website where I thankfully use the Easy Discount contribution to give discount for specific products on specific days. I also have free shipping enabled when the order total is more than ? xxx. Problem is, I can't get the discount to be subtracted from the order total BEFORE the code start to calculate what the shipping costs are (or even free shipping if the amount is large enough). Clear example: Product list price ? 10. Normal shipping for orders below ? 10 is ?1, anything over ? 10 is free shipping When I give a discount of, say, ?2, the end total will be ?8. So, no free shipping. But what happens now is that the code keeps looking at the product list price and doesn't take the discount into account, hence the shipping will be free because the total is seen as ?10. I want the shipping costs to be calculated AFTER processing the discounts. Any hints where and how to do this? Quote Link to comment Share on other sites More sharing options...
boxtel Posted May 9, 2006 Author Share Posted May 9, 2006 Sorry people, I'm not used to this forum's posting rules, so please forgive me for *bumping* my earlier question... well, you seem to know the rules so not being used to them is a pittyful argument. anyway, easy discount does take shipping in account if you set your sort order right. the exception is free shipping as that is done separately in several files. that implementation looks at the order total of the order object and compares it with your free shipping settings. You will have to incorporate easy discount totals into those calculations. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted May 11, 2006 Share Posted May 11, 2006 Hi, Easy discount is working well for me, but I just can't seem to format the font of the actual discount row. It ends up looking a bit like this, with a different font and no bold. Sub-Total: $164.90 20% Coupon Discount: - $32.98 Total: $131.92 This is the code in my shoppint_cart.php. So, the Total row looks right but I don't know how to format what is returned by the function. <?php if ($easy_discount->count() > 0) { echo easy_discount_display(); echo '<tr><td align="right"class="main"><b>'.SUB_TITLE_TOTAL.'</b></td><td align="right"class="main"><b>'.$currencies->format(($cart->show_total() - $easy_discount->total())).'</b></td></tr>'; } ?> Thanks in advance for any help!! Quote Link to comment Share on other sites More sharing options...
boxtel Posted May 11, 2006 Author Share Posted May 11, 2006 Hi, Easy discount is working well for me, but I just can't seem to format the font of the actual discount row. It ends up looking a bit like this, with a different font and no bold. Sub-Total: $164.90 20% Coupon Discount: - $32.98 Total: $131.92 This is the code in my shoppint_cart.php. So, the Total row looks right but I don't know how to format what is returned by the function. <?php if ($easy_discount->count() > 0) { echo easy_discount_display(); echo '<tr><td align="right"class="main"><b>'.SUB_TITLE_TOTAL.'</b></td><td align="right"class="main"><b>'.$currencies->format(($cart->show_total() - $easy_discount->total())).'</b></td></tr>'; } ?> Thanks in advance for any help!! in the function itself: $discount .= '<tr><td align="right">'.$easy_discounts[$i]['description'].':</td><td align="right"><font color="red">- ' . $currencies->format($easy_discounts[$i]['amount']).'</font></td></tr>'; you can add the formatting there. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted May 12, 2006 Share Posted May 12, 2006 boxtel, sorry to bug you again but if you have an extra moment, can you let me know what i'm doing wrong with your variation: http://www.oscommerce.com/forums/index.php?act...ndpost&p=856745 Quote Link to comment Share on other sites More sharing options...
Guest Posted May 15, 2006 Share Posted May 15, 2006 Hi Just wanting to find out. I have added all is required in the install txt I have also added on the bottom of my application_top this include (DIR_WS_MODULES.'easy_coupons_code.php'); 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 } which should give a 10 % discount for people that put there coupon code in.. I am getting a little mixed up because i thought u can set this in your administrator area. If you manually give people a discount code ? I tried this from Boxtel's ealier post for someone and it didnt work I typed in the code i manually put in the adminiistrator area in.. and in the shopping cart after clicking cash in coupon.. nothing.. it just went back to the shopping cart with no discount or anything.. I have no idea what im doing wrong please help me out thanks greg Quote Link to comment Share on other sites More sharing options...
boxtel Posted May 15, 2006 Author Share Posted May 15, 2006 Hi Just wanting to find out. I have added all is required in the install txt I have also added on the bottom of my application_top this include (DIR_WS_MODULES.'easy_coupons_code.php'); 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 } which should give a 10 % discount for people that put there coupon code in.. I am getting a little mixed up because i thought u can set this in your administrator area. If you manually give people a discount code ? I tried this from Boxtel's ealier post for someone and it didnt work I typed in the code i manually put in the adminiistrator area in.. and in the shopping cart after clicking cash in coupon.. nothing.. it just went back to the shopping cart with no discount or anything.. I have no idea what im doing wrong please help me out thanks greg looks like you installed easy coupons and still have an old version of easy discount running. I specifically released easy coupons so I would not have to support all these coupon implementations on easy discount in this thread. So first upgrade easy discount and then post problems with easy coupons in that contribution's support thread. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
rdbello Posted May 16, 2006 Share Posted May 16, 2006 (edited) I don't know how could I set some discounts with Easy Discount (for example: if you buy 2 products I 'll give to you 5% - If you buy 3, give you 10% - if 4 = 15% and 5=20%). I'm not a programmer, so I need some details like what I've to write (script) and where. Other doubt: i'm using the Order editor. Is it a problem? Thanks so much. Edited May 16, 2006 by rdbello Quote Link to comment Share on other sites More sharing options...
boxtel Posted May 17, 2006 Author Share Posted May 17, 2006 I don't know how could I set some discounts with Easy Discount (for example: if you buy 2 products I 'll give to you 5% - If you buy 3, give you 10% - if 4 = 15% and 5=20%). I'm not a programmer, so I need some details like what I've to write (script) and where. Other doubt: i'm using the Order editor. Is it a problem? Thanks so much. you could use something like: $incart = $cart->count_contents(); // number of items in the cart if ($incart > 0) $cart_total = $cart->show_total(); // value of items in cart if ($incart < 1) $easy_discount->clear('QTYDSC'); // clear this discount if cart empty elseif ($incart > 1) $easy_discount->set('QTYDSC', 'Qty Discount of 5%', $cart_total*0.05); elseif ($incart > 3) $easy_discount->set('QTYDSC', 'Qty Discount of 10%' ,$cart_total*0.10); elseif ($incart > 4) $easy_discount->set('QTYDSC', 'Qty Discount of 15%' ,$cart_total*0.15); elseif ($incart > 5) $easy_discount->set('QTYDSC', 'Qty Discount of 20%' ,$cart_total*0.20); Quote Treasurer MFC Link to comment Share on other sites More sharing options...
rdbello Posted May 17, 2006 Share Posted May 17, 2006 you could use something like: $incart = $cart->count_contents(); // number of items in the cart if ($incart > 0) $cart_total = $cart->show_total(); // value of items in cart if ($incart < 1) $easy_discount->clear('QTYDSC'); // clear this discount if cart empty elseif ($incart > 1) $easy_discount->set('QTYDSC', 'Qty Discount of 5%', $cart_total*0.05); elseif ($incart > 3) $easy_discount->set('QTYDSC', 'Qty Discount of 10%' ,$cart_total*0.10); elseif ($incart > 4) $easy_discount->set('QTYDSC', 'Qty Discount of 15%' ,$cart_total*0.15); elseif ($incart > 5) $easy_discount->set('QTYDSC', 'Qty Discount of 20%' ,$cart_total*0.20); Thanks for the reply. But I don't know where I've to write this script, could you help me? Is this script the only one that I need to implement Easy Discount? Thanks Quote Link to comment Share on other sites More sharing options...
boxtel Posted May 17, 2006 Author Share Posted May 17, 2006 Thanks for the reply. But I don't know where I've to write this script, could you help me? Is this script the only one that I need to implement Easy Discount? Thanks application_top.php after: if (!tep_session_is_registered('easy_discount')) { tep_session_register('easy_discount'); $easy_discount = new easy_discount(); } Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted May 18, 2006 Share Posted May 18, 2006 Hi I currently use CCGV contrib which works well in the main. However, I want to offer a 10% flat rate discount to call customers that buy online rather than through the physical store). From what I have read, this contrib looks perfect. Couple of questions... 1. has any one installed this along side CCGV, are there any conflicts 2. can vat free items be removed from the discounts (ie books). I have only one tax class set up so when I add a product i have either left it as --none-- or Taxable Goods. It needs to ignore all --none-- products. Many thanks W Quote Link to comment Share on other sites More sharing options...
MzM Posted May 18, 2006 Share Posted May 18, 2006 Hi, I have SPPC contrib running. Just want to know if i can use both easy discount and sppc. I really want easy discount installed... Thx Quote Link to comment Share on other sites More sharing options...
boxtel Posted May 19, 2006 Author Share Posted May 19, 2006 Hi I currently use CCGV contrib which works well in the main. However, I want to offer a 10% flat rate discount to call customers that buy online rather than through the physical store). From what I have read, this contrib looks perfect. Couple of questions... 1. has any one installed this along side CCGV, are there any conflicts 2. can vat free items be removed from the discounts (ie books). I have only one tax class set up so when I add a product i have either left it as --none-- or Taxable Goods. It needs to ignore all --none-- products. Many thanks W 1)I do not have CCGV so I cannot verify but I also cannot imagine any conflicts. 2)you would have to issue discounts per product iso per order which is fine but it does mean that each discount will be displayed separately in the cart and at checkout inless you add the discounts first and then issue 1 combined discount entry like (in pseudo code): // discount issue per product with tax for x = 1 to products in cart { if (taxed product) add discount for product } // discount combined discount = 0 for x = 1 to products in cart { if (taxed product) add to discount total } if (discount > 0 ) add discount for all Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted May 20, 2006 Share Posted May 20, 2006 Hi Could I not just apply a discount that says if there is 1 product or more in the basket at checkout then add a discount. I thought I saw an example somewhere that says if 5 products or more then apply discount? Thanks W 1)I do not have CCGV so I cannot verify but I also cannot imagine any conflicts.2)you would have to issue discounts per product iso per order which is fine but it does mean that each discount will be displayed separately in the cart and at checkout inless you add the discounts first and then issue 1 combined discount entry like (in pseudo code): // discount issue per product with tax for x = 1 to products in cart { if (taxed product) add discount for product } // discount combined discount = 0 for x = 1 to products in cart { if (taxed product) add to discount total } if (discount > 0 ) add discount for all 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.