Guest Posted February 17, 2006 Share Posted February 17, 2006 I fail to see the relevance. Well if you have a 100% discount... Usually you want by bypass the payment. But I posted a new topic about it. I need to find out how to change the info["payment"] object.. Ether I'm brain dead - or it keeps changing it up on me. Quote Link to comment Share on other sites More sharing options...
laurelsstitchery Posted February 17, 2006 Share Posted February 17, 2006 For some reason, I'm having a hard time understanding the installation instructions on this contribution, so I need a little help. The install file for the addon shopping cart portion says: 1) in top of shopping_cart.php add: include_once (DIR_WS_FUNCTIONS.'easy_discount.php'); It doesn't say where specifically to insert this code. What should this code come after? The same install file also says: 2) in shopping_cart.php: after : <tr> <td> <table width="100%"> <tr> <td align="right" class="smallText"><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $currencies->format($cart->show_total()); ?> </td> </tr> </table> </td> </tr> add: <?php if ($easy_discount->count() > 0) { echo easy_discount_display(); echo '<tr><td align="right">'.SUB_TITLE_TOTAL.'</td><td align="right">'.$currencies->format(($cart->show_total() - $easy_discount->total())).'</td></tr>'; } ?> My shoppingcart.php file does not contain that last </table></td></tr> portion, should I paste this code after the </tr>? Let me know if I need to paste my shoppingcart file here for review. The install file for the shopping cart box says: Shopping cart info box addon: in includes/boxes/shopping_cart.php after : $info_box_contents[] = array('align' => 'right', 'text' => $currencies->format($cart->show_total())); add: if ($easy_discount->count() > 0) { $info_box_contents [] = array('align' => ' right ', 'text' => 'Discounts: <font color="red">- '.$currencies->format(($easy_discount->total())).'</font>'); $info_box_contents [] = array('align' => ' right ', 'text' => 'Total: '.$currencies->format(($cart->show_total() - $easy_discount->total()))); } In my file, there is a } after the first code snippet. Do I paste the second snippet before or after the } mark? Quote Laurel Link to comment Share on other sites More sharing options...
kbking Posted February 17, 2006 Share Posted February 17, 2006 Hi! This is by far the easiest and the most intelligent contribution I have added to my shop (and I have added lots of them on an heavily modded copy of OsCommerce), so thanks Amanda for your talented work. I have one question though. In the order confirmation email that I get when ordering from my site it says: Products ------------------------------------------------------ 1 x Giga System (sys1) = $1,215.00 ------------------------------------------------------ Sub-Total: $1,215.00 Flat Rate (Best Way): $5.00 Total: $1,220.00 Regular Customer Bonus: -$10.00 Now I'd like it to be: Products ------------------------------------------------------ 1 x Giga System (sys1) = $1,215.00 ------------------------------------------------------ Sub-Total: $1,215.00 Flat Rate (Best Way): $5.00 Regular Customer Bonus: -$10.00 Total: $1,210.00 (Regular Customer Bonus: -$10.00 = Is the result of Easy Discount, of course) Maybe I have missed something here, if so please advice. If not please help me out on this! Regards! /kbking Quote Link to comment Share on other sites More sharing options...
kbking Posted February 17, 2006 Share Posted February 17, 2006 Sorry for this last post, I went ahead of myself, it had to do with the sort order. Thanks anyways! Quote Link to comment Share on other sites More sharing options...
Guest Posted February 17, 2006 Share Posted February 17, 2006 I figured out the one payment module and 100% discount issue and it trying to run the payment module. Fixed it with: http://www.oscommerce.com/community/contri...all/search,free I just modified that module to use the values I'm using. Quote Link to comment Share on other sites More sharing options...
Caterpillar Posted February 18, 2006 Share Posted February 18, 2006 Simple promotion code working in shopping cart Thanks, boxtel for this great contribution. I was fearing installing "Credit Class & Gift Voucher" on my modified site, and it also had many more features than I needed. I needed a simple promotion code system for my site like that described by varnco, Caterpillar, and others. The customer enters some text, like "SPECIAL", in an input box and then clicks the update cart button and the discount appears. I got it working on my site and wanted to share what I did if people are still working on this. <<snip>> This last step creates the text box for customers to enter the promotion code. This is working on my site, but please test it and let me know if it works for you. I'm new to php, so any coding suggestions are appreciated. The next improvement I'd like to add is an error message that comes up if the customer enters an incorrect promotion code. Right not, they get no feedback. Amanda, Phil I tried setting this up but when a customer enters SPECIAL into the promo code and they update the cart they get a Fatal error: Call to undefined function: easy_discount_total() in /home/caterpillar/www/www/shopping_cart.php on line 176 Then once they leave all customers are getting Fatal error: Call to undefined function: easy_discount_total() in /home/caterpillar/www/www/includes/boxes/shopping_cart.php on line 69 Any suggestions would be appreciated Regards Neil Quote Link to comment Share on other sites More sharing options...
Caterpillar Posted February 18, 2006 Share Posted February 18, 2006 Amanda, Phil I tried setting this up but when a customer enters SPECIAL into the promo code and they update the cart they get a Fatal error: Call to undefined function: easy_discount_total() in /home/caterpillar/www/www/shopping_cart.php on line 176 Then once they leave all customers are getting Fatal error: Call to undefined function: easy_discount_total() in /home/caterpillar/www/www/includes/boxes/shopping_cart.php on line 69 Any suggestions would be appreciated Regards Neil Got it. easy_discount_total did not have $ in the code. Now however, when a customer logs off say and does not complete checkout the discount is remaining. Any ideas would be appreciated. Regards Neil Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 18, 2006 Author Share Posted February 18, 2006 Hi! This is by far the easiest and the most intelligent contribution I have added to my shop (and I have added lots of them on an heavily modded copy of OsCommerce), so thanks Amanda for your talented work. I have one question though. In the order confirmation email that I get when ordering from my site it says: Products ------------------------------------------------------ 1 x Giga System (sys1) = $1,215.00 ------------------------------------------------------ Sub-Total: $1,215.00 Flat Rate (Best Way): $5.00 Total: $1,220.00 Regular Customer Bonus: -$10.00 Now I'd like it to be: Products ------------------------------------------------------ 1 x Giga System (sys1) = $1,215.00 ------------------------------------------------------ Sub-Total: $1,215.00 Flat Rate (Best Way): $5.00 Regular Customer Bonus: -$10.00 Total: $1,210.00 (Regular Customer Bonus: -$10.00 = Is the result of Easy Discount, of course) Maybe I have missed something here, if so please advice. If not please help me out on this! Regards! /kbking I think that has to do with your sort order of the order total modules, my email says: Sub-Total: NT$ 100 Your Discount: -NT$ 50 Loyalty Discount (7.5%): -NT$ 4 WorldWide Shipping Taiwan 80g : NT$ 80 Total: NT$ 126 and I have the easy discount sort order just after the sub total. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted February 18, 2006 Author Share Posted February 18, 2006 For some reason, I'm having a hard time understanding the installation instructions on this contribution, so I need a little help. The install file for the addon shopping cart portion says: It doesn't say where specifically to insert this code. What should this code come after? The same install file also says: My shoppingcart.php file does not contain that last </table></td></tr> portion, should I paste this code after the </tr>? Let me know if I need to paste my shoppingcart file here for review. The install file for the shopping cart box says: In my file, there is a } after the first code snippet. Do I paste the second snippet before or after the } mark? 1)in the top means after the first <? 2)I think so. 3)before Quote Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted February 18, 2006 Author Share Posted February 18, 2006 Amanda, Phil I tried setting this up but when a customer enters SPECIAL into the promo code and they update the cart they get a Fatal error: Call to undefined function: easy_discount_total() in /home/caterpillar/www/www/shopping_cart.php on line 176 Then once they leave all customers are getting Fatal error: Call to undefined function: easy_discount_total() in /home/caterpillar/www/www/includes/boxes/shopping_cart.php on line 69 Any suggestions would be appreciated Regards Neil are you using the latest version? that has that function in the class which eliminates these kind of no/double declared functions. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted February 18, 2006 Author Share Posted February 18, 2006 Got it. easy_discount_total did not have $ in the code. Now however, when a customer logs off say and does not complete checkout the discount is remaining. Any ideas would be appreciated. Regards Neil well, easy_discount is session based so if the session goes, so does the discount. As with all session variables, if you use logoff, you have to unregister the session variables that are specifically linked to that customer. in my logoff function I use: switch ($_GET['action']) { case 'logoff' : { tep_autologincookie(false); tep_session_unregister('customer_id'); tep_session_unregister('customer_default_address_id'); tep_session_unregister('customer_first_name'); tep_session_unregister('customer_last_name'); tep_session_unregister('customer_created'); tep_session_unregister('customer_last_signin'); tep_session_unregister('customer_country_id'); tep_session_unregister('customer_zone_id'); tep_session_unregister('comments'); tep_session_unregister('noaccount'); tep_session_unregister('new_products_id_in_cart'); tep_session_unregister('country'); tep_session_unregister('shipping'); tep_session_unregister('sendto'); tep_session_unregister('billto'); tep_session_unregister('payment'); $cart->reset(); $easy_discount->reset(); if ($request_type == 'SSL') { tep_redirect(tep_href_link(FILENAME_DEFAULT)); } break; so I do not destroy the session as I want to retain "your recent history" but unregister the rest, reset the cart and easy discount. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
zalik22 Posted February 18, 2006 Share Posted February 18, 2006 I get these errors when I add an item to a shopping cart: Warning: main(DIR_WS_FUNCTIONSeasy_discount.php): failed to open stream: No such file or directory in /home/virtual/site14/fst/var/www/html/catalog/shopping_cart.php on line 13 Warning: main(): Failed opening 'DIR_WS_FUNCTIONSeasy_discount.php' for inclusion (include_path='.:/php/includes:/usr/share/php') in /home/virtual/site14/fst/var/www/html/catalog/shopping_cart.php on line 13 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/virtual/site14/fst/var/www/html/catalog/shopping_cart.php:13) in /home/virtual/site14/fst/var/www/html/catalog/includes/functions/sessions.php on line 128 My code from the catalog/shopping_cart.php file: <?php /* $Id: shopping_cart.php,v 1.73 2003/06/09 23:03:56 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ include_once (DIR_WS_FUNCTIONS.'easy_discount.php'); require("includes/application_top.php"); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART); $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SHOPPING_CART)); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_SHOPPING_CART, 'action=update_product')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_cart.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php if ($cart->count_contents() > 0) { ?> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[0][] = array('align' => 'center', 'params' => 'class="productListing-heading"', 'text' => TABLE_HEADING_REMOVE); $info_box_contents[0][] = array('params' => 'class="productListing-heading"', 'text' => TABLE_HEADING_PRODUCTS); $info_box_contents[0][] = array('align' => 'center', 'params' => 'class="productListing-heading"', 'text' => TABLE_HEADING_QUANTITY); $info_box_contents[0][] = array('align' => 'right', 'params' => 'class="productListing-heading"', 'text' => TABLE_HEADING_TOTAL); $any_out_of_stock = 0; $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { // Push all attributes information in an array if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) { while (list($option, $value) = each($products[$i]['attributes'])) { echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value); $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $products[$i]['id'] . "' and pa.options_id = '" . $option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'"); $attributes_values = tep_db_fetch_array($attributes); $products[$i][$option]['products_options_name'] = $attributes_values['products_options_name']; $products[$i][$option]['options_values_id'] = $value; $products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name']; $products[$i][$option]['options_values_price'] = $attributes_values['options_values_price']; $products[$i][$option]['price_prefix'] = $attributes_values['price_prefix']; } } } for ($i=0, $n=sizeof($products); $i<$n; $i++) { if (($i/2) == floor($i/2)) { $info_box_contents[] = array('params' => 'class="productListing-even"'); } else { $info_box_contents[] = array('params' => 'class="productListing-odd"'); } $cur_row = sizeof($info_box_contents) - 1; $info_box_contents[$cur_row][] = array('align' => 'center', 'params' => 'class="productListing-data" valign="top"', 'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id'])); $products_name = '<table border="0" cellspacing="2" cellpadding="2">' . ' <tr>' . ' <td class="productListing-data" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' . ' <td class="productListing-data" valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>' . $products[$i]['name'] . '</b></a>'; if (STOCK_CHECK == 'true') { $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']); if (tep_not_null($stock_check)) { $any_out_of_stock = 1; $products_name .= $stock_check; } } if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) { reset($products[$i]['attributes']); while (list($option, $value) = each($products[$i]['attributes'])) { $products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>'; } } $products_name .= ' </td>' . ' </tr>' . '</table>'; $info_box_contents[$cur_row][] = array('params' => 'class="productListing-data"', 'text' => $products_name); $info_box_contents[$cur_row][] = array('align' => 'center', 'params' => 'class="productListing-data" valign="top"', 'text' => tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id'])); $info_box_contents[$cur_row][] = array('align' => 'right', 'params' => 'class="productListing-data" valign="top"', 'text' => '<b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b>'); } new productListingBox($info_box_contents); ?> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td align="right" class="main"><b><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $currencies->format($cart->show_total()); ?></b></td> </tr> <?php if ($easy_discount->count() > 0) { echo easy_discount_display(); echo '<tr><td align="right">'.SUB_TITLE_TOTAL.'</td><td align="right">'.$currencies->format(($cart->show_total() - $easy_discount->total())).'</td></tr>'; } ?> <?php if ($any_out_of_stock == 1) { if (STOCK_ALLOW_CHECKOUT == 'true') { ?> <tr> <td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CAN_CHECKOUT; ?></td> </tr> <?php } else { ?> <tr> <td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></td> </tr> <?php } } ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td class="main"><?php echo tep_image_submit('button_update_cart.gif', IMAGE_BUTTON_UPDATE_CART); ?></td> <?php $back = sizeof($navigation->path)-2; if (isset($navigation->path[$back])) { ?> <td class="main"><?php echo '<a href="' . tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action')), $navigation->path[$back]['mode']) . '">' . tep_image_button('button_continue_shopping.gif', IMAGE_BUTTON_CONTINUE_SHOPPING) . '</a>'; ?></td> <?php } ?> <td align="right" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image_button('button_checkout.gif', IMAGE_BUTTON_CHECKOUT) . '</a>'; ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> <?php } else { ?> <tr> <td align="center" class="main"><?php new infoBox(array(array('text' => TEXT_CART_EMPTY))); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td align="right" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> <?php } ?> </table></form></td> <!-- 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'); ?> Please help. Thanks! Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 18, 2006 Author Share Posted February 18, 2006 I get these errors when I add an item to a shopping cart: Warning: main(DIR_WS_FUNCTIONSeasy_discount.php): failed to open stream: No such file or directory in /home/virtual/site14/fst/var/www/html/catalog/shopping_cart.php on line 13 Warning: main(): Failed opening 'DIR_WS_FUNCTIONSeasy_discount.php' for inclusion (include_path='.:/php/includes:/usr/share/php') in /home/virtual/site14/fst/var/www/html/catalog/shopping_cart.php on line 13 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/virtual/site14/fst/var/www/html/catalog/shopping_cart.php:13) in /home/virtual/site14/fst/var/www/html/catalog/includes/functions/sessions.php on line 128 My code from the catalog/shopping_cart.php file: <?php /* $Id: shopping_cart.php,v 1.73 2003/06/09 23:03:56 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ include_once (DIR_WS_FUNCTIONS.'easy_discount.php'); require("includes/application_top.php"); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART); $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SHOPPING_CART)); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_SHOPPING_CART, 'action=update_product')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_cart.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php if ($cart->count_contents() > 0) { ?> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[0][] = array('align' => 'center', 'params' => 'class="productListing-heading"', 'text' => TABLE_HEADING_REMOVE); $info_box_contents[0][] = array('params' => 'class="productListing-heading"', 'text' => TABLE_HEADING_PRODUCTS); $info_box_contents[0][] = array('align' => 'center', 'params' => 'class="productListing-heading"', 'text' => TABLE_HEADING_QUANTITY); $info_box_contents[0][] = array('align' => 'right', 'params' => 'class="productListing-heading"', 'text' => TABLE_HEADING_TOTAL); $any_out_of_stock = 0; $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { // Push all attributes information in an array if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) { while (list($option, $value) = each($products[$i]['attributes'])) { echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value); $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $products[$i]['id'] . "' and pa.options_id = '" . $option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'"); $attributes_values = tep_db_fetch_array($attributes); $products[$i][$option]['products_options_name'] = $attributes_values['products_options_name']; $products[$i][$option]['options_values_id'] = $value; $products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name']; $products[$i][$option]['options_values_price'] = $attributes_values['options_values_price']; $products[$i][$option]['price_prefix'] = $attributes_values['price_prefix']; } } } for ($i=0, $n=sizeof($products); $i<$n; $i++) { if (($i/2) == floor($i/2)) { $info_box_contents[] = array('params' => 'class="productListing-even"'); } else { $info_box_contents[] = array('params' => 'class="productListing-odd"'); } $cur_row = sizeof($info_box_contents) - 1; $info_box_contents[$cur_row][] = array('align' => 'center', 'params' => 'class="productListing-data" valign="top"', 'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id'])); $products_name = '<table border="0" cellspacing="2" cellpadding="2">' . ' <tr>' . ' <td class="productListing-data" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' . ' <td class="productListing-data" valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>' . $products[$i]['name'] . '</b></a>'; if (STOCK_CHECK == 'true') { $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']); if (tep_not_null($stock_check)) { $any_out_of_stock = 1; $products_name .= $stock_check; } } if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) { reset($products[$i]['attributes']); while (list($option, $value) = each($products[$i]['attributes'])) { $products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>'; } } $products_name .= ' </td>' . ' </tr>' . '</table>'; $info_box_contents[$cur_row][] = array('params' => 'class="productListing-data"', 'text' => $products_name); $info_box_contents[$cur_row][] = array('align' => 'center', 'params' => 'class="productListing-data" valign="top"', 'text' => tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id'])); $info_box_contents[$cur_row][] = array('align' => 'right', 'params' => 'class="productListing-data" valign="top"', 'text' => '<b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b>'); } new productListingBox($info_box_contents); ?> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td align="right" class="main"><b><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $currencies->format($cart->show_total()); ?></b></td> </tr> <?php if ($easy_discount->count() > 0) { echo easy_discount_display(); echo '<tr><td align="right">'.SUB_TITLE_TOTAL.'</td><td align="right">'.$currencies->format(($cart->show_total() - $easy_discount->total())).'</td></tr>'; } ?> <?php if ($any_out_of_stock == 1) { if (STOCK_ALLOW_CHECKOUT == 'true') { ?> <tr> <td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CAN_CHECKOUT; ?></td> </tr> <?php } else { ?> <tr> <td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></td> </tr> <?php } } ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td class="main"><?php echo tep_image_submit('button_update_cart.gif', IMAGE_BUTTON_UPDATE_CART); ?></td> <?php $back = sizeof($navigation->path)-2; if (isset($navigation->path[$back])) { ?> <td class="main"><?php echo '<a href="' . tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action')), $navigation->path[$back]['mode']) . '">' . tep_image_button('button_continue_shopping.gif', IMAGE_BUTTON_CONTINUE_SHOPPING) . '</a>'; ?></td> <?php } ?> <td align="right" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image_button('button_checkout.gif', IMAGE_BUTTON_CHECKOUT) . '</a>'; ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> <?php } else { ?> <tr> <td align="center" class="main"><?php new infoBox(array(array('text' => TEXT_CART_EMPTY))); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td align="right" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> <?php } ?> </table></form></td> <!-- 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'); ?> Please help. Thanks! after: require("includes/application_top.php"); as all essential settings are set in there. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
zalik22 Posted February 18, 2006 Share Posted February 18, 2006 after: require("includes/application_top.php"); as all essential settings are set in there. I'm sorry, Amanda, I don't understand. One thing, I did not put any discount so that probably did not work. I did change the code so that I placed: include_once(DIR_WS_FUNCTIONS.'easy_discount.php'); $easy_discount->reset(); if ($cart->count_contents() > 5) { $easy_discount->set('CQTY','Cart Quantity Discount',5); } else { $easy_discount->clear('CQTY'); } ?> in the shopping_cart.php file and it works. What is the difference between placing this code in the application_top.php file and the shopping_cart.php file. Also, I would only like to give discounts to items where the item number does not start with "F". Is there an easy way to do this? Thanks! Quote Link to comment Share on other sites More sharing options...
zalik22 Posted February 18, 2006 Share Posted February 18, 2006 in the shopping_cart.php file and it works. What is the difference between placing this code in the application_top.php file and the shopping_cart.php file. Also, I would only like to give discounts to items where the item number does not start with "F". Is there an easy way to do this? Thanks! Actually, after thinking a bit more, I would like the customer to enter "10OFF" at some place during the checkout under a box labeled "Discount Code" Then, the customer should get 10% off all items whose item numbers do not start with "F". Could you please help me out with the coding? I do not have much experience, as I am sure you can tell. Thanks! Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 18, 2006 Author Share Posted February 18, 2006 I'm sorry, Amanda, I don't understand. One thing, I did not put any discount so that probably did not work. I did change the code so that I placed: include_once(DIR_WS_FUNCTIONS.'easy_discount.php'); $easy_discount->reset(); if ($cart->count_contents() > 5) { $easy_discount->set('CQTY','Cart Quantity Discount',5); } else { $easy_discount->clear('CQTY'); } ?> in the shopping_cart.php file and it works. What is the difference between placing this code in the application_top.php file and the shopping_cart.php file. Also, I would only like to give discounts to items where the item number does not start with "F". Is there an easy way to do this? Thanks! you can put include_once(DIR_WS_FUNCTIONS.'easy_discount.php'); in application top but that means that that file is included whether it is needed on that particular page or not. in shopping_cart you know it is needed but in contact_us not so why load files you do not need. the impact is pure performance related. something like: if ($products_model[0] != 'F') { give the discount} Quote Treasurer MFC Link to comment Share on other sites More sharing options...
zalik22 Posted February 18, 2006 Share Posted February 18, 2006 you can put include_once(DIR_WS_FUNCTIONS.'easy_discount.php'); in application top but that means that that file is included whether it is needed on that particular page or not. in shopping_cart you know it is needed but in contact_us not so why load files you do not need. the impact is pure performance related. something like: if ($products_model[0] != 'F') { give the discount} Thanks Amanda, I think that makes sense. In case you missed my post above while posting: Actually, after thinking a bit more, I would like the customer to enter "10OFF" at some place during the checkout under a box labeled "Discount Code" Then, the customer should get 10% off all items whose item numbers do not start with "F". So, if the customer has 3 items in their cart, and 1 item starts with "F", I only want the 10% discount applied to the 2 "non-F" items. Could you please help me out with the coding? I do not have much experience, as I am sure you can tell. Thanks Amanda! Quote Link to comment Share on other sites More sharing options...
boxtel Posted February 18, 2006 Author Share Posted February 18, 2006 Thanks Amanda, I think that makes sense. In case you missed my post above while posting: Actually, after thinking a bit more, I would like the customer to enter "10OFF" at some place during the checkout under a box labeled "Discount Code" Then, the customer should get 10% off all items whose item numbers do not start with "F". So, if the customer has 3 items in their cart, and 1 item starts with "F", I only want the 10% discount applied to the 2 "non-F" items. Could you please help me out with the coding? I do not have much experience, as I am sure you can tell. Thanks Amanda! well, after you have determined that the code is correct and the discount should be given: // detailed discounts (discount entry per product) if (give discount) { $products = $cart->get_products(); $n = sizeof($products); for ($i=0; $i<$n; $i++) { if ($products[$i]['model'][0] != 'F') $easy_discount->add($products[$i]['id'], 'Discount for '.$products[$i]['name'],$products[$i]['price']*0.1); } } or // totalled discount (1 discount entry) if (give discount) { $discount = 0; $products = $cart->get_products(); $n = sizeof($products); for ($i=0; $i<$n; $i++) { if ($products[$i]['model'][0] != 'F') $discount = $discount + $products[$i]['price']*0.1; } if ($discount > 0) $easy_discount->add('FD', 'Discount for Code 10OFF',$discount); } Quote Treasurer MFC Link to comment Share on other sites More sharing options...
zalik22 Posted February 18, 2006 Share Posted February 18, 2006 well, after you have determined that the code is correct and the discount should be given:// detailed discounts (discount entry per product) if (give discount) { $products = $cart->get_products(); $n = sizeof($products); for ($i=0; $i<$n; $i++) { if ($products[$i]['model'][0] != 'F') $easy_discount->add($products[$i]['id'], 'Discount for '.$products[$i]['name'],$products[$i]['price']*0.1); } } or // totalled discount (1 discount entry) if (give discount) { $discount = 0; $products = $cart->get_products(); $n = sizeof($products); for ($i=0; $i<$n; $i++) { if ($products[$i]['model'][0] != 'F') $discount = $discount + $products[$i]['price']*0.1; } if ($discount > 0) $easy_discount->add('FD', 'Discount for Code 10OFF',$discount); } Is there a way to add the box that says "Discount Code" on the shopping cart? How do I extract the code to make sure the customer is actually placing some valid code. Quote Link to comment Share on other sites More sharing options...
zalik22 Posted February 18, 2006 Share Posted February 18, 2006 Where would the code be to change the font when the discount is applied? I would like all of them to look like the first row, but the 2nd and 3rd rows are in a different font and size. Sub-Total: $212.80 Cart Quantity Discount: - $5.00 Total: $207.80 Thanks! Quote Link to comment Share on other sites More sharing options...
zalik22 Posted February 18, 2006 Share Posted February 18, 2006 Hi guys, First, THANK YOU Amanda for the contribution. I think everything works with the exception of the fonts below. The subtotal is in a smaller font and I want all the font sizes to match this line. If possible, I want the entire product name to be red too. The last 3 lines are size 12 font, take up 2 lines, and they are not lined up. How can I change this? Sub-Total: $530.10 Discount for Product 1 Name: - $18.10 Discount for Product 2 Name: - $3.60 Total: $508.40 Thanks! Quote Link to comment Share on other sites More sharing options...
laurelsstitchery Posted February 18, 2006 Share Posted February 18, 2006 Ok. I think I have everything installed. I'd like to offer free shipping to all my new customers. Since I am a php newbie, I need help on what exactly I need to code into which files. Could someone help me? Thanks! :) Quote Laurel Link to comment Share on other sites More sharing options...
laurelsstitchery Posted February 18, 2006 Share Posted February 18, 2006 Well, of course I spoke too soon. The boxes/shoppingcart.php has an error that I can't figure out. Here's the file, please review and let me know what I've screwed up. <?php /* $Id: shopping_cart.php,v 1.18 2003/02/10 22:31:06 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ ?> <!-- shopping_cart //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART); new infoBoxHeading($info_box_contents, false, true, tep_href_link(FILENAME_SHOPPING_CART)); $cart_contents_string = ''; if ($cart->count_contents() > 0) { $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0">'; $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $cart_contents_string .= '<tr><td align="right" valign="top" class="infoBoxContents">'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { $cart_contents_string .= '<span class="newItemInCart">'; } else { $cart_contents_string .= '<span class="infoBoxContents">'; } $cart_contents_string .= $products[$i]['quantity'] . ' x </span></td><td valign="top" class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { $cart_contents_string .= '<span class="newItemInCart">'; } else { $cart_contents_string .= '<span class="infoBoxContents">'; } $cart_contents_string .= $products[$i]['name'] . '</span></a></td></tr>'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { tep_session_unregister('new_products_id_in_cart'); } } $cart_contents_string .= '</table>'; } else { $cart_contents_string .= BOX_SHOPPING_CART_EMPTY; } $info_box_contents = array(); $info_box_contents[] = array('text' => $cart_contents_string); if ($cart->count_contents() > 0) { $info_box_contents[] = array('text' => tep_draw_separator()); $info_box_contents[] = array('align' => 'right', 'text' => $currencies->format($cart->show_total())); if ($easy_discount->count() > 0) { $info_box_contents [] = array('align' => 'right', 'text' => 'Discounts: <font color="red">- '.$currencies->format(($easy_discount->total())).'</font>'); $info_box_contents [] = array('align' => ' right ', 'text' => 'Total: '.$currencies->format(($cart->show_total() - $easy_discount->total()))); } } new infoBox($info_box_contents); ?> </td> </tr> <!-- shopping_cart_eof //--> Quote Laurel Link to comment Share on other sites More sharing options...
laurelsstitchery Posted February 18, 2006 Share Posted February 18, 2006 Here are the errors I'm getting: Warning: main(DIR_WS_FUNCTIONSeasy_discount.php): failed to open stream: No such file or directory in /home/.charmian/moosedog/laurelsstitchery.com/catalog/shopping_cart.php on line 13 Warning: main(): Failed opening 'DIR_WS_FUNCTIONSeasy_discount.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/.charmian/moosedog/laurelsstitchery.com/catalog/shopping_cart.php on line 13 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/.charmian/moosedog/laurelsstitchery.com/catalog/shopping_cart.php:13) in /home/.charmian/moosedog/laurelsstitchery.com/catalog/includes/functions/sessions.php on line 97 Fatal error: Call to a member function on a non-object in /home/.charmian/moosedog/laurelsstitchery.com/catalog/shopping_cart.php on line 166 Quote Laurel Link to comment Share on other sites More sharing options...
boxtel Posted February 19, 2006 Author Share Posted February 19, 2006 Hi guys, First, THANK YOU Amanda for the contribution. I think everything works with the exception of the fonts below. The subtotal is in a smaller font and I want all the font sizes to match this line. If possible, I want the entire product name to be red too. The last 3 lines are size 12 font, take up 2 lines, and they are not lined up. How can I change this? Sub-Total: $530.10 Discount for Product 1 Name: - $18.10 Discount for Product 2 Name: - $3.60 Total: $508.40 Thanks! file ot_easy_discount.php: $this->output[] = array('title' => $easy_discounts[$i]['description'].': ', 'text' => '<font color="red">-' . $currencies->format($easy_discounts[$i]['amount']).'</font>', 'value' => $easy_discounts[$i]['amount']); Quote Treasurer MFC 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.