NOTE: I apologize if this was duplicated - could not find my original post.
I am using CubeCart (v4) for my e-commerce site.
I have attached the code below for three .php files, one of which is the actual shopping cart .php file that uses the other two (UPS and Calc) .php files to acquire shipping cost from UPS.
QUESTION:
Can someone point out the flow, of how the Cart.inc.php file is sending the calculated (total weight) of all products to UPS through the use of the other two files (calc.php and UPS.php) to acquire shipping cost from UPS.
PROBLEM and GOAL:
It passes the total 'actual weight' value to UPS to acquire shipping cost for any of the shipping options you have enabled in CubeCart. The problem is that CubeCart does not support 'Dimensional weight' which is what UPS uses to calculate any "AIR" shipping cost (i.e. Next Day Air, 2nd Day Air). Dimensional weight is the cubic weight (length x width x height) of each package. UPS only uses 'actual weight' for calculating "Ground" shipping cost.
What happens is that CubeCart uses the total 'actual weight' of all products in the shopping cart to acquire shipping cost for both ground and AIR shipping cost. Therefore, ground shipping cost is correct, while AIR shipping cost are lower since actual weight for the products I sell is lower than cubic weight of the package.
I have completed the ability to input the package dimensions of each product, and have it calculate and store the cubic weight of each package and finally calculate the 'total' cubic weight of the contents in the shopping cart. If I could just figure out how the cart.inc.php file passes the value of the 'actual weight' through the other two files (UPS.php and Calc.php) to acquire shipping cost, I could possibly figure out a way to use the 'actual weight' for acquiring shipping cost for ground, and the 'cubic weight' for acquiring shipping cost for all AIR shipping options.
Shopping Cart
Cart.inc.php
<?php
/*
+--------------------------------------------------------------------------
| CubeCart 4
| ========================================
| CubeCart is a registered trade mark of Devellion Limited
| Copyright Devellion Limited 2006. All rights reserved.
| Devellion Limited,
| 5 Bridge Street,
| Bishops Stortford,
| HERTFORDSHIRE.
| CM23 2JU
| UNITED KINGDOM
| http://www.devellion.com
| UK Private Limited Company No. 5323904
| ========================================
| Web: http://www.cubecart.com
| Email: info (at) cubecart (dot) com
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
| Licence Info: http://www.cubecart.com/site/faq/license.php
+--------------------------------------------------------------------------
| cart.inc.php
| ========================================
| Core Checkout & Cart Pages
+--------------------------------------------------------------------------
*/
if(!defined('CC_INI_SET')) die("Access Denied");
session_start(); // required for PayPal Pro
// include lang file
$lang1 = getLang("includes".CC_DS."content".CC_DS."reg.inc.php");
$lang2 = getLang("includes".CC_DS."content".CC_DS."cart.inc.php");
$lang = array_merge($lang1, $lang2);
require_once("classes".CC_DS."cart".CC_DS."shoppingCart.php");
$cart = new cart();
// check the user is logged on
if($_GET['_a']=="step2" && empty($cc_session->ccUserData['customer_id'])) {
httpredir("index.php?_g=co&_a=step1");
}
// if user is logged in an act = cart jump ahead to step2
else if($_GET['_a']=="cart" && $cc_session->ccUserData['customer_id']>0) {
# $basket = $cart->cartContents($cc_session->ccUserData['basket']);
# if (!empty($basket)) {
httpredir("index.php?_g=co&_a=step2");
# }
}
/* start mod: Shipping Estimates - http://cubecart.expandingbrain.com */
if ($config['shipAddressLock'] && !empty($_GET['editDel'])) {
/* not permitted to have different delivery address - change invoice instead */
httpredir('index.php?_a=profile&f=step2');
}
/* end mod: Shipping Estimates - by Estelle */
$basket = $cart->cartContents($cc_session->ccUserData['basket']);
// Flexible Taxes, by Estelle Winterflood
$config_tax_mod = fetchDbConfig("Multiple_Tax_Mod");
if(isset($_GET['remlast'])) {
$cart->unsetVar("invArray");
$cart->removeLastItem();
$refresh = TRUE;
}
if (isset($_GET['remCode'])) {
$cart->removeCoupon($_GET['remCode']);
// lose the post vars
$refresh = TRUE;
}
if (isset($_POST['coupon']) && !empty($_POST['coupon']) && !isset($basket['code'])){
$cart->addCoupon($_POST['coupon']);
// lose post vars
$refresh = TRUE;
}
if(isset($_POST['shipKey']) && $_POST['shipKey']>0) {
$cart->setVar($_POST['shipKey'],"shipKey");
// lose post vars
$refresh = TRUE;
}
/* start mod: Shipping Estimates - http://cubecart.expandingbrain.com */
if (!empty($_POST['shipAddress'])) {
$cart->setVar($_POST['shipAddress'], "shipAddress");
$refresh = TRUE;
}
/* end mod: Shipping Estimates - by Estelle */
if(isset($_POST['delInf'])) {
// start: Flexible Taxes, by Estelle Winterflood
if (isset($_POST['which_field'])){
$delivery = $_POST['delInf'];
if ($_POST['which_field']=="T"){
unset($delivery['county_sel']);
} elseif ($_POST['which_field']=="S") {
$delivery['county'] = $delivery['county_sel'];
unset($delivery['county_sel']);
}
$_POST['delInf'] = $delivery;
}
$cart->setVar($_POST['delInf'],"delInf");
$refresh = TRUE;
}
if(isset($_GET['remove'])) {
$cart->unsetVar("invArray");
$cart->remove($_GET['remove']);
$refresh = true;
}
if (isset($_POST['quan'])) {
$cart->unsetVar('invArray');
foreach ($_POST['quan'] as $key => $value) {
$cart->update($key, $value);
}
$refresh = true;
}
if(isset($_GET['mode']) && $_GET['mode'] == "emptyCart") {
## Empty the cart
$cart->emptyCart();
$refresh = true;
}
if(isset($_POST['productCode']) && !empty($_POST['productCode'])) {
$cart->addByCode($_POST['productCode']);
$refresh = TRUE;
}
if ($refresh) {
$excludeGetVars = array("editDel" => 1, "remCode" => 1, "mode" => 1, "remove" => 1, "remlast" => 1);
httpredir(currentpage($excludeGetVars));
}
CART.INC.PHP CONTINUES BELOW