Example #1
0
 function get_order_total()
 {
     global $oOrder;
     $order_total = $oOrder->info['total'];
     // Check if gift voucher is in cart and adjust total
     $products = $_SESSION['cart']->get_products();
     for ($i = 0; $i < count($products); $i++) {
         $t_prid = oos_get_product_id($products[$i]['id']);
         // Get database information
         $dbconn =& oosDBGetConn();
         $oostable =& oosDBGetTables();
         $productstable = $oostable['products'];
         $query = "SELECT products_price, products_tax_class_id, products_model\n                FROM {$productstable}\n                WHERE products_id = '" . intval($t_prid) . "'";
         $gv_result = $dbconn->GetRow($query);
         if (ereg('^GIFT', addslashes($gv_result['products_model']))) {
             $qty = $_SESSION['cart']->get_quantity($t_prid);
             $products_tax = oos_get_tax_rate($gv_result['products_tax_class_id']);
             if ($this->include_tax == '0') {
                 $gv_amount = $gv_result['products_price'] * $qty;
             } else {
                 $gv_amount = ($gv_result['products_price'] + oos_calculate_tax($gv_result['products_price'], $products_tax)) * $qty;
             }
             $order_total = $order_total - $gv_amount;
         }
     }
     if ($this->include_tax == '0') {
         $order_total = $order_total - $oOrder->info['tax'];
     }
     if ($this->include_shipping == '0') {
         $order_total = $order_total - $oOrder->info['shipping_cost'];
     }
     return $order_total;
 }
Example #2
0
if (count(get_included_files()) < 2) {
    header("HTTP/1.1 301 Moved Permanently"); header("Location: /"); exit;
}

if (!defined('OOS_BASE_PRICE')) {
    define('OOS_BASE_PRICE', '0');
}

$_SESSION['navigation']->remove_current_page();

$sLanguage = oos_var_prep_for_os($_SESSION['language']);
require 'includes/languages/' . $sLanguage . '.php';
require 'includes/languages/' . $sLanguage . '/products_info.php';

if (isset($_GET['products_id'])) {
    if (!isset($nProductsId)) $nProductsId = oos_get_product_id($_GET['products_id']);
}

$aOption['popup_print'] = $sTheme . '/products/popup_print.html';

//smarty
require 'includes/classes/class_template.php';
$oSmarty = new Template;

$oSmarty->caching = true;

$popup_cache_id = $sTheme . '|products|' . $nGroupID . '|print|' . $nProductsId . '|' . $sLanguage;

