Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Shipping mod is unselectable at checkout_shipping.php


shaggy2dope2125

Recommended Posts

I was up all night recoding my mod and finally got it to work. The problem is that when ever item_model, the mod, is installed im not able to select it as a shipping option, the radio button doesn't get displayed. If i have another mod installed, flat, both of them show up and the radio buttons show up next to both of them also. i can select either one of the mods, but flat will be the one that gets sent to checkout_conformation.php. If Item_model is the only one enabled i can not get past the checkout_shipping page.

 

<?php
/*
$Id: item_model.php, V 1.0 2005/14.09 05:03:31 hpd1 Exp $

Written by Kevin Myers, [email protected]

osCommerce, Open Source E-Commerce Solutions
[url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

Copyright © 2003 osCommerce

Copyright ? 2005 Magickoncepts.com

Released under the GNU General Public License
*/
class item_model {
var $code, $title, $description, $icon, $enabled;

// class constructor
function item_model() {
global $order;

$this->code = 'item_model';
$this->title = MODULE_SHIPPING_ITEM_MODEL_TEXT_TITLE;
$this->description = MODULE_SHIPPING_ITEM_MODEL_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_ITEM_MODEL_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_ITEM_MODEL_TAX_CLASS;
$this->enabled = ((MODULE_SHIPPING_ITEM_MODEL_STATUS == 'True') ? true : false);
$this->num_zones = 5;
if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_ITEM_MODEL_ZONE > 0) ) 
{
	$check_flag = false;
	$check_query = tep_db_query("SELECT zone_id FROM " . TABLE_ZONE__TO_GEO_ZONES . " WHERE geo_zone_id = '" . 	MODULE_SHIPPING_ITEM_MODEL_ZONE . "' and zone_county_id '" . $order->delivery['country']['id'] . "' ORDER BY zode_id");
		while ($check = tep_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 $order, $total_count, $order_id, $oID, $cartID, $customer_id;
$dest_country = $order->delivery['country']['iso_code_2'];
$dest_zone = 0;
$error1 = false;
for ($i=1; $s<=$this->num_zones; $i++)
{
$countries_table = constant(MODULE_SHIPPING_ITEM_MODEL_COUNTRIES_ . $i);
$country_zones = split("[,]", $countries_table);
	if(in_Array($dest_country, $country_zones)) 
	{
	$dest_zone = $i;
	break;
	}//ends if statement
}//ends for loop
if ($dest_zone == 0) 
{
	for ($i=1; $i<=$this->num_zones; $i++)
	{
	$countries_table = constant(MODULE_SHIPPING_ITEM_MODEL_COUNTRIES_ . $i);
		if ($countries_table == '' or $countries_table == '*')
		{
		$dest_zone = $i;
		break;
		}
	}
}
if ($dest_zone == 0) 
{
$error1 = true;
}
$this->Cart_contents = tep_db_query("SELECT * FROM " . TABLE_CUSTOMERS_BASKET . " WHERE customers_id = '". (int)$customer_id."'");
$this->num_cards = mysql_num_rows($this->Cart_contents);
$this->Cart_contents = tep_db_fetch_array($this->Cart_contents);
for($x=1;$x<=$this->num_cards;$x++)
{

$this->productsID[$x] = $this->Cart_contents['products_id'];
}
$this->num_products = count($this->productsID);
for($X=1;$X<=$this->num_products;$X++)
{
$product_Info = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS . " WHERE products_id = '". $this->productsID[$X]."'");
$this->products = tep_db_fetch_array($product_Info);
if($this->products['products_model'] == 'single')
{
$singles_count++;
}
elseif($this->products['products_model'] == 'box')
{
$box_count++;
}
elseif($this->products['products_model'] == 'set')
{
$set_count++;
}
elseif($this->products['products_model'] == 'deck')
{
$deck_count++;
}
elseif($this->products['products_model'] == 'lot')
{
$lot_count++;
}
}
if($singles_count < "30")
{
$shipping_singles = 1;
}
else
{
$shipping_singles = 1 + (($singles_count - "30")* .1);
}
$shipping_box = $box_count * 2;
$shipping_set = $set_count * 2;
$shipping_deck = $deck_count * 0.75;
$shipping_lot = $lot_count * 2;
$shipping_total = $shipping_singles + $shipping_box + $shipping_set + $shipping_deck + $shipping_lot;
//this is where i set up the additional charge for each "zone"
if($dest_zone == 1) {
$shipping_total = $shipping_total;
}
elseif($dest_zone == 2) {
$shipping_total = $shipping_total + ($shipping_total * .02);
}
elseif($dest_zone == 3) {
$shipping_total = $shipping_total + ($shipping_total * .025);
}
elseif($dest_zone == 4) {
$shipping_total = $shipping_total + ($shipping_total * .03);
}
elseif($dest_zone == 5) {
$shipping_total = $shipping_total + ($shipping_total * .045);
}//this ends the shipping totals for each zone
$this->quotes = array('id' => $this->code,
				  'module' => MODULE_SHIPPING_ITEM_MODEL_TEXT_TITLE,
				  'methods' => array(array('id' => $this->code,
											'title' => MODULE_SHIPPING_ITEM_MODEL_TEXT_WAY,
											'cost' => $shipping_total
										   )//closes second array
									 )//closes first aray
				  );//closes the qutes array

if ($this->tax_class > 0)
{
$this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
}
if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

return $this->quotes;


}//ends the quote functions

function check() {
if (!isset($this->_check)) {
$check_query = tep_db_query("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'MODULE_SHIPPING_ITEM_MODEL_STATUS'");
$this->_check = tep_db_num_rows($check_query);
}
return $this->_check;
}//ends check function
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 Model Method', 'MODULE_SHIPPING_ITEM_MODEL_STATUS', 'True', 'Do you want to offer Model rate 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, use_function, set_function, date_added)
VALUES ('Tax Class', 'MODULE_SHIPPING_ITEM_MODEL_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, date_added)
VALUES ('Sort Order', 'MODULE_SHIPPING_ITEM_MODEL_SORT_ORDER', '0', 'Sort Order of display.', '6', '0', now())");
for ($i = 1; $i <= $this->num_zones; $i++) {
if ($i == 1) {
$default_countries = 'US';
}
elseif ($i == 2) {
$default_countries = 'CA';
}
elseif ($i == 3) {
$default_countries = 'AT,BE,GB,FR,DE,GL,IS,IE,IT,NO,NL,DK,PL,ES,SE,CH,FI,PT,IL,GR';
}
elseif ($i == 4) {
$default_countries = 'JP,AU,NZ,SG';
}
elseif ($i == 5) {
$default_countries = 'TW,CN,HK';
}//ends the if statments for default countires
//tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Countries', 'MODULE_SHIPPING_ZONES_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".', '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 ('Zone " . $i ." Countries', 'MODULE_SHIPPING_ITEM_MODEL_COUNTRIES_" . $i ."', '" .$default_countries . "', 'Comma seprtated list of two character ISO country codes that are part of zone " . $i . ".', '6', '0', now())");
}//ends the for loop
}//ends the install function

function remove() {

tep_db_query("DELETE FROM " . TABLE_CONFIGURATION . " WHERE configuration_key in ('" . implode(" ', '", $this->keys()) . "')");
}//ends the remove function

function keys() {

$keys = array('MODULE_SHIPPING_ITEM_MODEL_STATUS', 'MODULE_SHIPPING_ITEM_MODEL_TAX_CLASS', 'MODULE_SHIPPING_ITEM_MODEL_SORT_ORDER');

for ($i=1; $i<=$this->num_zones; $i++) {
$keys[] = 'MODULE_SHIPPING_ITEM_MODEL_COUNTRIES_' . $i;
}//ends the for loop
return $keys;
}//ends the keys function

}//ends the modlue
?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...