Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

free shipping with other shipping method


jwang90

Recommended Posts

We have "Free US domestic ground shipping on order exceed $150" on our site. If your order exceed $150, you do not have any shipping method to choose. Right now, we like to offer UPS 2day, UPS 3day and USPS express to choose for order exceed $150.00.

 

Right now is like this. Please see below.

 

Free shipping for orders over $150.00

 

2nd Day Air $28.03

3 Day Select $19.53

UPS Ground $9.50

 

United States Postal Service

Domestic Express Mail $41.30

Domestic Priority Mail $9.45

 

 

I like to make something like this.

 

Free shipping for orders over $150.00

 

2nd Day Air $28.03

3 Day Select $19.53

UPS Ground $0.00

 

United States Postal Service

Domestic Express Mail $41.30

 

My code does not work out. Please see my code below. And, please give me some ideas. Thank You for your help.

 

 

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 © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

require('includes/classes/http_client.php');

 

// if the customer is not logged on, redirect them to the login page

if (!tep_session_is_registered('customer_id')) {

$navigation->set_snapshot();

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

$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');

}

}

 

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') {

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'] - $order->info['shipping_cost']) >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) && (tep_get_customer_type_id() == 99 || tep_get_customer_type_id() == 5 || tep_get_customer_type_id() == 4)) {

$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

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">

<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">

<!-- 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('checkout_address', tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')) . tep_draw_hidden_field('action', 'process'); ?><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_delivery.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>

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td class="mainWithoutbk"><b><?php echo TABLE_HEADING_SHIPPING_ADDRESS; ?></b></td>

</tr>

</table></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><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="mainWithoutbk" width="50%" valign="top"><?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>'; ?></td>

<td align="right" width="50%" valign="top"><table border="0" cellspacing="0" cellpadding="2">

<tr>

<td class="mainWithoutbk" align="center" valign="top"><?php echo '<b>' . TITLE_SHIPPING_ADDRESS . '</b><br>' . tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?></td>

<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="mainWithoutbk" valign="top"><?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br>'); ?></td>

<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</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="mainWithoutbk"><b><?php echo TABLE_HEADING_SHIPPING_METHOD; ?></b></td>

</tr>

</table></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">

 

<?php

if ($free_shipping == false) {

?>

 

<?php

if (sizeof($quotes) > 1 && sizeof($quotes[0]) > 1) {

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="mainWithoutbk" width="50%" valign="top"><?php echo TEXT_CHOOSE_SHIPPING_METHOD; ?></td>

<td class="mainWithoutbk" width="50%" valign="top" align="right"><?php echo '<b>' . TITLE_PLEASE_SELECT . '</b><br>' . tep_image(DIR_WS_IMAGES . 'arrow_east_south.gif'); ?></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="mainWithoutbk" 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

}

?>

 

 

<?php

 

$radio_buttons = 0;

for ($i=0, $n=sizeof($quotes); $i<$n; $i++) {

if(($order->delivery['country_id'] == 223 || $order->delivery['country_id'] == 38) && $order->delivery['zone_id'] != 2 && $order->delivery['zone_id'] != 20 && $order->delivery['zone_id'] != 21 && $order->delivery['zone_id'] != 52 && $quotes[$i]['id'] == 'international') continue;

if(!($order->delivery['country_id'] == 223 || $order->delivery['country_id'] == 38) && ($quotes[$i]['id'] == 'ups' || $quotes[$i]['id'] == 'usps')) continue;

if(($order->delivery['zone_id'] == 2 || $order->delivery['zone_id'] == 20 || $order->delivery['zone_id'] == 21 || $order->delivery['zone_id'] == 52) && ($quotes[$i]['id'] == 'ups' || $quotes[$i]['id'] == 'usps')) continue;

if($total_weight > 222.9 && $order->delivery['country_id'] == 223 && $quotes[$i]['id'] == 'usps') continue;

if(!(tep_get_customer_type_id() == 1 || tep_get_customer_type_id() == 2 || tep_get_customer_type_id() == 3) && $quotes[$i]['id'] == 'flat') continue;

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td colspan="2"><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="mainWithoutbk" colspan="3"><b><?php echo ($quotes[$i]['id'] == 'usps') ? $quotes[$i]['module'] . '<br>[<font color="#ff0000">Priority Mail usually faster than UPS ground service</font>]' : $quotes[$i]['module']; ?></b>?<?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="mainWithoutbk" 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";

}

?>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="mainWithoutbk" width="75%"><?php echo $quotes[$i]['methods'][$j]['title']; ?></td>

<?php

if ( ($n > 1) || ($n2 > 1) ) {

?>

<td class="mainWithoutbk"><?php if($quotes[$i]['id'] == 'international') { echo "<b>T.B.D.</b>"; } else { echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))); } ?></td>

