コード例 #1
0
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
include "includes/config.php";
include "includes/session.php";
include "includes/functions.php";
include "includes/arrays.inc.php";
/*if (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
	$_SESSION = array_map('stripslashes_deep', $_SESSION);
}*/
$uspsRequired_Service = array("Express Mail", "Express Mail Hold For Pickup", "Express Mail Sunday/Holiday Delivery", "Priority Mail", "Parcel Post", "Priority Mail Large Flat Rate Box", "\nPriority Mail Medium Flat Rate Box", "Priority Mail Small Flat Rate Box", "Priority Mail Flat Rate Envelope", "Media Mail", "Library Mail");
if (isset($_SESSION["sess_userid"]) and $_SESSION["sess_userid"] != "") {
    $userid = $_SESSION["sess_userid"];
    if (isCartEmpty($userid)) {
        header("Location:viewcart.php");
        exit;
    }
    if (checkDigitalProductsExistsinCart($userid)) {
        header("Location:viewcart.php?msg=cart_error_nondigital");
    }
} else {
    if (isset($_GET['guest_login']) && $_GET['guest_login'] == 1) {
        $guest_login = $_GET['guest_login'];
        $_SESSION['guest_login'] = $guest_login;
        if (isset($_SESSION['guest_login']) && $_SESSION['guest_login'] == 1) {
            $_SESSION["sess_userid"] = '';
        }
    } else {
        if (isVisitorCartEmpty(session_id())) {
 public static function getShippingPriceProduct($productid = 0, $productOptionId = 0, $userId = "", $destination_country = "", $destination_state = "", $destination_zip = "")
 {
     global $tableprefix;
     $adminCurrency = GetAdminCurrency();
     if (isCartEmpty($userId)) {
         clsGenerateShippingControl::getNoShippingControl($product_option_id);
         return 0;
     }
     if (get_magic_quotes_gpc()) {
         $_POST = array_map('stripslashes_deep', $_POST);
         $_GET = array_map('stripslashes_deep', $_GET);
         $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
     }
     if ($destination_country == "" && $destination_state == "" && $destination_zip == "") {
         $userAddress = clsGenerateShippingControl::getuserAddress($userId);
         if (count($userAddress) > 0) {
             $destination_state = $userAddress['state'];
             $destination_country = $userAddress['country'];
             $destination_zip = $userAddress['zip'];
         }
     }
     $uspsRequired_Service = array("Express Mail", "Express Mail Hold For Pickup", "Express Mail Sunday/Holiday Delivery", "Priority Mail", "Parcel Post", "Priority Mail Large Flat Rate Box", "\nPriority Mail Medium Flat Rate Box", "Priority Mail Small Flat Rate Box", "Priority Mail Flat Rate Envelope", "Media Mail", "Library Mail");
     //===================Getting Currency Type=========================
     $currency_attributes = displayCurrencyType();
     $flatrateEnabled = getSettingsValue('enable_flatrate');
     /*display the active template*/
     //set shipping gateway and doing basic settings
     include_once 'fedex/fedex.php';
     $sql = "select * from " . $tableprefix . "fedexsettings ";
     $rs = mysql_query($sql) or die(mysql_error());
     if (mysql_num_rows($rs) > 0) {
         $serviceName = array();
         $row = mysql_fetch_array($rs);
         $fedexaccno = stripslashes($row['FedexAccno']);
         $fedexmeterno = stripslashes($row['FedexMeterno']);
         $weightunits = $row['FedexWeight'];
         $server = $row['FedexServer'];
         $dropoff = stripslashes($row['FedexDropOff']);
         $packageTypes = stripslashes($row['FedexPackage']);
         $sName = $row['FedexService'];
         $currency = $row['FedexCurrency'];
         if ($_SESSION["sessShippingMethod"] == "FDXE") {
             $sarry = $fedexService;
             $shippingTitle = "Fedex Express Shipping";
         } else {
             $sarry = $fedexGroundService;
             $shippingTitle = "Fedex Express Ground Shipping";
         }
     }
     // end num rows check
     switch ($server) {
         case "test":
             $fedexserver = "https://gatewaybeta.fedex.com/GatewayDC";
             break;
         case "production":
             // change this to actual server when go on live
             $fedexserver = "https://gatewaybeta.fedex.com/GatewayDC";
             break;
         default:
             $fedexserver = "https://gatewaybeta.fedex.com/GatewayDC";
             break;
     }
     //// check enabled shipping is usps or not
     include_once "usps/xmlparser.php";
     include_once 'usps/usps.php';
     $shippingTitle = "USPS";
     $sql = "select * from " . $tableprefix . "usps_settings ";
     $rs = mysql_query($sql) or die(mysql_error());
     if (mysql_num_rows($rs) > 0) {
         $row = mysql_fetch_array($rs);
         $uspsid = $row['username'];
         $server = $row['server'];
     }
     // end num rows check
     switch ($server) {
         case "test":
             $uspsserver = "http://testing.shippingapis.com/ShippingAPITest.dll";
             break;
         case "production":
             //change this line when usps is on live
             $uspsserver = "http://Production.ShippingAPIs.com/ShippingAPI.dll";
             break;
         default:
             $uspsserver = "http://testing.shippingapis.com/ShippingAPITest.dll";
             break;
     }
     // end switch
     require_once "ups.php";
     include_once "shipping.php";
     include_once 'http_client.php';
     $shippingTitle = "UPS";
     // Shipping setting for UPS Shipping
     $select_shipping_settings = "SELECT * FROM " . $tableprefix . "shipping_settings";
     $result_shipping_settings = mysql_query($select_shipping_settings);
     if (mysql_num_rows($result_shipping_settings) > 0) {
         $rs_ship = mysql_fetch_array($result_shipping_settings);
         $ups_weight = $rs_ship['nShippingweight'];
         $ups_rate = $rs_ship['ups_rate'];
         $ups_container = $rs_ship['container_type'];
         $ups_type = $rs_ship['address_quote_method'];
     }
     $upsrate = new Ups();
     // select product details
     $select_cart_details = "SELECT prd.product_id,prd.product_name,po.product_option_id,po.product_length,po.product_width,po.product_height,crt.quantity,\n                       po.product_shipping_weight,art.country AS origin_country,art.state AS origin_state,art.zip AS origin_zip,art.artist_id,\n                       art.defaultflatrate,art.additionalflatrate, prd.eUps, prd.eUsps , prd.eFedex , prd.fFlatRateShippingAmount, prd.fAdditionalItemCost\n                       FROM " . $tableprefix . "cart crt\n                       INNER JOIN " . $tableprefix . "product_options po ON crt.product_option_id = po.product_option_id\n                       INNER JOIN " . $tableprefix . "products prd ON prd.product_id = po.product_id\n                       INNER JOIN " . $tableprefix . "artists art ON art.artist_id = prd.product_artist_id\n                       WHERE crt.user_id = '" . mysql_real_escape_string($userId) . "' AND po.product_option_id = '" . mysql_real_escape_string($productOptionId) . "' ORDER BY crt.cart_id";
     $result_cart_details = mysql_query($select_cart_details) or die(mysql_error());
     $_SESSION["SHIPPING_DETAILS"] = array();
     $_SESSION["SHIPPING_TOTAL"] = 0;
     $productArray = array();
     $resultShippingArray = array();
     if (mysql_num_rows($result_cart_details) == 0) {
         //as no products there is no point in staying in shipping options
         clsGenerateShippingControl::getNoShippingControl($product_option_id);
         return 0;
     } else {
         //Now we need to take shipping rates a products
         $cart_details_row = mysql_fetch_array($result_cart_details);
         $shipping_weight = trim($cart_details_row['product_shipping_weight']);
         $origin_country = $cart_details_row['origin_country'];
         $origin_state = $cart_details_row['origin_state'];
         $origin_zip = $cart_details_row['origin_zip'];
         $product_name = $cart_details_row['product_name'];
         $artist_id = $cart_details_row['artist_id'];
         $product_id = $cart_details_row['product_id'];
         $product_option_id = $cart_details_row['product_option_id'];
         $optionsStr = "";
         $optionVal = getProductOptionsName($product_option_id);
         if ($optionVal != "") {
             $optionsStr = "<br>" . $optionVal;
         }
         $productArray[$product_option_id] = $product_name . $optionsStr;
         $quantity = trim($cart_details_row['quantity']);
         $product_length = $cart_details_row['product_length'];
         $product_height = $cart_details_row['product_height'];
         $product_width = $cart_details_row['product_width'];
         // Take product shippings
         $productShippingArray = array();
         if ($cart_details_row['eUps'] == 'Y') {
             $productShippingArray[] = 'UPS';
         }
         if ($cart_details_row['eFedex'] == 'Y') {
             $productShippingArray[] = 'FDXG';
         }
         if ($cart_details_row['eUsps'] == 'Y') {
             $productShippingArray[] = 'USPS';
         }
         if ($cart_details_row['fFlatRateShippingAmount'] > 0) {
             $productShippingArray[] = 'Flat Rate';
             $FlatRateShippingAmount = $cart_details_row['fFlatRateShippingAmount'];
             $AdditionalItemCost = $cart_details_row['fAdditionalItemCost'];
         }
         /*  echo '<br>' . $origin_state;
             echo '<br>' . $origin_country;
             echo '<br>' . $origin_zip;
             echo '<br>' . $destination_state;
             echo '<br>' . $destination_country;
             echo '<br>' . $destination_zip;*/
         //print_r($productShippingArray);
         foreach ($productShippingArray as $key => $shippingMethod) {
             //  $shippingMethod = $value; // set product shipping
             //set for ups only
             $shippingMethod = trim($shippingMethod);
             //======================Getting rates for each product from shipping gateways-Santhosh=================================
             switch ($shippingMethod) {
                 case "FDXE":
                 case "FDXG":
                     $shippingMode = $shippingMethod;
                     if (is_array($sarry)) {
                         // check service is an array or not
                         foreach ($sarry as $serviceNames) {
                             $fedex_shipping_weight = $shipping_weight * $quantity;
                             list($service, $serviceName) = split('-', $serviceNames);
                             $fedex = new Fedex();
                             $fedex->setServer($fedexserver);
                             $fedex->setAccountNumber($fedexaccno);
                             //Get your own - this will not work...
                             $fedex->setMeterNumber($fedexmeterno);
                             //Get your own - this will not work...
                             $fedex->setCarrierCode($shippingMode);
                             $fedex->setDropoffType($dropoff);
                             $fedex->setService($service, $serviceName);
                             $fedex->setPackaging($packageTypes);
                             $fedex->setWeightUnits($weightunits);
                             $fedex->setWeight($fedex_shipping_weight);
                             $fedex->setOriginStateOrProvinceCode($origin_state);
                             $fedex->setOriginPostalCode($origin_zip);
                             $fedex->setOriginCountryCode($origin_country);
                             $fedex->setDestStateOrProvinceCode($destination_state);
                             $fedex->setDestPostalCode($destination_zip);
                             $fedex->setDestCountryCode($destination_country);
                             $fedex->setPayorType("SENDER");
                             $fedexprice = $fedex->getPrice();
                             $fedexrate[] = $fedexprice->price->rate;
                             $fedexerror[] = $fedexprice->error->description;
                             if ($fedexprice->error->description == "" && $fedexprice->serviceName != "" && $fedexprice->price->rate != "") {
                                 $resultShippingArray[$product_option_id][] = array("service_name" => $fedexprice->serviceName, "rate" => $fedexprice->price->rate);
                             }
                         }
                         // end foreach
                     }
                     // end array check
                     break;
                 case "USPS":
                     $usps_shipping_weight = $shipping_weight * $quantity;
                     if ($usps_shipping_weight < 1) {
                         $usps_shipping_weight = 1;
                     }
                     $usps_shipping_weightSplit = explode(".", $usps_shipping_weight);
                     $shipping_pounds = $usps_shipping_weightSplit[0];
                     $ouncelength = count_digit($usps_shipping_weightSplit[1]);
                     if ($ouncelength == 0) {
                         $shipping_ounces = 0;
                     }
                     if ($ouncelength == 1) {
                         $shipping_ounces = $usps_shipping_weightSplit[1] / 10 * 16;
                     }
                     if ($ouncelength == 2) {
                         $shipping_ounces = $usps_shipping_weightSplit[1] / 100 * 16;
                     }
                     if ($ouncelength == 3) {
                         $shipping_ounces = $usps_shipping_weightSplit[1] / 1000 * 16;
                     }
                     if ($ouncelength == 4) {
                         $shipping_ounces = $usps_shipping_weightSplit[1] / 10000 * 16;
                     }
                     $usps = new USPS();
                     if ($server == "test") {
                         $usps->setWeight(10, 5);
                         $usps->setDestZip("20008");
                         $usps->setOrigZip("10022");
                     } else {
                         $usps->setDestZip($destination_zip);
                         $usps->setOrigZip($origin_zip);
                         $usps->setWeight($shipping_pounds, $shipping_ounces);
                     }
                     $usps->setServer($uspsserver);
                     $usps->setUserName($uspsid);
                     $uspspaswd = "";
                     $usps->setPass($uspspaswd);
                     $usps->setService("All");
                     //$usps->setContainer("Flat Rate Box");
                     $usps->setCountry("USA");
                     $usps->setMachinable("true");
                     $usps->setSize("REGULAR");
                     $uspsprice = array();
                     $uspsprice = $usps->getPrice();
                     $special_chars = "&lt;sup&gt;&amp;reg;&lt;/sup&gt;";
                     if ($uspsprice->error->description == "") {
                         foreach ($uspsprice->list as $eachItem) {
                             if ($eachItem->mailservice != "" && $eachItem->rate != "") {
                                 $eachItemServicename = str_replace($special_chars, "", $eachItem->mailservice);
                                 if (in_array($eachItemServicename, $uspsRequired_Service)) {
                                     $resultShippingArray[$product_option_id][] = array("service_name" => $eachItemServicename, "rate" => $eachItem->rate);
                                 }
                             }
                         }
                     }
                     break;
                 case "UPS":
                     $ups_types = clsGenerateShippingControl::getupsShippingTypes();
                     $ups_shipping_weight = $shipping_weight * $quantity;
                     $ups_shipping_weight = $ups_shipping_weight < 0.1 ? 0.1 : $ups_shipping_weight;
                     foreach ($ups_types as $types => $ups) {
                         $upsrate->upsProduct($types);
                         // See upsProduct() function for codes
                         $upsrate->origin($origin_zip, $origin_country);
                         // Use ISO country codes!
                         $upsrate->dest($destination_zip, $destination_country);
                         // Use ISO country codes!
                         $upsrate->rate($ups_rate);
                         // See the rate() function for codes
                         $upsrate->container($ups_container);
                         // See the container() function for codes
                         $upsrate->weight(number_format($ups_shipping_weight, 2, ".", ""));
                         $upsrate->rescom($ups_type);
                         // See the rescom() function for codes
                         $quote = $upsrate->getQuote();
                         if ($quote != "error" && $ups != "" && $quote != "") {
                             $resultShippingArray[$product_option_id][] = array("service_name" => $ups, "rate" => $quote);
                         }
                         // end price empty check
                     }
                     //end foreach
                     break;
                 case "Flat Rate":
                     $flat_rate_name = "Flat Rate";
                     $first_Item_charge = $FlatRateShippingAmount;
                     $additional_Item_charge = $AdditionalItemCost;
                     $rate = $first_Item_charge + $additional_Item_charge * ($quantity - 1);
                     $resultShippingArray[$product_option_id][] = array("service_name" => stripslashes($flat_rate_name), "rate" => $rate);
                 default:
             }
             // if the rate array is empty for other shipping Options check whether
             // admin has enabled the flat rate shipping so that customer can still
             // buy with the flat option.
             $Selected_Shipping_options = $shippingTitle;
             if (empty($selectedShippingOption)) {
                 $selectedShippingOption = $shippingTitle;
             }
             $shipping_options_availabe = count($resultShippingArray[$product_option_id]);
         }
         // end while loop
     }
     return $resultShippingArray;
 }
コード例 #3
0
ファイル: cart_list.php プロジェクト: kraza/ecom
                <tr> <td height="325" align="center" valign="top"><img src="images/feel.jpg" width="176" height="319"></td></tr>
              </table></td>
                <td width="6">&nbsp;</td>
                <td width="561"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td height="20" align="left" valign="top">&nbsp;</td>
                    </tr>
                    <tr> 
                      <td height="31" align="left" valign="middle" background="images/greenbar.gif" style="background-repeat:no-repeat" >&nbsp;&nbsp;&nbsp;<span class="footermenu"><strong><font color="#FFFFFF">store </font></strong></span></td>
                    </tr>
                    <tr> 
                      <td height="20">&nbsp;</td>
                    </tr>
                    <tr> 
                      <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr align="center" valign="top"><?php 
if (isCartEmpty()) {
    echo "<font size='5' color='red'>Your Shopping Cart is Empty</font>";
} else {
    require_once "cartitem.php";
}
?>
 </tr></table></td>
                    </tr>
                    <tr><td align="center" valign="top"> <h1>Our Latest Products</h1></td></tr>
                    <tr> 
                      <td height="10" align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr align="center" valign="top"><?php 
require_once "latest.php";
?>
 </tr>
                      </table></td>
コード例 #4
0
ファイル: menubar.php プロジェクト: kraza/ecom
<tr>
  <td height="75" align="center" valign="middle">
    <table width="720" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="475" height="30" align="left" valign="middle" class="caption"><a href="index.php"><img src="images/logo.jpg" width="150" height="111" border="0"></a></td>
        <td width="114" height="30" align="right" valign="middle" class="cart">&nbsp;</td>
        <td width="130" height="30" align="center" valign="middle"><div align="left" class="style2"><br></div></td>
        <td width="10" height="30">
        	<?php 
if (!isCartEmpty()) {
    ?>
        		<a href="cart_list.php" class="cart"><img src="images/viewcart.jpg"  border="0" /></a>
        	<?php 
}
?>
        </td>
      </tr>
    </table>
  </td>
</tr>
<tr>
  <td height="32" align="center" valign="middle" background="images/menubar.gif">
    <table width="750" border="0" cellspacing="0" cellpadding="0">
      <tr align="center" valign="middle">
        <td width="72" height="25"><a href="index.php" class="footermenu">home</a></td>
        <td width="98" height="25"><a href="about.php" class="footermenu">about us </a></td>
        <td width="71" height="25"><a href="store.php" class="footermenu">store</a></td>
        <td width="187" height="25"><a href="promotionalproducts.php" class="footermenu">promotional products</a></td>
        <td width="139" height="25"><a href="upcomingshow.php" class="footermenu">upcoming shows</a></td>
        <td width="83" height="25"><a href="links.php" class="footermenu">Links</a></td>
        <td width="100" height="25"><a href="contact.php" class="footermenu">contact us</a></td>