Exemplo n.º 1
0
function ecom_shipping_main($destination_zip, $destination_country)
{
    global $_TABLES, $_CONF;
    $index = 0;
    $shipping_option;
    //Get Orgin Zipcode
    $config_res = DB_query("SELECT shipping_zipCode  FROM {$_TABLES['ecom_config']}");
    $config_row = DB_fetchArray($config_res);
    //Set packages w, h, l, p, o
    $package_id = 0;
    $c = new shopping_cart($_SESSION['cart']);
    foreach ($c->get_item_array() as $cart_item) {
        $item_res = DB_query("SELECT ecom_item_weight_ounces, ecom_item_weight_pounds, ecom_item_width, ecom_item_height, ecom_item_length, ecom_item_ship_printed, ecom_ship_media, ecom_ship_library, ecom_free_shipping FROM {$_TABLES['ecom_item']} WHERE ecom_item_id = " . $cart_item['id'] . "");
        $item_row = DB_fetchArray($item_res);
        //Only add item if it's not free to ship
        if (!$item_row['ecom_free_shipping']) {
            //For loop for multiple items is quantity is more than 1..
            for ($i = 0; $i < $cart_item['quantity']; $i++) {
                $packages[$package_id]['w'] = $item_row['ecom_item_width'];
                $packages[$package_id]['h'] = $item_row['ecom_item_height'];
                $packages[$package_id]['l'] = $item_row['ecom_item_length'];
                $packages[$package_id]['p'] = $item_row['ecom_item_weight_pounds'];
                $packages[$package_id]['o'] = $item_row['ecom_item_weight_ounces'];
                $packages[$package_id]['bmp'] = $item_row['ecom_item_ship_printed'];
                $packages[$package_id]['media'] = $item_row['ecom_ship_media'];
                $packages[$package_id]['library'] = $item_row['ecom_ship_library'];
                $package_id++;
            }
        }
    }
    //echo "<pre>"; print_r($packages); echo "</pre>"; //uncomment to see package array.
    $error = "";
    //make sure there atleast one package to get shipping cost for
    if ($package_id > 0) {
        //Get all the shippers and call their main function to fill $shipping_option.
        $res = DB_query("SELECT function FROM {$_TABLES['ecom_shipper']} WHERE enabled = true");
        while ($row = DB_fetchArray($res)) {
            require_once 'shipping/' . $row['function'] . "/index.php";
            $function = "ecom_shipping_" . $row['function'];
            $function(&$shipping_option, &$index, $packages, $config_row['shipping_zipCode'], $destination_zip, $destination_country, &$error);
        }
        #descide to return error or shipping options
        if ($error != "") {
            return $error;
        } else {
            return $shipping_option;
        }
    } else {
        //No package to ship. (Donation or downloadable item)
        $shipping_option[0]['description'] = "Free Shipping";
        $shipping_option[0]['price'] = 0.0;
        return $shipping_option;
    }
}
Exemplo n.º 2
0
function draw_cart_contents($T)
{
    global $_TABLES, $_CONF, $LANG_ECOM;
    require_once $_CONF['path'] . "/plugins/ecommerce/shopping_cart.class.php";
    $c = new shopping_cart($_SESSION['cart']);
    //List each item in cart. Add up sub total.
    $cart_total = 0;
    $T->set_var('msg_180', $LANG_ECOM[180]);
    $T->set_var('msg_183', $LANG_ECOM[183]);
    $T->set_var('msg_184', $LANG_ECOM[184]);
    $arr_items = $c->get_item_array();
    $i = 0;
    foreach ($arr_items as $item) {
        $total = $item['price'] * $item['quantity'];
        $T->set_var('name', $item['name']);
        $T->set_var('price', number_format($item['price'], 2));
        $T->set_var('quantity', $item['quantity']);
        $T->set_var('total', number_format($total, 2));
        $T->set_var('num', $i);
        $T->parse('cart_content_row', 'cart_content_row', true);
        $cart_total += $total;
        $i++;
    }
    //Get Sales Tax:
    $tax_code = $_SESSION['country'] . "-" . $_SESSION['state'];
    $tax_rate = 0;
    //Assume sales tax is 0 unless it's found in table
    $tax_res = DB_query("SELECT ecom_tax_amount FROM {$_TABLES['ecom_tax']} WHERE ecom_tax_code = '" . $tax_code . "' AND ecom_tax_enabled = true");
    if (mysql_num_rows($tax_res) > 0) {
        $tax_row = DB_fetchArray($tax_res);
        $tax_rate = $tax_row['ecom_tax_amount'];
    }
    $sales_tax = $cart_total * $tax_rate;
    $grand_total = $cart_total + $sales_tax + $_SESSION['shipping_price'];
    $T->set_var('cart_total', number_format($cart_total, 2));
    $T->set_var('sales_tax', number_format($sales_tax, 2));
    $T->set_var('shipping_description', $_SESSION['shipping_description']);
    $T->set_var('shipping_price', number_format($_SESSION['shipping_price'], 2));
    $T->set_var('grand_total', number_format($grand_total, 2));
    $T->set_var('num_items', $i);
    $T->set_var('cart_total', number_format($cart_total, 2));
    $_SESSION['TotalAmount'] = $grand_total;
    return number_format($grand_total, 2);
}
Exemplo n.º 3
0
function get_cart_information()
{
    global $_TABLES, $_CONF;
    require_once $_CONF['path'] . "/plugins/ecommerce/shopping_cart.class.php";
    $c = new shopping_cart($_SESSION['cart']);
    //List each item in cart. Add up sub total.
    $cart_total = 0;
    $arr_items = $c->get_item_array();
    require_once '../shared_functions.php';
    update_quantity($arr_items);
    foreach ($arr_items as $item) {
        $total = $item['price'] * $item['quantity'];
        $cart_contents .= "<tr>\r\n\t\t\t<td>" . $item['name'] . "</td>\r\n\t\t\t<td>\$" . number_format($item['price'], 2) . "</td>\r\n\t\t\t<td align=\"center\">" . $item['quantity'] . "</td>\r\n\t\t\t<td><b>\$" . number_format($total, 2) . "</b></td></tr>";
        $cart_total += $total;
    }
    $cart['total'] = $cart_total;
    $cart['contents'] = $card_contents;
    $cart['items'] = $arr_items;
    return $cart;
}
Exemplo n.º 4
0
            } else {
                echo "<SCRIPT> window.location = 'check_out_shipping.php' </SCRIPT>";
            }
        }
    }
}
$T = new Template($_CONF['path'] . 'plugins/ecommerce/templates');
$T->set_file(array('check_out' => 'check_out.thtml', 'check_out_row' => 'check_out_row.thtml'));
$T->set_var('msg_2', $LANG_ECOM[2]);
$T->set_var('msg_3', $LANG_ECOM[3]);
$T->set_var('msg_34', $LANG_ECOM[34]);
$T->set_var('msg_35', $LANG_ECOM[35]);
$T->set_var('msg_179', $LANG_ECOM[179]);
$T->set_var('site_url', $_SERVER['PHP_SELF']);
$cart_total = 0;
$arr_items = $c->get_item_array();
foreach ($arr_items as $item) {
    $total = $item['price'] * $item['quantity'];
    $T->set_var('item_id', $item['id']);
    $T->set_var('images', $_ECOM_CONF['images']);
    $T->set_var('name', $item['name']);
    $T->set_var('price', number_format($item['price'], 2));
    $T->set_var('quantity', $item['quantity']);
    $T->set_var('item_total', number_format($total, 2));
    $T->parse('check_out_row', 'check_out_row', true);
    $cart_total += $total;
}
//Set up the template
$T->set_var('total', number_format($cart_total, 2));
$T->set_var('msg_180', $LANG_ECOM[180]);
$T->set_var('msg_181', $LANG_ECOM[181]);