<td class="mainWithoutbk" align="right"><?php echo tep_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked); ?></td>

<?php

} else {

?>

<td class="mainWithoutbk" align="right" colspan="2"><?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

}

?>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

<?php

$radio_buttons++;

}

}

?>

</table></td>

<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

<?php

}

}

?>

</table><table border="0" width="100%" cellspacing="0" cellpadding="2">

 

<?php

if ($free_shipping == true) {

?>

 

<?php

if (sizeof($quotes) > 1 && sizeof($quotes[0]) > 1) {

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="mainWithoutbk" width="50%" valign="top"><?php echo TEXT_CHOOSE_SHIPPING_METHOD; ?></td>

<td class="mainWithoutbk" width="50%" valign="top" align="right"><?php echo '<b>' . TITLE_PLEASE_SELECT . '</b><br>' . tep_image(DIR_WS_IMAGES . 'arrow_east_south.gif'); ?></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="mainWithoutbk" 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

}

?>

 

<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="mainWithoutbk" 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="mainWithoutbk" 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

 

$radio_buttons = 1;

for ($i=0, $n=sizeof($quotes); $i<$n; $i++) {

if(($order->delivery['country_id'] == 223 || $order->delivery['country_id'] == 38) && $order->delivery['zone_id'] != 2 && $order->delivery['zone_id'] != 20 && $order->delivery['zone_id'] != 21 && $order->delivery['zone_id'] != 52 && $quotes[$i]['id'] == 'international') continue;

if(!($order->delivery['country_id'] == 223 || $order->delivery['country_id'] == 38) && ($quotes[$i]['id'] == 'upss' || $quotes[$i]['id'] == 'usps')) continue;

if(($order->delivery['zone_id'] == 2 || $order->delivery['zone_id'] == 20 || $order->delivery['zone_id'] == 21 || $order->delivery['zone_id'] == 52) && ($quotes[$i]['id'] == 'upss' || $quotes[$i]['id'] == 'usps')) continue;

if($total_weight > 222.9 && $order->delivery['country_id'] == 223 && $quotes[$i]['id'] == 'usps') continue;

if(!(tep_get_customer_type_id() == 1 || tep_get_customer_type_id() == 2 || tep_get_customer_type_id() == 3) && $quotes[$i]['id'] == 'flat') continue;

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td colspan="2"><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="mainWithoutbk" colspan="3"><b><?php echo ($quotes[$i]['id'] == 'usps') ? $quotes[$i]['module'] . '<br>[<font color="#ff0000">Priority Mail usually faster than UPS ground service</font>]' : $quotes[$i]['module']; ?></b>?<?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="mainWithoutbk" 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";

}

?>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="mainWithoutbk" width="75%"><?php echo $quotes[$i]['methods'][$j]['title']; ?></td>

<?php

if ( ($n > 1) || ($n2 > 1) ) {

?>

<td class="mainWithoutbk"><?php if($quotes[$i]['id'] == 'international') { echo "<b>T.B.D.</b>"; } else { echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))); } ?></td>

<td class="mainWithoutbk" align="right"><?php echo tep_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked); ?></td>

<?php

} else {

?>

<td class="mainWithoutbk" align="right" colspan="2"><?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

}

