Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Free Shipping on Shipping Estimator osc 2.3


dvale

Recommended Posts

Posted

This module is working nice in my shop but is not taking free shipping.

 

I'm using the regular Free Shipping over $50 that is set by default in the admin of osc and the Free Shipping Per Product 1.2 module I installed.

 

Here is the shipping_estimate.php code

 

<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2012 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
require('includes/classes/http_client.php');

require(DIR_WS_CLASSES . 'order.php');
$order = new order;

if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();

//if (isset($_GET['iso_code_2'])) $order->delivery['iso_code_2']= (int)$_GET['iso_code_2'];
//$order->delivery['iso_code_2']= 'FI';
// $order->delivery['country']= 'FI';
$shp_country_id= $_GET["c"];
$c= $_GET["c"]; // define c so application top can register a new session variable
$countries_array = array();
		 $countries = tep_db_query("select countries_id, countries_name, countries_iso_code_2, countries_iso_code_3 from " . TABLE_COUNTRIES . " WHERE countries_id = '" . (int)$shp_country_id . "'");
 $countries_values = tep_db_fetch_array($countries);
 $countries_array = array('countries_name' => $countries_values['countries_name'],
							 'countries_iso_code_2' => $countries_values['countries_iso_code_2'],
							 'countries_iso_code_3' => $countries_values['countries_iso_code_3']);

$shp_country_iso=$countries_array['countries_iso_code_2'];

$order->delivery['country'] = array(
						 'iso_code_2' => $shp_country_iso,
	 );

}		




// 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');
} elseif (($cartID != $cart->cartID) && tep_session_is_registered('shipping')) {
tep_session_unregister('shipping');
}
$cartID = $cart->cartID = $cart->generate_cart_id();
// 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;

// 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);
?>
<script type="text/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>
<?php
if (tep_count_shipping_modules() > 0) {
?>
<h2><?php //echo TABLE_HEADING_SHIPPING_METHOD; ?></h2>
<?php
if (sizeof($quotes) > 1 && sizeof($quotes[0]) > 1) {
?>
<!-- <div class="contentText">
<div style="float: right;">
 <?php echo '<strong>' . TITLE_PLEASE_SELECT . '</strong>'; ?>
</div>
<?php echo TEXT_CHOOSE_SHIPPING_METHOD; ?>
</div>-->
<?php
} elseif ($free_shipping == false) {
?>
<div class="contentText">
<?php echo TEXT_ENTER_SHIPPING_INFORMATION; ?>
</div>
<?php
}
?>
<div class="contentText">
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
if ($free_shipping == true) {
?>
 <tr>
 <td><strong><?php echo FREE_SHIPPING_TITLE; ?></strong> <?php echo $quotes[$i]['icon']; ?></td>
 </tr>
 <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, 0)">
 <td style="padding-left: 15px;"><?php echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) . tep_draw_hidden_field('shipping', 'free_free'); ?></td>
 </tr>
<?php
} else {
 $radio_buttons = 0;
 for ($i=0, $n=sizeof($quotes); $i<$n; $i++) {
?>
 <tr>
 <td colspan="3"><strong><?php echo $quotes[$i]['module']; ?></strong> <?php if (isset($quotes[$i]['icon']) && tep_not_null($quotes[$i]['icon'])) { echo $quotes[$i]['icon']; } ?></td>
 </tr>
<?php
 if (isset($quotes[$i]['error'])) {
?>
 <tr>
 <td colspan="3"><?php echo $quotes[$i]['error']; ?></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="75%" style="padding-left: 15px;"><?php echo $quotes[$i]['methods'][$j]['title']; ?></td>
<?php
	 if ( ($n > 1) || ($n2 > 1) ) {
?>
 <td><?php echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))); ?></td>
 <td align="right"><?php //echo tep_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked); ?></td>
<?php
	 } else {
?>
 <td align="right" colspan="2"><?php echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))) . tep_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']); ?></td>
<?php
	 }
?>
 </tr>
<?php

	 }
 }
 }
}
?>
</table>
</div>
<?php
}
?>


</form>

 

I think all I need to know is what to set in this code for the shipping_estimate to recognize any free shipping approach.

 

Thanks in advance for the helpers.

Archived

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

×
×
  • Create New...