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; } }
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); }
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; }
$sort = COM_applyFilter($_GET['sort']); $price = COM_applyFilter($_POST['price']); $quantity = COM_applyFilter($_POST['quantity']); $title = COM_applyFilter($_POST['title']); $comment = COM_applyFilter($_POST['comment']); $rating = COM_applyFilter($_POST['rating']); $title = COM_applyFilter($_POST['title']); $comment_id = COM_applyFilter($_POST['comment_id']); $add_search = COM_applyFilter($_POST['add_search']); $edit_comment = COM_applyFilter($_GET['edit_comment']); $url = "products_full.php?id={$id}&catagory_search={$catagory_search}&name_search={$name_search}&sort={$sort}"; $comment = new rating($url, $id); $display = COM_siteHeader(); if (isset($_POST['add_to_cart'])) { require_once $_CONF['path'] . "/plugins/ecommerce/shopping_cart.class.php"; $c = new shopping_cart($_SESSION['cart']); if (isset($_POST['price'])) { $_SESSION['cart'] = $c->add_to_cart($id, "1", $price); } else { $_SESSION['cart'] = $c->add_to_cart($id, $quantity); } } // Add review for the current product if (isset($_POST['add_review'])) { $comment->add_review($title, $comment, $rating); } //Delete Comment if (isset($_GET['delete_comment'])) { $comment->delete_review($_GET['delete_comment']); } //Save edited comment
<?php include '../shopping-cart.php'; if (isset($_GET['one_product'])) { $cart_item = new shopping_cart(); $cart_item->update($_GET['q'], $_GET['one_product']); $cart_item1 = new shopping_cart(); $cart_item1->one_cart_item($_GET['one_product']); $jsondata = json_encode($cart_item1); echo $jsondata; }
<?php include "shopping-cart.php"; if (isset($_GET["id"])) { $cart = new shopping_cart(); if ($cart->is_exist($_GET["id"])) { echo "hamada"; } else { $cart->user_id = 1; $cart->product_id = $_GET["id"]; $cart->date_of_buy = $_GET["date"]; $cart->quantity = 1; $cart->insert(); header('Location: template/basket.php'); } }
session_start(); setcookie("sessionID", session_id(), time() + 31436000); //one year echo "<script>window.location='products.php';</script>"; } } else { session_start(); } require_once '../lib-common.php'; if ($_SESSION['cart'] == "") { //Cart is empty redirect to catalog echo "<script> window.location = 'products.php' </script>"; } $display = COM_siteHeader(); require_once $_CONF['path'] . "/plugins/ecommerce/shopping_cart.class.php"; $c = new shopping_cart($_SESSION['cart']); if (isset($_GET['delete_id'])) { $del_id = COM_applyFilter($_GET['delete_id']); $_SESSION['cart'] = $c->remove_from_cart($del_id); echo "<script> window.location = 'check_out.php' </script>"; } else { if (isset($_POST['update'])) { $count = 0; $cart = ""; $arr_item = $c->get_arr_cart(); foreach ($arr_item as $cart_item) { $item = explode("-", $cart_item); if ($count > 0) { $cart .= ","; } $cart .= $item[0] . "-" . COM_applyFilter($_POST["quantity" . $item[0]]);
<p class="text-muted">You currently have 3 item(s) in your cart.</p> <div class="table-responsive"> <table class="table"> <thead> <tr> <th colspan="2">Product</th> <th>Quantity</th> <th>Unit price</th> <th>Discount</th> <th colspan="2">Total</th> </tr> </thead> <tbody> <?php include "../shopping-cart.php"; $cart = new shopping_cart(); $data = $cart->product_in_cart(); for ($i = 0; $i < count($data); $i++) { ?> <tr> <td> <a href="#"> <img src="img/<?php echo $data[$i]['image_path']; ?> " alt="<?php echo $data[$i]['product_name']; ?> "> </a> </td>
$T->set_file(array('products' => 'products.thtml', 'products_row' => 'products_row.thtml')); $T->set_var('search_trail', $s->get_search_trail()); $T->set_var('catagory_options', $s->get_catagory_option()); $T->set_var('catagory_search', $s->get_catagory()); $T->set_var('name_search', $s->get_name()); $T->set_var('sort_none', $s->get_sort() == "" ? true : false); $T->set_var('sort_price', $s->get_sort() == "price" ? true : false); $T->set_var('msg_22', $LANG_ECOM[22]); $T->set_var('msg_14', $LANG_ECOM[14]); $T->set_var('msg_102', $LANG_ECOM[102]); $T->set_var('msg_143', $LANG_ECOM[143]); //Add item to chart if (isset($_GET['add_id'])) { $add_id = COM_applyFilter($_GET['add_id']); require_once $_CONF['path'] . "/plugins/ecommerce/shopping_cart.class.php"; $c = new shopping_cart($_SESSION['cart']); $_SESSION['cart'] = $c->add_to_cart($add_id, "1"); } //Build the Where clause can only search by catagory and name as of now. if ($s->get_catagory() != "" && $_GET['name_search'] != "") { $where_clause = "ecom_item_name LIKE '%" . $name_search . "%' AND " . get_catagory_list($s->get_catagory()); } else { if ($s->get_catagory() != "") { $where_clause = get_catagory_list($s->get_catagory()); } else { if ($_GET['name_search'] != "") { $where_clause = "ecom_item_name LIKE '%" . $name_search . "%'"; } else { $where_clause = "1=1"; } }