?>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

<?php

$radio_buttons++;

}

}

?>

</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="mainWithoutbk"><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td>

</tr>

</table></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><?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" 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="mainWithoutbk"><?php echo '<b>' . TITLE_CONTINUE_CHECKOUT_PROCEDURE . '</b><br>' . TEXT_CONTINUE_CHECKOUT_PROCEDURE; ?></td>

<td class="mainWithoutbk" 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></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'); ?>

 

 

ups.php

 

 

<?php

/*

$Id: ups.php,v 1.54 2003/04/08 23:23:42 dgw_ Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

class ups {

var $code, $title, $descrption, $icon, $enabled, $types;

 

// class constructor

function ups() {

global $order;

 

$this->code = 'ups';

$this->title = MODULE_SHIPPING_UPS_TEXT_TITLE;

$this->description = MODULE_SHIPPING_UPS_TEXT_DESCRIPTION;

$this->sort_order = MODULE_SHIPPING_UPS_SORT_ORDER;

$this->icon = DIR_WS_ICONS . 'shipping_ups.gif';

$this->tax_class = MODULE_SHIPPING_UPS_TAX_CLASS;

$this->enabled = ((MODULE_SHIPPING_UPS_STATUS == 'True') ? true : false);

 

if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_UPS_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_UPS_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;

}

 

 

 

 

}

 

 

 

$this->types = array('1DM' => 'Next Day Air Early AM',

'1DML' => 'Next Day Air Early AM Letter',

'1DA' => 'Next Day Air',

'1DAL' => 'Next Day Air Letter',

'1DAPI' => 'Next Day Air Intra (Puerto Rico)',

'1DP' => 'Next Day Air Saver',

'1DPL' => 'Next Day Air Saver Letter',

'2DM' => '2nd Day Air AM',

'2DML' => '2nd Day Air AM Letter',

'2DA' => '2nd Day Air(Guarantee to ship out your package within 24hrs)',

'2DAL' => '2nd Day Air Letter',

'3DS' => '3 Day Select',

'GND' => 'UPS Ground',

'GNDCOM' => 'Ground Commercial',

'GNDRES' => 'Ground Residential',

'STD' => 'Canada Standard',

'XPR' => 'Worldwide Express',

'XPRL' => 'worldwide Express Letter',

'XDM' => 'Worldwide Express Plus',

'XDML' => 'Worldwide Express Plus Letter',

'XPD' => 'Worldwide Expedited');

}

 

 

 

// class methods

function quote($method = '') {

global $HTTP_POST_VARS, $order, $shipping_weight, $shipping_num_boxes;

 

 

 

 

 

if ( (tep_not_null($method)) && (isset($this->types[$method])) ) {

$prod = $method;

} else {

$prod = 'GNDRES';

}

 

if ($method) $this->_upsAction('3'); // return a single quote

 

$this->_upsProduct($prod);

 

$country_name = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true);

$this->_upsOrigin(SHIPPING_ORIGIN_ZIP, $country_name['countries_iso_code_2']);

$this->_upsDest($order->delivery['postcode'], $order->delivery['country']['iso_code_2']);

$this->_upsRate(MODULE_SHIPPING_UPS_PICKUP);

$this->_upsContainer(MODULE_SHIPPING_UPS_PACKAGE);

$this->_upsWeight($shipping_weight);

$this->_upsRescom(MODULE_SHIPPING_UPS_RES);

$upsQuote = $this->_upsGetQuote();

 

 

 

if ( (is_array($upsQuote)) && (sizeof($upsQuote) > 0) ) {

$this->quotes = array('id' => $this->code,

'module' => $this->title . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . 'lbs)');

 

$methods = array();

$qsize = sizeof($upsQuote);

for ($i=0; $i<$qsize; $i++) {

list($type, $cost) = each($upsQuote[$i]);

 

 

if ($free_shipping == true) {

 

 

if($type == 'GND' || $type == 'STD' )

$methods[] = array('id' => $type,

'title' => $this->types[$type],

'cost' => (0.00));

 

 

if($type== '3DS' )

$methods[] = array('id' => $type,

'title' => $this->types[$type],

'cost' => ($cost + MODULE_SHIPPING_UPS_HANDLING + '4.00') * $shipping_num_boxes);

 

 

 

 

if($type== '2DA' )

$methods[] = array('id' => $type,

'title' => $this->types[$type],

'cost' => ($cost + MODULE_SHIPPING_UPS_HANDLING + '8.00') * $shipping_num_boxes);

 

}

 

elseif ($free_shipping == false) {

 

 

 

if($type == 'GND' || $type == 'STD' )

$methods[] = array('id' => $type,

'title' => $this->types[$type],

'cost' => ($cost + MODULE_SHIPPING_UPS_HANDLING) * $shipping_num_boxes);

 

 

if($type== '3DS' )

$methods[] = array('id' => $type,

'title' => $this->types[$type],

'cost' => ($cost + MODULE_SHIPPING_UPS_HANDLING + '4.00') * $shipping_num_boxes);

 

 

 

 

if($type== '2DA' )

$methods[] = array('id' => $type,

'title' => $this->types[$type],

'cost' => ($cost + MODULE_SHIPPING_UPS_HANDLING + '8.00') * $shipping_num_boxes);

 

}

 

 

 

 

 

$this->quotes['methods'] = $methods;

 

 

}

 

 

if ($this->tax_class > 0) {

$this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);

}

} else {

$this->quotes = array('module' => $this->title,

'error' => 'An error occured with the UPS shipping calculations.<br>' . $upsQuote . '<br>If you prefer to use UPS as your shipping method, please contact the store owner.');

}

 

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_UPS_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 ('Enable UPS Shipping', 'MODULE_SHIPPING_UPS_STATUS', 'True', 'Do you want to offer UPS shipping?', '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 ('UPS Pickup Method', 'MODULE_SHIPPING_UPS_PICKUP', 'CC', 'How do you give packages to UPS? CC - Customer Counter, RDP - Daily Pickup, OTP - One Time Pickup, LC - Letter Center, OCA - On Call Air', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('UPS Packaging?', 'MODULE_SHIPPING_UPS_PACKAGE', 'CP', 'CP - Your Packaging, ULE - UPS Letter, UT - UPS Tube, UBE - UPS Express Box', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Residential Delivery?', 'MODULE_SHIPPING_UPS_RES', 'RES', 'Quote for Residential (RES) or Commercial Delivery (COM)', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_UPS_HANDLING', '0', 'Handling fee for this shipping method.', '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 ('Tax Class', 'MODULE_SHIPPING_UPS_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', 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 ('Shipping Zone', 'MODULE_SHIPPING_UPS_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '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 ('Sort order of display.', 'MODULE_SHIPPING_UPS_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '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_UPS_STATUS', 'MODULE_SHIPPING_UPS_PICKUP', 'MODULE_SHIPPING_UPS_PACKAGE', 'MODULE_SHIPPING_UPS_RES', 'MODULE_SHIPPING_UPS_HANDLING', 'MODULE_SHIPPING_UPS_TAX_CLASS', 'MODULE_SHIPPING_UPS_ZONE', 'MODULE_SHIPPING_UPS_SORT_ORDER');

}

 

function _upsProduct($prod){

$this->_upsProductCode = $prod;

}

 

function _upsOrigin($postal, $country){

$this->_upsOriginPostalCode = $postal;

$this->_upsOriginCountryCode = $country;

}

 

function _upsDest($postal, $country){

$postal = str_replace(' ', '', $postal);

 

if ($country == 'US') {

$this->_upsDestPostalCode = substr($postal, 0, 5);

} else {

$this->_upsDestPostalCode = $postal;

}

 

$this->_upsDestCountryCode = $country;

}

 

function _upsRate($foo) {

switch ($foo) {

case 'RDP':

$this->_upsRateCode = 'Regular+Daily+Pickup';

break;

case 'OCA':

$this->_upsRateCode = 'On+Call+Air';

break;

case 'OTP':

$this->_upsRateCode = 'One+Time+Pickup';

break;

case 'LC':

$this->_upsRateCode = 'Letter+Center';

break;

case 'CC':

$this->_upsRateCode = 'Customer+Counter';

break;

}

}

 

function _upsContainer($foo) {

switch ($foo) {

case 'CP': // Customer Packaging

$this->_upsContainerCode = '00';

break;

case 'ULE': // UPS Letter Envelope

$this->_upsContainerCode = '01';

break;

case 'UT': // UPS Tube

$this->_upsContainerCode = '03';

break;

case 'UEB': // UPS Express Box

$this->_upsContainerCode = '21';

break;

case 'UW25': // UPS Worldwide 25 kilo

$this->_upsContainerCode = '24';

break;

case 'UW10': // UPS Worldwide 10 kilo

$this->_upsContainerCode = '25';

break;

}

}

 

function _upsWeight($foo) {

$this->_upsPackageWeight = $foo;

}

 

function _upsRescom($foo) {

switch ($foo) {

case 'RES': // Residential Address

$this->_upsResComCode = '1';

break;

case 'COM': // Commercial Address

$this->_upsResComCode = '2';

break;

}

}

 

function _upsAction($action) {

/* 3 - Single Quote

4 - All Available Quotes */

 

