[TEP-COMMIT] [CVS catalog] the new checkout shipping page based on a CSS layout, and the new shipping
hpdl-OfajU3CKLf1/[email protected] 30 Mar 2005 00:00:09 -0000
| Newsgroups | gmane.comp.web.oscommerce.cvs |
|---|---|
| Message-ID | <[email protected]> |
<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>catalog/catalog/includes</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt>content/pages/<a href="#file1"><span id="added">checkout_shipping.php</span></a></tt></td><td align="right" id="added">+219</td><td></td><td nowrap="nowrap" align="right">added <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages/checkout_shipping.php?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt>modules/checkout/<a href="#file2"><span id="added">shipping.php</span></a></tt></td><td align="right" id="added">+181</td><td></td><td nowrap="nowrap" align="right">added <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/checkout/shipping.php?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td></td><td align="right" id="added">+400</td><td></td><td></td></tr>
</table>
<small id="info">2 added files</small><br />
<pre class="comment">
the new checkout shipping page based on a CSS layout, and the new shipping
checkout module to handle the processing logic
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname" id="added"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content">content</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages">pages</a><br /></span>
<div class="fileheader" id="added"><big><b>checkout_shipping.php</b></big> <small id="info">added at <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages/checkout_shipping.php?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N checkout_shipping.php
--- /dev/null Wed Mar 30 02:00:02 2005
+++ /tmp/cvsAAAEPayFW Wed Mar 30 02:00:06 2005
@@ -0,0 +1,219 @@
</small></pre><pre class="diff" id="added">+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2005 osCommerce
+
+ Released under the GNU General Public License
+*/
+?>
+
+<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;
+ }
+}
+//--></script>
+
+<div class="pageHeading">
+ <span class="pageHeadingImage"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_delivery.gif', HEADING_TITLE_CHECKOUT_SHIPPING, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></span>
+
+ <h1><?php echo HEADING_TITLE_CHECKOUT_SHIPPING; ?></h1>
+</div>
+
+<form name="checkout_address" action="<?php echo tep_href_link(FILENAME_CHECKOUT, 'shipping=process', 'SSL'); ?>" method="post">
+
+<div class="moduleBox">
+ <div class="outsideHeading"><?php echo TABLE_HEADING_SHIPPING_ADDRESS; ?></div>
+
+ <div class="content">
+ <div style="float: right; padding: 0px 0px 10px 20px;">
+ <?php echo tep_address_label($osC_Customer->id, $osC_Session->value('sendto'), true, ' ', '<br>'); ?>
+ </div>
+
+ <div style="float: right; padding: 0px 0px 10px 20px; text-align: center;">
+ <?php echo '<b>' . TITLE_SHIPPING_ADDRESS . '</b><br>' . tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?>
+ </div>
+
+ <?php echo TEXT_CHOOSE_SHIPPING_DESTINATION . '<br><br><a href="' . tep_href_link(FILENAME_CHECKOUT, 'shipping_address', 'SSL') . '">' . tep_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>'; ?>
+ </div>
+</div>
+
+<?php
+ if (tep_count_shipping_modules() > 0) {
+?>
+
+<div class="moduleBox">
+ <div class="outsideHeading"><?php echo TABLE_HEADING_SHIPPING_METHOD; ?></div>
+
+ <div class="content">
+
+<?php
+ if ( (sizeof($quotes) > 1) && (sizeof($quotes[0]) > 1) ) {
+?>
+
+ <div style="float: right; padding: 0px 0px 10px 20px; text-align: center;">
+ <?php echo '<b>' . TITLE_PLEASE_SELECT . '</b><br>' . tep_image(DIR_WS_IMAGES . 'arrow_east_south.gif'); ?>
+ </div>
+
+ <p style="margin-top: 0px;"><?php echo TEXT_CHOOSE_SHIPPING_METHOD; ?></p>
+
+<?php
+ } elseif ($free_shipping == false) {
+?>
+
+ <p style="margin-top: 0px;"><?php echo TEXT_ENTER_SHIPPING_INFORMATION; ?></p>
+
+<?php
+ }
+?>
+
+ <table border="0" width="100%" cellspacing="0" cellpadding="2">
+
+<?php
+ if ($free_shipping == true) {
+?>
+ <tr>
+ <td 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="main" colspan="3"><b><?php echo FREE_SHIPPING_TITLE; ?></b>&nbsp;<?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, $osC_Currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) . osc_draw_hidden_field('shipping', 'free_free'); ?></td>
+ <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
+ </tr>
+ </table></td>
+ </tr>
+<?php
+ } else {
+ $radio_buttons = 0;
+ for ($i=0, $n=sizeof($quotes); $i<$n; $i++) {
+?>
+ <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" colspan="3"><b><?php echo $quotes[$i]['module']; ?></b>&nbsp;<?php if (isset($quotes[$i]['icon']) && tep_not_null($quotes[$i]['icon'])) { echo $quotes[$i]['icon']; } ?></td>
+ <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></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++) {
+ if ( (($n == 1) && ($n2 == 1)) || ($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $osC_Session->value('shipping')) ) {
+ 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";
+ }
+?>
+ <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
+ <td class="main" width="75%"><?php echo $quotes[$i]['methods'][$j]['title']; ?></td>
+<?php
+ if ( ($n > 1) || ($n2 > 1) ) {
+?>
+ <td class="main"><?php echo $osC_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 osc_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $osC_Session->value('shipping')); ?></td>
+<?php
+ } else {
+?>
+ <td class="main" align="right" colspan="2"><?php echo $osC_Currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])) . osc_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']); ?></td>
+<?php
+ }
+?>
+ <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
+ </tr>
+<?php
+ $radio_buttons++;
+ }
+ }
+?>
+ </table></td>
+ </tr>
+<?php
+ }
+ }
+?>
+
+ </table>
+ </div>
+</div>
+
+<?php
+ }
+?>
+
+<div class="moduleBox">
+ <div class="outsideHeading"><?php echo TABLE_HEADING_COMMENTS; ?></div>
+
+ <div class="content">
+ <?php echo osc_draw_textarea_field('comments', ($osC_Session->exists('comments') ? $osC_Session->value('comments') : '')); ?>
+ </div>
+</div>
+
+<div class="moduleBox">
+ <div class="content">
+ <div style="float: right;">
+ <?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?>
+ </div>
+
+ <?php echo '<b>' . TITLE_CONTINUE_CHECKOUT_PROCEDURE . '</b><br>' . TEXT_CONTINUE_CHECKOUT_PROCEDURE_TO_PAYMENT; ?>
+ </div>
+</div>
+
+<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>
+
+</form>
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname" id="added"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules">modules</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/checkout">checkout</a><br /></span>
<div class="fileheader" id="added"><big><b>shipping.php</b></big> <small id="info">added at <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/checkout/shipping.php?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N shipping.php
--- /dev/null Wed Mar 30 02:00:02 2005
+++ /tmp/cvsAAAt1aiJW Wed Mar 30 02:00:07 2005
@@ -0,0 +1,181 @@
</small></pre><pre class="diff" id="added">+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2005 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ require('includes/classes/http_client.php');
+
+ class osC_Checkout_Shipping {
+
+/* Public variables */
+
+ var $page_contents = 'checkout_shipping.php';
+
+/* Private variables */
+
+ var $_module = 'shipping';
+
+/* Class constructor */
+
+ function osC_Checkout_Shipping() {
+ global $osC_Database, $osC_Session, $osC_Customer, $osC_Services, $breadcrumb, $order, $cart, $total_weight, $total_count, $shipping_modules, $pass, $free_shipping, $quotes;
+
+ if ($cart->count_contents() < 1) {
+ tep_redirect(tep_href_link(FILENAME_CHECKOUT, '', 'SSL'));
+ }
+
+ if ($osC_Services->isStarted('breadcrumb')) {
+ $breadcrumb->add(NAVBAR_TITLE_CHECKOUT_SHIPPING, tep_href_link(FILENAME_CHECKOUT, $this->_module, 'SSL'));
+ }
+
+ if ($osC_Customer->hasDefaultAddress() === false) {
+ $this->page_contents = 'shipping_address.php';
+ }
+
+// if no shipping destination address was selected, use the customers own address as default
+ if ($osC_Session->exists('sendto') == false) {
+ $osC_Session->set('sendto', $osC_Customer->default_address_id);
+ } else {
+// verify the selected shipping address
+ $Qcheck = $osC_Database->query('select count(*) as total from :table_address_book where customers_id = :customers_id and address_book_id = :address_book_id');
+ $Qcheck->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
+ $Qcheck->bindInt(':customers_id', $osC_Customer->id);
+ $Qcheck->bindInt(':address_book_id', $osC_Session->value('sendto'));
+ $Qcheck->execute();
+
+ if ($Qcheck->valueInt('total') != 1) {
+ $osC_Session->set('sendto', $osC_Customer->default_address_id);
+
+ $osC_Session->remove('shipping');
+ }
+ }
+
+ $order = new order;
+
+// register a random ID in the session to check throughout the checkout procedure
+// against alterations in the shopping cart contents
+ $osC_Session->set('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') {
+ $false = false;
+
+ $osC_Session->set('shipping', $false);
+ $osC_Session->set('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'] - $order->info['shipping_cost']) >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
+ $free_shipping = true;
+
+ include(DIR_WS_LANGUAGES . $osC_Session->value('language') . '/modules/order_total/ot_shipping.php');
+ }
+ } else {
+ $free_shipping = false;
+ }
+
+// 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
+ if ( ($osC_Session->exists('shipping') == false) || ($osC_Session->exists('shipping') && ($osC_Session->value('shipping') == false) && (tep_count_shipping_modules() > 1)) ) {
+ $osC_Session->set('shipping', $shipping_modules->cheapest());
+ }
+
+ if ($_GET[$this->_module] == 'process') {
+ $this->_process();
+ }
+ }
+
+/* Public methods */
+
+ function getPageContentsFile() {
+ return $this->page_contents;
+ }
+
+/* Private methods */
+
+ function _process() {
+ global $osC_Session, $free_shipping, $shipping_modules;
+
+ if (tep_not_null($_POST['comments'])) {
+ $osC_Session->set('comments', tep_sanitize_string($_POST['comments']));
+ }
+
+ if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) {
+ if (isset($_POST['shipping']) && strpos($_POST['shipping'], '_')) {
+ $osC_Session->set('shipping', $_POST['shipping']);
+
+ list($module, $method) = explode('_', $osC_Session->value('shipping'));
+ if (is_object($GLOBALS[$module]) || ($osC_Session->value('shipping') == 'free_free')) {
+ if ($osC_Session->value('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'])) {
+ $osC_Session->remove('shipping');
+ } else {
+ if (isset($quote[0]['methods'][0]['title']) && isset($quote[0]['methods'][0]['cost'])) {
+ $shipping = array('id' => $osC_Session->value('shipping'),
+ 'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
+ 'cost' => $quote[0]['methods'][0]['cost']);
+
+ $osC_Session->set('shipping', $shipping);
+
+ tep_redirect(tep_href_link(FILENAME_CHECKOUT, 'payment', 'SSL'));
+ }
+ }
+ } else {
+ $osC_Session->remove('shipping');
+ }
+ }
+ } else {
+ $osC_Session->set('shipping', false);
+
+ tep_redirect(tep_href_link(FILENAME_CHECKOUT, 'payment', 'SSL'));
+ }
+ }
+ }
+?>
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.9</small></center>
</body></html>
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click