if (!$oSmarty->is_cached($aOption['popup_print'], $popup_cache_id )) {
 
    $productstable = $oostable['products'];
                 $today = date("Y-m-d H:i:s", time());
                 $sql = "INSERT INTO {$products_notificationstable}\n                    (products_id, customers_id,\n                     date_added) VALUES (" . $dbconn->qstr($notify[$i]) . ',' . $dbconn->qstr($_SESSION['customer_id']) . ',' . $dbconn->DBTimeStamp($today) . ")";
                 $dbconn->Execute($sql);
             }
         }
         MyOOS_CoreApi::redirect(oos_href_link($sPage, oos_get_all_get_parameters(array('action')), 'SSL'));
     } else {
         $_SESSION['navigation']->set_snapshot();
         MyOOS_CoreApi::redirect(oos_href_link($aPages['login'], '', 'SSL'));
     }
     break;
 case 'notify_remove':
     $products_notificationstable = $oostable['products_notifications'];
     if (isset($_SESSION['customer_id']) && isset($_GET['products_id'])) {
         if (!isset($nProductsId)) {
             $nProductsId = oos_get_product_id($_GET['products_id']);
         }
         $check_sql = "SELECT COUNT(*) AS total\n                      FROM {$products_notificationstable}\n                      WHERE products_id = '" . intval($nProductsId) . "'\n                      AND customers_id = '" . intval($_SESSION['customer_id']) . "'";
         $check = $dbconn->Execute($check_sql);
         if ($check->fields['total'] > 0) {
             $dbconn->Execute("DELETE FROM {$products_notificationstable} WHERE products_id = '" . intval($nProductsId) . "' AND customers_id = '" . intval($_SESSION['customer_id']) . "'");
         }
         MyOOS_CoreApi::redirect(oos_href_link($sPage, oos_get_all_get_parameters(array('action'))));
     } else {
         $_SESSION['navigation']->set_snapshot();
         MyOOS_CoreApi::redirect(oos_href_link($aPages['login'], '', 'SSL'));
     }
     break;
 case 'cust_order':
     if (isset($_SESSION['customer_id']) && isset($_GET['pid'])) {
         if (oos_has_product_attributes($_GET['pid'])) {

$hidden_field = '';
$shopping_cart_detail = '';
$any_out_of_stock = 0;

if ($_SESSION['cart']->count_contents() > 0) {

    $products = $_SESSION['cart']->get_products();
    for ($i=0, $n=count($products); $i<$n; $i++) {

        // Push all attributes information in an array
        if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
            while (list($option, $value) = each($products[$i]['attributes'])) {

                $products_id = oos_get_product_id($products[$i]['id']);

                $products_optionstable = $oostable['products_options'];
                $products_options_valuestable = $oostable['products_options_values'];
                $products_attributestable = $oostable['products_attributes'];

                if ($value == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
                    $sql = "SELECT popt.products_options_name,
                                   pa.options_values_price, pa.price_prefix
                            FROM $products_optionstable popt,
                                 $products_attributestable pa
                            WHERE pa.products_id = '" . intval($products_id) . "'
                              AND pa.options_id = popt.products_options_id
                              AND pa.options_id = '" . oos_db_input($option) . "'
                              AND popt.products_options_languages_id = '" . intval($nLanguageID) . "'";
                } else {
/**
 * Check if product has attributes
 *
 * @param $products_id
 * @return boolean
 */
function oos_has_product_attributes($products_id)
{

    $products_id = oos_get_product_id($products_id);

    // Get database information
    $dbconn =& oosDBGetConn();
    $oostable =& oosDBGetTables();

    $products_attributestable = $oostable['products_attributes'];
    $query = "SELECT COUNT(*) AS total
              FROM $products_attributestable
              WHERE products_id = '" . intval($products_id) . "'";
    $attributes = $dbconn->Execute($query);
    if ($attributes->fields['total'] > 0) {
        return true;
    } else {
        return false;
    }
}
$wishlist_result_raw = "SELECT products_id, customers_wishlist_date_added\n                        FROM " . $oostable['customers_wishlist'] . "\n                        WHERE customers_wishlist_link_id = '" . oos_db_input($wlid) . "'\n                        ORDER BY customers_wishlist_date_added";
$wishlist_split = new splitPageResults($_GET['page'], MAX_DISPLAY_WISHLIST_PRODUCTS, $wishlist_result_raw, $wishlist_numrows);
$wishlist_result = $dbconn->Execute($wishlist_result_raw);
if (!$wishlist_result->RecordCount()) {
    MyOOS_CoreApi::redirect(oos_href_link($aPages['main'], '', 'NONSSL'));
}
$sql = "SELECT customers_firstname, customers_lastname\n        FROM " . $oostable['customers'] . "\n        WHERE customers_wishlist_link_id = '" . oos_db_input($wlid) . "'";
$customer_result = $dbconn->Execute($sql);
if (!$customer_result->RecordCount()) {
    MyOOS_CoreApi::redirect(oos_href_link($aPages['main'], '', 'NONSSL'));
}
$customer_info = $customer_result->fields;
$customer = $customer_info['customers_firstname'] . ' ' . $customer_info['customers_lastname'] . ': ';
$aWishlist = array();
while ($wishlist = $wishlist_result->fields) {
    $wl_products_id = oos_get_product_id($wishlist['products_id']);
    $sql = "SELECT p.products_id, pd.products_name, pd.products_description, p.products_model,\n                   p.products_image, p.products_price, p.products_base_price, p.products_base_unit,\n                   p.products_discount_allowed, p.products_tax_class_id, p.products_units_id\n            FROM " . $oostable['products'] . " p,\n                 " . $oostable['products_description'] . " pd\n            WHERE p.products_id = '" . intval($wl_products_id) . "'\n              AND pd.products_id = p.products_id\n              AND pd.products_languages_id = '" . intval($nLanguageID) . "'";
    $wishlist_product = $dbconn->GetRow($sql);
    $wishlist_product_price = '';
    $wishlist_product_special_price = '';
    $wishlist_product_discount = 0;
    $wishlist_product_discount_price = '';
    $wishlist_base_product_price = '';
    $wishlist_base_product_special_price = '';
    $wishlist_special_price = '';
    $wishlist_product_price = $oCurrencies->display_price($wishlist_product['products_price'], oos_get_tax_rate($wishlist_product['products_tax_class_id']));
    if ($wishlist_special_price = oos_get_products_special_price($wl_products_id)) {
        $wishlist_product_special_price = $oCurrencies->display_price($wishlist_special_price, oos_get_tax_rate($wishlist_product['products_tax_class_id']));
    } else {
        $wishlist_product_discount = min($wishlist_product['products_discount_allowed'], $_SESSION['member']->group['discount']);
        if ($wishlist_product_discount != 0) {
Example #7
0
 function get_product_price($product_id)
 {
     global $oOrder;
     // Get database information
     $dbconn =& oosDBGetConn();
     $oostable =& oosDBGetTables();
     $products_id = oos_get_product_id($product_id);
     // products price
     $qty = $_SESSION['cart']->contents[$product_id]['qty'];
     $productstable = $oostable['products'];
     $product_query = $dbconn->Execute("SELECT products_id, products_price, products_tax_class_id, products_weight FROM {$productstable} WHERE products_id='" . (int) $product_id . "'");
     if ($product = $product_query->fields) {
         $prid = $product['products_id'];
         $products_tax = oos_get_tax_rate($product['products_tax_class_id']);
         $products_price = $product['products_price'];
         $specialstable = $oostable['specials'];
         $specials_query = $dbconn->Execute("SELECT specials_new_products_price FROM {$specialstable} WHERE products_id = '" . (int) $prid . "' AND status = '1'");
         if ($specials_query->RecordCount()) {
             $specials = $specials_query->fields;
             $products_price = $specials['specials_new_products_price'];
         }
         if ($this->include_tax == '1') {
             $total_price += ($products_price + oos_calculate_tax($products_price, $products_tax)) * $qty;
         } else {
             $total_price += $products_price * $qty;
         }
         // attributes price
         if (isset($_SESSION['cart']->contents[$product_id]['attributes'])) {
             reset($_SESSION['cart']->contents[$product_id]['attributes']);
             while (list($option, $value) = each($_SESSION['cart']->contents[$product_id]['attributes'])) {
                 $products_attributestable = $oostable['products_attributes'];
                 $attribute_price_query = $dbconn->Execute("SELECT options_values_price, price_prefix FROM {$products_attributestable} WHERE products_id = '" . (int) $prid . "' AND options_id = '" . oos_db_input($option) . "' AND options_values_id = '" . oos_db_input($value) . "'");
                 $attribute_price = $attribute_price_query->fields;
                 if ($attribute_price['price_prefix'] == '+') {
                     if ($this->include_tax == '1') {
                         $total_price += $qty * ($attribute_price['options_values_price'] + oos_calculate_tax($attribute_price['options_values_price'], $products_tax));
                     } else {
                         $total_price += $qty * $attribute_price['options_values_price'];
                     }
                 } else {
                     if ($this->include_tax == '1') {
                         $total_price -= $qty * ($attribute_price['options_values_price'] + oos_calculate_tax($attribute_price['options_values_price'], $products_tax));
                     } else {
                         $total_price -= $qty * $attribute_price['options_values_price'];
                     }
                 }
             }
         }
     }
     if ($this->include_shipping == '1') {
         $total_price += $oOrder->info['shipping_cost'];
     }
     return $total_price;
 }
                $dbconn->Execute("UPDATE $productstable
                                  SET products_status = '0'
                                  WHERE products_id = '" . intval(oos_get_product_id($oOrder->products[$i]['id'])) . "'");
            }
        }
    }


// Update products_ordered (for bestsellers list)
    $productstable = $oostable['products'];
    $dbconn->Execute("UPDATE $productstable
                      SET products_ordered = products_ordered + " . sprintf('%d', intval($oOrder->products[$i]['qty'])) . "
                      WHERE products_id = '" . intval(oos_get_product_id($oOrder->products[$i]['id'])) . "'");

    $sql_data_array = array('orders_id' => $insert_id,
                            'products_id' => oos_get_product_id($oOrder->products[$i]['id']),
                            'products_model' => $oOrder->products[$i]['model'],
                            'products_ean' => $oOrder->products[$i]['ean'],
                            'products_name' => $oOrder->products[$i]['name'],
                            'products_price' => $oOrder->products[$i]['price'],
                            'final_price' => $oOrder->products[$i]['final_price'],
                            'products_tax' => $oOrder->products[$i]['tax'],
                            'products_quantity' => $oOrder->products[$i]['qty']);
    oos_db_perform($oostable['orders_products'], $sql_data_array);

    $order_products_id = $dbconn->Insert_ID();
     $oOrderTotalModules->update_credit_account($i);

//------insert customer choosen option to order--------
    $attributes_exist = '0';
    $products_ordered_attributes = '';
 function count_contents_virtual()
 {
     // Get database information
     $dbconn =& oosDBGetConn();
     $oostable =& oosDBGetTables();
     $total_items = 0;
     if (is_array($this->contents)) {
         reset($this->contents);
         while (list($products_id, ) = each($this->contents)) {
             $no_count = false;
             $productstable = $oostable['products'];
             $sql = "SELECT products_model FROM {$productstable} WHERE products_id = '" . intval($products_id) . "'";
             $gv_result = $dbconn->GetRow($sql);
             if (ereg('^GIFT', $gv_result['products_model'])) {
                 $no_count = true;
             }
             if (NO_COUNT_ZERO_WEIGHT == 1) {
                 $productstable = $oostable['products'];
                 $sql = "SELECT products_weight FROM {$productstable} WHERE products_id = '" . oos_get_product_id($products_id) . "'";
                 $gv_result = $dbconn->GetRow($sql);
                 if ($gv_result['products_weight'] <= MINIMUM_WEIGHT) {
                     $no_count = true;
                 }
             }
             if (!$no_count) {
                 $total_items += $this->get_quantity($products_id);
             }
         }
     }
     return $total_items;
 }
Example #10
0
             $stock_left = $stock_values['products_quantity'] - $oOrder->products[$i]['qty'];
         } else {
             $stock_left = $stock_values['products_quantity'];
         }
         $productstable = $oostable['products'];
         $dbconn->Execute("UPDATE {$productstable}\n                              SET products_quantity = '" . oos_db_input($stock_left) . "'\n                              WHERE products_id = '" . intval(oos_get_product_id($oOrder->products[$i]['id'])) . "'");
         if ($stock_left < 1) {
             $productstable = $oostable['products'];
             $dbconn->Execute("UPDATE {$productstable}\n                                  SET products_status = '0'\n                                  WHERE products_id = '" . intval(oos_get_product_id($oOrder->products[$i]['id'])) . "'");
         }
     }
 }
 // Update products_ordered (for bestsellers list)
 $productstable = $oostable['products'];
 $dbconn->Execute("UPDATE {$productstable}\n                      SET products_ordered = products_ordered + " . sprintf('%d', intval($oOrder->products[$i]['qty'])) . "\n                      WHERE products_id = '" . intval(oos_get_product_id($oOrder->products[$i]['id'])) . "'");
 $sql_data_array = array('orders_id' => $insert_id, 'products_id' => oos_get_product_id($oOrder->products[$i]['id']), 'products_model' => $oOrder->products[$i]['model'], 'products_ean' => $oOrder->products[$i]['ean'], 'products_name' => $oOrder->products[$i]['name'], 'products_price' => $oOrder->products[$i]['price'], 'final_price' => $oOrder->products[$i]['final_price'], 'products_tax' => $oOrder->products[$i]['tax'], 'products_quantity' => $oOrder->products[$i]['qty']);
 oos_db_perform($oostable['orders_products'], $sql_data_array);
 $order_products_id = $dbconn->Insert_ID();
 $oOrderTotalModules->update_credit_account($i);
 //------insert customer choosen option to order--------
 $attributes_exist = '0';
 $products_ordered_attributes = '';
 if (isset($oOrder->products[$i]['attributes'])) {
     $attributes_exist = '1';
     for ($j = 0, $n2 = count($oOrder->products[$i]['attributes']); $j < $n2; $j++) {
         if (DOWNLOAD_ENABLED == '1') {
             $products_optionstable = $oostable['products_options'];
             $products_options_valuestable = $oostable['products_options_values'];
             $products_attributestable = $oostable['products_attributes'];
             $products_attributes_downloadtable = $oostable['products_attributes_download'];
             if ($oOrder->products[$i]['attributes'][$j]['value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {