Jump to content


Photo

shipping costs any ideas


  • Please log in to reply
3 replies to this topic

#1 fazzfarrell

fazzfarrell
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 17 October 2006 - 10:22 AM

Hopefully my last problem!

I have a shipping table as follows:
CREATE TABLE `dhl_pricing` (
  `zone_id` int(11) NOT NULL auto_increment,
  `zone_number` int(11) NOT NULL default '0',
  `zone_weight` varchar(20) default '0',
  `zone_price` decimal(5,2) default NULL,
  PRIMARY KEY  (`zone_id`),
  KEY `zone_id` (`zone_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=49 ;

-- 
-- Dumping data for table `dhl_pricing`
-- 

INSERT INTO `dhl_pricing` (`zone_id`, `zone_number`, `zone_weight`, `zone_price`) VALUES 
(1, 1, '0.5', '8.75'),
(2, 1, '1', '10.01'),
(3, 1, '1.5', '10.64'),
(4, 1, '2', '11.28'),
(5, 7, '0.5', '11.12'),
(6, 7, '1', '14.11'),
(7, 7, '1.5', '16.34'),
(8, 7, '2', '17.55'),

AND..
CREATE TABLE `dhl_zoneid` (
  `zone_id` int(11) NOT NULL auto_increment,
  `zone_country` varchar(50) NOT NULL default '',
  `zone_number` int(11) NOT NULL default '0',
  PRIMARY KEY  (`zone_id`),
  KEY `zone_id` (`zone_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=209 ;

-- 
-- Dumping data for table `dhl_zoneid`
-- 

INSERT INTO `dhl_zoneid` (`zone_id`, `zone_country`, `zone_number`) VALUES 
(1, 'UK', 1),
(2, 'AGUILLA', 9),
(3, 'ALBANIA', 5),
(4, 'ALGERIA', 10),
(5, 'ANDORRA', 5),
(6, 'ANGOLA', 10),
(7, 'ANTIGUABARBUDA', 9),


the shiping cost works fine:
<?php
include_once(IMX_DIR . "/../Connections/jag.php");
$IMX_SHIPCALC = new zoneCalc();
$IMX_SHIPCALC->zoneTable = "dhl_zoneid";
$IMX_SHIPCALC->zoneNumberColumn = "zone_number";
$IMX_SHIPCALC->zoneCountryColumn = "zone_country";
$IMX_SHIPCALC->priceTable = "dhl_pricing";
$IMX_SHIPCALC->priceZoneColumn = "zone_number";
$IMX_SHIPCALC->priceWeightColumn = "zone_weight";
$IMX_SHIPCALC->priceAmountColumn = "zone_price";
	$IMX_SHIPCALC->destination = $_SESSION['postConn'];
$IMX_SHIPCALC->weight = $HTTP_SESSION_VARS["icJag"]->col("TotalWeight");
$IMX_SHIPCALC->conn = &$jag;
$IMX_SHIPCALC->dbName = $database_jag;
$HTTP_SESSION_VARS["icJag"]->shippingPrice = $IMX_SHIPCALC->calculate();
?>[CODE]

Untill the weight valur goes above '2' and then reverts to '0.00' is there any script to get around this?
[/code]


#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 17 October 2006 - 10:50 AM

I don't think this is going to help anyone, as you haven't actually provided us with any of the functional code.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 17 October 2006 - 10:57 AM

looks like your table only has data up to 2 pounds. does DHL have a flat rate above that, or do you need more data? if you want to quote the 2lb price for anything over 2lbs, just do a check before you run your calculator:
<?php
$weight = $_SESSION['icJag']->col("TotalWeight");
if ($weight > 2) $weight = 2;
$IMX_SHIPCALC->weight = $weight;
?>

more information about how your provider handles weights over your 2lb limit would be helpful, too.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 fazzfarrell

fazzfarrell
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 17 October 2006 - 11:05 AM

Brill, that works great, just what i needed!

thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users