catch Posted August 8, 2009 Share Posted August 8, 2009 Hey all I have online store where you can . Can I make it possible that you only can make orders on opening hours? Also in closing time will not be possible to make an order. I want it to go automatically, and I determining the times. valid for a whole week. (closing time is not the same every day) Hope someone can help me thanks :-) Link to comment Share on other sites More sharing options...
germ Posted August 8, 2009 Share Posted August 8, 2009 One way: The first page in the osC standard checkout process is checkout_shipping.php At the top of /catalog/checkout_shipping.php AFTER this code: require('includes/application_top.php'); require('includes/classes/http_client.php'); ADD this code: //BOF checking business hours code $open_for_business = array("store_hours" => array( "0" => array("open" => "07:00:00", "close" => "17:00:00"), // sunday hours "1" => array("open" => "07:00:00", "close" => "17:00:00"), // monday hours "2" => array("open" => "07:00:00", "close" => "17:00:00"), // tuesday hours "3" => array("open" => "07:00:00", "close" => "17:00:00"), // wednesday hours "4" => array("open" => "07:00:00", "close" => "17:00:00"), // thursday hours "5" => array("open" => "07:00:00", "close" => "17:00:00"), // friday hours "6" => array("open" => "07:00:00", "close" => "17:00:00"))); // saturday hours $offset = 0; // 3600 = 1 hour. use to adjust server time to local time if necessary $timenow = date('H:i:s',time()+ $offset); $open_today = $open_for_business["store_hours"][date('w',time()+ $offset)]["open"]; $close_today = $open_for_business["store_hours"][date('w',time()+ $offset)]["close"]; if ( ($timenow >= $open_today ) && ( $timenow <= $close_today ) ) { // Store open! } else { // Store closed! tep_redirect(tep_href_link(FILENAME_STORE_NOT_OPEN)); } //EOF checking business hours code Then create a page you want to send them to when they try to order and the store is closed and add that page name in /catalog/includes/filenames.php like this: define('FILENAME_STORE_NOT_OPEN', 'store_closed.php'); //use your own page name here Adjust the code to your own hours. HOURS are 24 hour format (0 to 23)! If the server time is not the same as your local time use the $offset variable to adjust (can use positive or negative values): $offset = 0; // 3600 = 1 hour. use to adjust server time to local time if necessary If you want to be closed on any day just set the open time greater than the closed time like: "5" => array("open" => "17:00:00", "close" => "07:00:00"), // friday hours, we are closed this day I have tested this code (logic and syntax) to the best of my abilities and it seems to work. BACKUP ANY FILE BEFORE MAKING ANY EDITS!!! You break it - You bought it... :blush: If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
germ Posted August 12, 2009 Share Posted August 12, 2009 I added code so you can be closed for days or a range of days throughout the year: //BOF checking business hours code // check for days this year the store is closed // fill the following array with the days you are closed this year // format = mm/dd (i.e. 02/16 = feb. 16) // to be closed for a range of days use: // '05/23 to 05/25' // that makes the store closed may 23 thru may 25 (inclusive) // (the existing days in the array are what I used for testing) $days_closed = array( '01/01', '02/16', '05/23 to 05/25', '07/03 to 07/05', '09/05 to 09/07', '10/12', '11/11', '11/26 to 11/29', '12/24 to 12/27'); $offset = 0; // 3600 = 1 hour. use to adjust server time to local time if necessary $daynow = date('m/d',time()+ $offset); for ( $i = 0; $i < count($days_closed); $i++ ) { if ( strpos($days_closed[$i], 'to') ) { $pieces = explode("to", $days_closed[$i]); $pieces[0] = str_replace(" ", "", $pieces[0]); $pieces[1] = str_replace(" ", "", $pieces[1]); if ( ( $daynow >= $pieces[0] ) && ( $daynow <= $pieces[1] ) ) { tep_redirect(tep_href_link(FILENAME_STORE_NOT_OPEN)); } } else { if ( $daynow == $days_closed[$i] ) { tep_redirect(tep_href_link(FILENAME_STORE_NOT_OPEN)); } } } // check for hours we are open $open_for_business = array("store_hours" => array( "0" => array("open" => "07:00:00", "close" => "17:00:00"), // sunday hours "1" => array("open" => "07:00:00", "close" => "17:00:00"), // monday hours "2" => array("open" => "07:00:00", "close" => "17:00:00"), // tuesday hours "3" => array("open" => "07:00:00", "close" => "17:00:00"), // wednesday hours "4" => array("open" => "07:00:00", "close" => "17:00:00"), // thursday hours "5" => array("open" => "07:00:00", "close" => "17:00:00"), // friday hours "6" => array("open" => "07:00:00", "close" => "17:00:00"))); // saturday hours $timenow = date('H:i:s',time()+ $offset); $open_today = $open_for_business["store_hours"][date('w',time()+ $offset)]["open"]; $close_today = $open_for_business["store_hours"][date('w',time()+ $offset)]["close"]; if ( ($timenow >= $open_today ) && ( $timenow <= $close_today ) ) { // Store open! } else { // Store closed! tep_redirect(tep_href_link(FILENAME_STORE_NOT_OPEN)); } //EOF checking business hours code If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
catch Posted October 3, 2009 Author Share Posted October 3, 2009 Thank you very much, that's what I was looking for. I will test it today :-) My best regards Link to comment Share on other sites More sharing options...
♥ecartz Posted October 3, 2009 Share Posted October 3, 2009 If you want to be sure that it catches everyone, you should add the code to checkout_process.php as well as checkout_shipping.php. It is possible to bypass checkout_shipping.php under some circumstances. It is not possible to bypass checkout_process.php. You probably still want the code in checkout_shipping.php as well, so customers don't start a checkout that they can't finish. Always back up before making changes. Link to comment Share on other sites More sharing options...
MrPhil Posted October 3, 2009 Share Posted October 3, 2009 How does germ's code compare to contributions http://addons.oscommerce.com/info/5333 and http://addons.oscommerce.com/info/6332? I think they close a store for full days, rather than for hours within a day. It might be nice to combine the ideas in these contributions to have a contribution that partly/fully closes a store based on dates and times in a flat data file. You could go off on holiday/vacation knowing that someone won't place an order while you're gone, or maybe let them stash their shopping cart until the store reopens, or just let them check out, but put up a big warning (when they start checkout) that orders won't be processed until such and such a date and time. Confirmation email should repeat that notice. Would it be useful for anyone, to fully shut down a store (no window shopping) for some period of days (unless you're doing major maintenance on the site, in which case it may not be running anyway)? Anyway, combining all these existing contribs with germ's hourly shutdown, and putting the information in a flat file, might make a nice little project for someone looking for one to do. Link to comment Share on other sites More sharing options...
MrPhil Posted October 3, 2009 Share Posted October 3, 2009 (the edit window closed while I was typing this in!) Add: a couple of afterthoughts: 1) use the same data (e.g., flat file) to post hours open at the top of the page, or in an "Our Schedule" page. 2) use cron jobs to figure open/closed times, updating a simple flat file that contains current open-closed mode. osC just reads the file and activates/deactivates certain functions/capabilities Link to comment Share on other sites More sharing options...
Xpajun Posted October 3, 2009 Share Posted October 3, 2009 Is there a way of using this to turn a shipping module off for a day or 6 days? for example shipping company charges a premium for next day Saturday delivery the idea is to swap between the normal next day and the Saturday next day My store is currently running Phoenix 1.0.3.0 I'm currently working on 1.0.7.2 and hope to get it live before 1.0.8.0 arrives (maybe 🙄 ) I used to have a list of add-ons here but I've found that with the ones that supporters of Phoenix get any other add-ons are not really neccessary Link to comment Share on other sites More sharing options...
tidemann Posted October 6, 2009 Share Posted October 6, 2009 I am writing on behalf of Catch, as I am his webmaster. Thank you for this fantastic script, it just works. I have a small following questions I've installed it on checkout_process.php and want it so that checkout_shipping.php only send you to another page, "If" you choose delivery. Can it? Because the opening and the delivery time isn´t the same.... Open: 11:00 - 21:00 Delivery: 17:00 - 20:00 Best regards Marianne Link to comment Share on other sites More sharing options...
tidemann Posted October 6, 2009 Share Posted October 6, 2009 I am writing on behalf of Catch, as I am his webmaster. Thank you for this fantastic script, it just works. I have a small following questions I've installed it on checkout_process.php and want it so that checkout_shipping.php only send you to another page, "If" you choose delivery. Can it? Because the opening and the delivery time isn´t the same.... Open: 11:00 - 21:00 Delivery: 17:00 - 20:00 Best regards Marianne Sorry, it vas checkout_shipping I install it on... ;o) Link to comment Share on other sites More sharing options...
burt Posted October 6, 2009 Share Posted October 6, 2009 I used a similar solution for a food shop that had strange opening hours. Deliveries made from shop to customers, so the website had to have the same hours of operation as the real life shop. I did it all in appliation_top.php as I recall, which negates the possibility of anyone ordering outside the allowed hours. I do remember that I set the online shop time to the exact time of where the client was located - that was a bit weird, as I think the (real life) shop was in Chicago and the virtual shop (in other words, the web server) was in Texas (or somewhere equally remote from Chicago). Look up date_default_timezone_set instead of messing with offset minutes - much easier!. Link to comment Share on other sites More sharing options...
♥ecartz Posted October 7, 2009 Share Posted October 7, 2009 I have a small following questions I've installed it on checkout_shipping.php and want it so that checkout_shipping.php only send you to another page, "If" you choose delivery. Can it? The easiest way to do this would be to put the code in the delivery shipping module so that delivery does not show as an option until 17:00. Rather than redirecting the customer, just don't allow the customer to select delivery. The customer would then still be able to choose pickup and do things that way. In checkout_shipping.php, you could add code that says (not in correct syntax) if $shipping == delivery and timenow < delivery_time redirect to delivery not open. We'd need to know as exactly what the shipping POSTs to tell you more about that. Always back up before making changes. Link to comment Share on other sites More sharing options...
tidemann Posted October 11, 2009 Share Posted October 11, 2009 The easiest way to do this would be to put the code in the delivery shipping module so that delivery does not show as an option until 17:00. Rather than redirecting the customer, just don't allow the customer to select delivery. The customer would then still be able to choose pickup and do things that way. In checkout_shipping.php, you could add code that says (not in correct syntax) if $shipping == delivery and timenow < delivery_time redirect to delivery not open. We'd need to know as exactly what the shipping POSTs to tell you more about that. Here is the checkout_shipping.php: <?php /* $Id: checkout_shipping.php,v 1.16 2003/06/09 23:03:53 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require('includes/classes/http_client.php'); //BOF checking business hours code // check for days this year the store is closed // fill the following array with the days you are closed this year // format = mm/dd (i.e. 02/16 = feb. 16) // to be closed for a range of days use: // '05/23 to 05/25' // that makes the store closed may 23 thru may 25 (inclusive) // (the existing days in the array are what I used for testing) $days_closed = array( '12/24 to 12/25'); $offset = 0; // 3600 = 1 hour. use to adjust server time to local time if necessary $daynow = date('m/d',time()+ $offset); for ( $i = 0; $i < count($days_closed); $i++ ) { if ( strpos($days_closed[$i], 'to') ) { $pieces = explode("to", $days_closed[$i]); $pieces[0] = str_replace(" ", "", $pieces[0]); $pieces[1] = str_replace(" ", "", $pieces[1]); if ( ( $daynow >= $pieces[0] ) && ( $daynow <= $pieces[1] ) ) { tep_redirect(tep_href_link(FILENAME_STORE_NOT_OPEN)); } } else { if ( $daynow == $days_closed[$i] ) { tep_redirect(tep_href_link(FILENAME_STORE_NOT_OPEN)); } } } // check for hours we are open $open_for_business = array("store_hours" => array( "0" => array("open" => "11:00:00", "close" => "20:45:00"), // sunday hours "1" => array("open" => "11:00:00", "close" => "20:45:00"), // monday hours "2" => array("open" => "11:00:00", "close" => "20:45:00"), // tuesday hours "3" => array("open" => "11:00:00", "close" => "20:45:00"), // wednesday hours "4" => array("open" => "11:00:00", "close" => "20:45:00"), // thursday hours "5" => array("open" => "11:00:00", "close" => "20:45:00"), // friday hours "6" => array("open" => "14:00:00", "close" => "20:45:00"))); // saturday hours $timenow = date('H:i:s',time()+ $offset); $open_today = $open_for_business["store_hours"][date('w',time()+ $offset)]["open"]; $close_today = $open_for_business["store_hours"][date('w',time()+ $offset)]["close"]; if ( ($timenow >= $open_today ) && ( $timenow <= $close_today ) ) { // Store open! } else { // Store closed! tep_redirect(tep_href_link(FILENAME_STORE_NOT_OPEN)); } //EOF checking business hours code // if the customer is not logged on, redirect them to the login page if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); if ((PROCEED_WITHOUT_LOGIN == 'Ja') && (PURCHASE_WITHOUT_ACCOUNT == 'Ja')) { tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT, 'guest=guest', 'SSL')); } else { tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } } // if there is nothing in the customers cart, redirect them to the shopping cart page if ($cart->count_contents() < 1) { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART)); } // if no shipping destination address was selected, use the customers own address as default if (!tep_session_is_registered('sendto')) { tep_session_register('sendto'); $sendto = $customer_default_address_id; } else { // verify the selected shipping address // PWA BOF CHANGE if ($customer_id == 0) { $sendto = 1; } else { $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$sendto . "'"); $check_address = tep_db_fetch_array($check_address_query); if ($check_address['total'] != '1') { $sendto = $customer_default_address_id; if (tep_session_is_registered('shipping')) tep_session_unregister('shipping'); } } } // PWA EOF require(DIR_WS_CLASSES . 'order.php'); $order = new order; // register a random ID in the session to check throughout the checkout procedure // against alterations in the shopping cart contents if (!tep_session_is_registered('cartID')) tep_session_register('cartID'); $cartID = $cart->cartID; // if the order contains only virtual products, forward the customer to the billing page as // a shipping address is not needed if (($order->content_type == 'virtual') || ($order->content_type == 'virtual_weight') ) { // Edited for CCGV if (!tep_session_is_registered('shipping')) tep_session_register('shipping'); $shipping = false; $sendto = false; tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); } $total_weight = $cart->show_weight(); $total_count = $cart->count_contents(); // load all enabled shipping modules require(DIR_WS_CLASSES . 'shipping.php'); $shipping_modules = new shipping; if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) { $pass = false; switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) { case 'national': if ($order->delivery['country_id'] == STORE_COUNTRY) { $pass = true; } break; case 'international': if ($order->delivery['country_id'] != STORE_COUNTRY) { $pass = true; } break; case 'both': $pass = true; break; } $free_shipping = false; if ( ($pass == true) && ($order->info['total'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) { $free_shipping = true; include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_shipping.php'); } } else { $free_shipping = false; } // process the selected shipping method if ( isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') ) { if (!tep_session_is_registered('comments')) tep_session_register('comments'); if (tep_not_null($HTTP_POST_VARS['comments'])) { $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']); } if (!tep_session_is_registered('shipping')) tep_session_register('shipping'); if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) { if ( (isset($HTTP_POST_VARS['shipping'])) && (strpos($HTTP_POST_VARS['shipping'], '_')) ) { $shipping = $HTTP_POST_VARS['shipping']; list($module, $method) = explode('_', $shipping); if ( is_object($$module) || ($shipping == 'free_free') ) { if ($shipping == 'free_free') { $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE; $quote[0]['methods'][0]['cost'] = '0'; } else { $quote = $shipping_modules->quote($method, $module); } if (isset($quote['error'])) { tep_session_unregister('shipping'); } else { if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) { $shipping = array('id' => $shipping, 'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'), 'cost' => $quote[0]['methods'][0]['cost']); tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); } } } else { tep_session_unregister('shipping'); } } } else { $shipping = false; tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); } } // get all available shipping quotes $quotes = $shipping_modules->quote(); // if no shipping method has been selected, automatically select the cheapest method. // if the modules status was changed when none were available, to save on implementing // a javascript force-selection method, also automatically select the cheapest shipping // method if more than one module is now enabled // Disabled by GrafikStudiet // if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest(); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_SHIPPING); $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); ?> <!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"> <meta name="robots" content="noindex, nofollow"> <script language="javascript"><!-- var selected; function selectRowEffect(object, buttonSelect) { if (!selected) { if (document.getElementById) { selected = document.getElementById('defaultSelected'); } else { selected = document.all['defaultSelected']; } } if (selected) selected.className = 'moduleRow'; object.className = 'moduleRowSelected'; selected = object; // one button is not an array if (document.checkout_address.shipping[0]) { document.checkout_address.shipping[buttonSelect].checked=true; } else { document.checkout_address.shipping.checked=true; } } function rowOverEffect(object) { if (object.className == 'moduleRow') object.className = 'moduleRowOver'; } function rowOutEffect(object) { if (object.className == 'moduleRowOver') object.className = 'moduleRow'; } //--></script> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <div id="wrapper"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="0" cellpadding="0" class="pageBody"> <tr> <?php // added by GrafikStudiet if (LAYOUT_COLUMN_LEFT_SHOW == 'Ja') { ?> <td width="<?php echo LAYOUT_COLUMN_LEFT_WIDTH; ?>" valign="top" class="columnLeft"> <table border="0" width="<?php echo LAYOUT_COLUMN_LEFT_WIDTH; ?>" cellspacing="0" cellpadding="0"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table> </td> <?php } ?> <!-- body_text //--> <td width="100%" valign="top" class="columnCenter"> <?php echo tep_draw_form('checkout_address', tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')) . tep_draw_hidden_field('action', 'process'); ?> <table border="0" width="100%" cellspacing="0" cellpadding="0" class="pageContents"> <tr> <td class="pageContents"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="0" class="pageHeading"> <tr> <td class="pageHeading"><h1><?php echo HEADING_TITLE; ?></h1></td> <?php // added by GrafikStudiet if (LAYOUT_SHOW_PAGE_HEADING_ICON == 'Ja') { ?> <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_delivery.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> <?php } ?> </tr> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '3'); ?></td> </tr> </table> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="main"><h3><?php echo TABLE_HEADING_SHIPPING_ADDRESS; ?></h3></td> </tr> </table> </td> </tr> <tr> <td> <table border="0" width="100%" cellspacing="1" cellpadding="2"> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td class="main" width="50%" valign="top"><?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br>'); ?></td> <td align="right" width="50%" valign="top"> <table border="0" cellspacing="0" cellpadding="3"> <tr> <!-- PWA BOF CHANGE--> <td class="main" valign="top"><?php echo (($customer_id>0 || (defined('PURCHASE_WITHOUT_ACCOUNT_SEPARATE_SHIPPING') && PURCHASE_WITHOUT_ACCOUNT_SEPARATE_SHIPPING=='yes') )? TEXT_CHOOSE_SHIPPING_DESTINATION . '</td></tr><tr><td><a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL') . '">' . tep_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>':' '); ?></td> <!-- PWA EOF --> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php if (tep_count_shipping_modules() > 0) { ?> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="main"><h3><?php echo TABLE_HEADING_SHIPPING_METHOD; ?></h3></td> </tr> </table> </td> </tr> <tr> <td> <table border="0" width="100%" cellspacing="1" cellpadding="2"> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <?php if (sizeof($quotes) > 1 && sizeof($quotes[0]) > 1) { ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td class="main" width="100%" valign="top"><?php echo TEXT_CHOOSE_SHIPPING_METHOD; ?></td> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> <?php } elseif ($free_shipping == false) { ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td class="main" width="100%" colspan="2"><?php echo TEXT_ENTER_SHIPPING_INFORMATION; ?></td> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> <?php } if ($free_shipping == true) { ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td colspan="2" width="100%"> <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="smallHeader" colspan="3"><b><?php echo FREE_SHIPPING_TITLE; ?></b> <?php echo $quotes[$i]['icon']; ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> <tr id="defaultSelected" class="moduleRowSelected" onMouseOver="rowOverEffect(this)" onMouseOut="rowOutEffect(this)" onClick="selectRowEffect(this, 0)"> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td class="main" width="100%"><?php echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) . tep_draw_hidden_field('shipping', 'free_free'); ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table> </td> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> <?php } else { $radio_buttons = 0; for ($i=0, $n=sizeof($quotes); $i<$n; $i++) { ?> <tr> <td></td> <td colspan="2"> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="smallHeader" colspan="3"> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><?php if (isset($quotes[$i]['icon']) && tep_not_null($quotes[$i]['icon'])) { echo $quotes[$i]['icon']; } ?></td> <td class="smallHeader"><?php echo $quotes[$i]['module']; ?></td> </tr> </table> </td> </tr> <?php if (isset($quotes[$i]['error'])) { ?> <tr> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td class="main" colspan="3"><?php echo $quotes[$i]['error']; ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> <?php } else { for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) { // set the radio button to be checked if it is the method chosen $checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id']) ? true : false); if ( ($checked == true) || ($n == 1 && $n2 == 1) ) { echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n"; } else { echo ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n"; } // Tilføjet af GrafikStudiet for at skjule fragtmetoder der returnere 0,00 kr fordi der ikke er defineret priser for pågældende vægt // $shipping_price = $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))); // if ((($shipping_price > 0) && ($cart->show_weight() > 0)) || ($quotes[$i]['module'] == MODULE_SHIPPING_FLAT_TEXT_TITLE )) { // slut på tilføjelse ?> <td class="main" width="75%"><?php echo $quotes[$i]['methods'][$j]['title']; ?></td> <?php if ( ($n > 1) || ($n2 > 1) ) { ?> <td class="main" width="25%" align="right"><?php echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))); ?></td> <td class="main" align="right"><?php echo tep_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked); ?></td> <?php } else { ?> <td class="main" align="right" colspan="2" width="25%"><?php echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])) . tep_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']); ?></td> <?php } ?> </tr> <?php $radio_buttons++; } // Tilføjet af GrafikStudiet // } // Slut på tilføjelse } ?> </table> </td> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> <?php } } ?> </table> </td> </tr> </table> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } ?> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="main"><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td> </tr> </table> </td> </tr> <tr> <td> <table border="0" width="100%" cellspacing="1" cellpadding="2"> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5'); ?></td> </tr> </table> </td> </tr> </table> </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"> <tr> <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 '<b>' . TITLE_CONTINUE_CHECKOUT_PROCEDURE . '</b><br>' . TEXT_CONTINUE_CHECKOUT_PROCEDURE; ?></td> <td class="main" align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="25%"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="50%" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'checkout_bullet.gif'); ?></td> <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td> </tr> </table> </td> <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td> <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td> <td width="25%"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td> <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td> </tr> </table> </td> </tr> <tr> <td align="center" width="25%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_DELIVERY; ?></td> <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_PAYMENT; ?></td> <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td> <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_FINISHED; ?></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </form></td> <!-- body_text_eof //--> <?php // added by GrafikStudiet if (LAYOUT_COLUMN_RIGHT_SHOW == 'Ja') { ?> <td width="<?php echo LAYOUT_COLUMN_RIGHT_WIDTH; ?>" valign="top" class="columnRight"> <table border="0" width="<?php echo LAYOUT_COLUMN_RIGHT_WIDTH; ?>" cellspacing="0" cellpadding="0"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> </table> </td> <?php } ?> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> </div> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> I use table.php as delivery module: <?php /* $Id: table.php,v 1.26x 2003/01/31 $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce * Modifications by Christian Lescuyer <[email protected]> * Copyright (c) 2003 Goélette http://www.goelette.net Released under the GNU General Public License */ class table { var $code, $title, $description, $icon, $enabled; // class constructor function table() { global $order; $this->code = 'table'; $this->title = MODULE_SHIPPING_TABLE_TEXT_TITLE; $this->description = MODULE_SHIPPING_TABLE_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_TABLE_SORT_ORDER; $this->icon = ''; $this->enabled = ((MODULE_SHIPPING_TABLE_STATUS == 'True') ? true : false); if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE_ZONE > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; } } } // class methods function quote($method = '') { global $cart, $shipping_weight, $shipping_num_boxes; if (MODULE_SHIPPING_TABLE_MODE == 'price') { $order_total = $cart->show_total(); } else if (MODULE_SHIPPING_TABLE_MODE == 'count') { $cart->count_contents(); $order_total = $cart->count_contents(); } else { $order_total = $shipping_weight; } $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE_COST); $size = sizeof($table_cost); for ($i=0; $i<$size; $i+=2) { if($order_total <= $table_cost[$i]){ if (MODULE_SHIPPING_TABLE_MODE == 'price') { $shipping = $table_cost[$i+1]; break; } else if (MODULE_SHIPPING_TABLE_MODE == 'count') { $shipping = $table_cost[$i+1] * $order_total; break; } else { $shipping = $table_cost[$i+1]; break; } } } if (MODULE_SHIPPING_TABLE_MODE == 'weight') { $shipping = $shipping * $shipping_num_boxes; } $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => MODULE_SHIPPING_TABLE_TEXT_WAY, 'cost' => $shipping + MODULE_SHIPPING_TABLE_HANDLING))); if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); return $this->quotes; } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Aktiver fragt efter tabel', 'MODULE_SHIPPING_TABLE_STATUS', 'True', 'Ønsker du at benytte tabelbaseret udregning af fragtpriser?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Udregnings tabel', 'MODULE_SHIPPING_TABLE_COST', '5:70,10:90,20:140,20.001:5000', 'Indtast din beregningstabel her.<br>Et eksempel kan være: 5:70,10:90,20:140 det giver følgende resultat op til 5 kg./kr./enheder koster 70 kr. fra 5 op til 10 koster 90, og fra 10 - 20 koster 140 kr.', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Beregningsgrundlag', 'MODULE_SHIPPING_TABLE_MODE', 'weight', 'Skal forsendelsen udregnes på baggrund af pakkens vægt (count), pris (price) eller antal enheder (count)', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\', \'count\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Hådteringsgebyr/grundbeløb', 'MODULE_SHIPPING_TABLE_HANDLING', '0', '', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Fragtzone', 'MODULE_SHIPPING_TABLE_ZONE', '0', 'Hvis du vælger en zone vil denne metode kun gælde for lande/områder i denne zone, ellers vil den gælde for ALLE kunder.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sorteringsorden', 'MODULE_SHIPPING_TABLE_SORT_ORDER', '0', 'Bestemmre i hvilken rækkefølge fragt modulerne vises for kunden hvis der er flere, laveste nummer vises først.', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_SHIPPING_TABLE_STATUS', 'MODULE_SHIPPING_TABLE_COST', 'MODULE_SHIPPING_TABLE_MODE', 'MODULE_SHIPPING_TABLE_HANDLING', 'MODULE_SHIPPING_TABLE_ZONE', 'MODULE_SHIPPING_TABLE_SORT_ORDER'); } } ?> Link to comment Share on other sites More sharing options...
andy_1984 Posted October 16, 2009 Share Posted October 16, 2009 absolutely fantastic thanks guys Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.