/* cart.show.php
*
*
*/
require_once("_app.cart.php"); // says this is a cart app
require_once("class.Countries.php");
require_once("class.CartUtils.php");
require_once("class.Cart.php");
require_once("class.MojoProducts.php");
//-----------------------------
$cart = new Cart($pdo);
$data['pageTitle'] = "Shopping Cart";
$data['css'][] = "/cfe/css/cfe.shopbox.css";
// useful numerical amounts for layout
$margin_m1 = '10';
$margin_m2 = '11';
$margin_m3 = '10';
$margin_top = '8';
$cart_width = '90%';
// would be nice to check POST vars, and if there
// if we got here by a post, put all the POSTed vars in SESSION vars
Utils::PostToSessionVars(array());
// get tempID
//
// Get TempInvoiceID from GET...
// ...set from ADDTOCART page, or maybe from the Update button submit logic
$tempId = $_GET['tID'];
if ($tempId == '') {
// try getting the value from the session
$tempId = $_SESSION['tempInvoiceID'];
//echo "tempID after setting form session(tID) is :" . $tempID . ": and it's len is " . strlen($tempID ) . "
\n";
} else {
// we SET the SESSION[tempID] later...
}
///*** add to pageErrors object
if ($tempId == '') { // if tempID is STILL blank...
// do nothing - there will just be no items in cart
// THIS SHOULD CHANGE! we should show some sort of processing arror if there is no tempID
// echo "
Unexpected error - tempID is blank!!! (not found in GET or SESSION)
"; // echo "We should really end the page here and now.
"; } else { //echo "Temp Invoice Num(tempID): <" . $tempID . ">
"; } // place tempID in Session[tempInvoiceID] var, so that we can get it if we come back to this page $_SESSION['tempInvoiceID'] = $tempId; // process condition where quantities have been changed and database must be updated // we need to take all 'txtItemXXX' vars from SESSION and put them into POST // because $cart->updateItemQuantities uses the var values in POST $prefix = 'txtItem'; $i = 1; while (isset($_SESSION[$prefix . 'Qty' . $i])) { $_POST[$prefix . 'Qty' . $i] = $_SESSION[$prefix . 'Qty' . $i]; $_POST[$prefix . 'SaveQty' . $i] = $_SESSION[$prefix . 'SaveQty' . $i]; $_POST[$prefix . 'Number' . $i] = $_SESSION[$prefix . 'Number' . $i]; $i++; } $result = $cart->updateItemQuantities($tempId, $m_numitems, $e); if (defined(CART_NUMITEMS_LIMIT) && CART_NUMITEMS_LIMIT > 0) { if ($m_numitems > CART_NUMITEMS_LIMIT) { // set up for CheckErrors //// $_GET['numitems'] = $m_numitems; //// $_GET['err'] = 'NumItems'; $e->add("Number of items in cart ($m_numitems) is greater than maximum allowed (" . CART_NUMITEMS_LIMIT . ")!"); } } // process condition where coupon code has been set and database must be updated if (isset($_POST['txtCouponCode'])) { $couponCode = $_POST['txtCouponCode']; $_SESSION['txtCouponCode'] = $couponCode; } elseif (isset($_SESSION['txtCouponCode'])) { $couponCode = $_SESSION['txtCouponCode']; } // if DELETE ITEM button hit, URL param 'deleteLineID' will be set // txtItemNumberXX will relate to same lineID, where XX=lineID // itemID will then be the value of txtItemNumberXX POST if (isset($_GET['deletelineID'])) { $lineId = intval($_GET['deletelineID']); $itemId = $_POST['txtItemNumber' . $lineId]; $cart->deleteTempLineitem($tempId, $itemId, $e); // TODO: check for success of this function /* * delete any SESSION vars associated with this line item, because we may have done a * PostToSessionVars before getting here. * don't know if it really matters if we clean this up or not. */ unset($_SESSION['txtItemQty' . $lineId]); unset($_SESSION['txtItemSaveQty' . $lineId]); unset($_SESSION['txtItemNumber' . $lineId]); } // // modify some session variables // // if the state or country has not been set by the SESSION yet, then set explicitly if (!isset($_SESSION['lstCountry'])) $_SESSION['lstCountry'] = STR_COUNTRY_ORIGIN; if (!isset($_SESSION['lstState'])) $_SESSION['lstState'] = STR_STATE_NONE; // fix the ShipMethod // 2006.01.03 chrisl - set this for no ship method choosing - // this needs to be set so that the cart show will function properly, without having to choose a shipmethod ////$_SESSION['txtShipMethod'] = "normal"; // set the ship method based on the country chosen if (STR_COUNTRY_ORIGIN == $_SESSION['lstCountry']) { // interpret as US - use lstShipMethod_domestic's value $_SESSION['txtShipMethod'] = $_SESSION['lstShipMethod_domestic']; } else { // country other than US - use lstShipMethod_global $_SESSION['txtShipMethod'] = $_SESSION['lstShipMethod_global']; } if ('' == $_SESSION['txtShipMethod']) $_SESSION['txtShipMethod'] = STR_SHIPMETHOD_NONE; CheckErrors($e); // checks errors passed in on URL and adds them to $errs object, if any // take care of any Coupons that might be indicated by POST vars $cart->makeCouponDiscounts($tempId, $couponCode, $e); // set up error markup, if any TODO this should change: do it inline $cartErrors = ($e->count() > 0) ? "
|