$this->_upsActionCode = $action;

}

 

function _upsGetQuote() {

if (!isset($this->_upsActionCode)) $this->_upsActionCode = '4';

 

$request = join('&', array('accept_UPS_license_agreement=yes',

'10_action=' . $this->_upsActionCode,

'13_product=' . $this->_upsProductCode,

'14_origCountry=' . $this->_upsOriginCountryCode,

'15_origPostal=' . $this->_upsOriginPostalCode,

'19_destPostal=' . $this->_upsDestPostalCode,

'22_destCountry=' . $this->_upsDestCountryCode,

'23_weight=' . $this->_upsPackageWeight,

'47_rate_chart=' . $this->_upsRateCode,

'48_container=' . $this->_upsContainerCode,

'49_residential=' . $this->_upsResComCode));

$http = new httpClient();

if ($http->Connect('www.ups.com', 80)) {

$http->addHeader('Host', 'www.ups.com');

$http->addHeader('User-Agent', 'GWSExpert.com');

$http->addHeader('Connection', 'Close');

 

if ($http->Get('/using/services/rave/qcostcgi.cgi?' . $request)) $body = $http->getBody();

 

$http->Disconnect();

} else {

return 'error';

}

 

$body_array = explode("\n", $body);

 

$returnval = array();

$errorret = 'error'; // only return error if NO rates returned

 

$n = sizeof($body_array);

for ($i=0; $i<$n; $i++) {

$result = explode('%', $body_array[$i]);

$errcode = substr($result[0], -1);

switch ($errcode) {

case 3:

if (is_array($returnval)) $returnval[] = array($result[1] => $result[8]);

break;

case 4:

if (is_array($returnval)) $returnval[] = array($result[1] => $result[8]);

break;

case 5:

$errorret = $result[1];

break;

case 6:

if (is_array($returnval)) $returnval[] = array($result[3] => $result[10]);

break;

}

}

if (empty($returnval)) $returnval = $errorret;

 

return $returnval;

}

}

?>

Link to comment
Share on other sites

There is a Free Shipping Plus Others contribution that does this. However, I have had some prblems with it not always working. What I do now is install the FreeAmount module. Be sure to turn off free shipping in order total and it works great.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Hi Jack,

 

Thank You. I just installed FreeAmount module, works great. But this thing is UPS ground do not show 0.00 with free shipping. It may makes customer confuse. any better idea?.....thank you

 

jessie

Maybe this post will help you, I haven't tried it yet, but I have the same predicament.

 

http://www.oscommerce.com/forums/index.php?showtopic=150997&hl=

 

Check the last post....

 

Brian

Brian Christensen

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...