Ejemplo n.º 1
0
function get_item_info(&$item, $item_id = "", $quantity = "")
{
    global $db, $table_prefix, $site_id;
    $dbp = new VA_SQL();
    $dbp->DBType = $db->DBType;
    $dbp->DBDatabase = $db->DBDatabase;
    $dbp->DBHost = $db->DBHost;
    $dbp->DBPort = $db->DBPort;
    $dbp->DBUser = $db->DBUser;
    $dbp->DBPassword = $db->DBPassword;
    $dbp->DBPersistent = $db->DBPersistent;
    $item_id = isset($item["ITEM_ID"]) ? $item["ITEM_ID"] : $item_id;
    $quantity = isset($item["QUANTITY"]) ? $item["QUANTITY"] : $quantity;
    $is_price_edit = isset($item["PRICE_EDIT"]) ? $item["PRICE_EDIT"] : 0;
    if (!$is_price_edit) {
        $quantity_price = get_quantity_price($item_id, $quantity);
        if (is_array($quantity_price) && sizeof($quantity_price) == 3) {
            $item["ITEM_ID"] = $item_id;
            $item["PRICE"] = $quantity_price[0];
            $item["PROPERTIES_DISCOUNT"] = $quantity_price[1];
            $item["DISCOUNT"] = $quantity_price[2];
        } else {
            // check original price
            $price_type = get_session("session_price_type");
            if ($price_type == 1) {
                $price_field = "trade_price";
                $sales_field = "trade_sales";
                $additional_price_field = "trade_additional_price";
            } else {
                $price_field = "price";
                $sales_field = "sales_price";
                $additional_price_field = "additional_price";
            }
            $sql = " SELECT " . $price_field . "," . $sales_field . ",is_sales ";
            $sql .= " FROM " . $table_prefix . "items ";
            $sql .= " WHERE item_id=" . $dbp->tosql($item_id, INTEGER);
            $dbp->query($sql);
            if ($dbp->next_record()) {
                $product_price = calculate_price($dbp->f($price_field), $dbp->f("is_sales"), $dbp->f($sales_field));
            } else {
                $product_price = isset($item["PRICE"]) ? $item["PRICE"] : "";
            }
            $item["ITEM_ID"] = $item_id;
            $item["PRICE"] = $product_price;
            $item["PROPERTIES_DISCOUNT"] = 0;
            $item["DISCOUNT"] = 1;
            // discount applicable
        }
    }
}
Ejemplo n.º 2
0
     write_to("\t\t<" . $schema_type . ":mpn><![CDATA[" . charset_conv($item_code) . "]]></" . $schema_type . ":mpn>" . $eol);
     //if (preg_match('/.*books.*/i', $item_google_type)) {
     //	write_to("\t\t<" . $schema_type . ":isbn>" . $item_code . "</" . $schema_type . ":isbn>" . $eol);
     //}
     //else if (preg_match('/.*media.*/i', $item_google_type) || preg_match('/.*software.*/i', $item_google_type)) {
     //	write_to("\t\t<" . $schema_type . ":upc>" . $item_code . "</" . $schema_type . ":upc>" . $eol);
     //}
     //else {
     //	write_to("\t\t<" . $schema_type . ":gtin>" . $item_code . "</" . $schema_type . ":gtin>" . $eol);
     //}
 } else {
     write_to("\t\t<" . $schema_type . ":mpn><![CDATA[" . substr(md5(microtime()), rand(0, 26), 5) . "]]></" . $schema_type . ":mpn>" . $eol);
 }
 //Customization by Vital - adding product category description
 $specific_item_type = "Wall Stencils";
 $sql = "SELECT c.category_name FROM ( " . $table_prefix . "items_categories ic  LEFT JOIN " . $table_prefix . "categories c ON ic.category_id=c.category_id) WHERE ic.item_id=" . $dbd->tosql($item_id, INTEGER) . " ORDER BY c.category_order";
 $dbd->query($sql);
 if ($dbd->next_record()) {
     if ($dbd->f("category_name")) {
         $specific_item_type = $dbd->f("category_name");
     }
 }
 //END customization
 write_to("\t\t<" . $schema_type . ":product_type>" . htmlspecialchars($item_google_type) . " &gt; " . $specific_item_type . "</" . $schema_type . ":product_type>" . $eol);
 write_to("\t\t<" . $schema_type . ":google_product_category>" . htmlspecialchars($item_google_type) . "</" . $schema_type . ":google_product_category>" . $eol);
 write_to("\t\t<" . $schema_type . ":expiration_date>" . $expiration_date_formatted . "</" . $schema_type . ":expiration_date>" . $eol);
 write_to("\t\t<" . $schema_type . ":condition>" . $google_base_product_condition . "</" . $schema_type . ":condition>" . $eol);
 $description = trim(strip_tags(get_translation($db->f("full_description"))));
 if (!strlen($description)) {
     $description = trim(strip_tags(get_translation($db->f("short_description"))));
 }
Ejemplo n.º 3
0
 $sql = " SELECT item_id,item_code,manufacturer_code,item_name,";
 $sql .= " price,quantity";
 $sql .= " FROM " . $table_prefix . "orders_items WHERE order_id=" . $db->tosql($order_id, INTEGER);
 $db->query($sql);
 while ($db->next_record()) {
     $google_item_id = $db->f("item_id");
     $google_item_name = $db->f("item_name");
     //$google_sku_code = $db->f("manufacturer_code");
     //if (!$google_sku_code) {
     $google_sku_code = $db->f("item_code");
     //}
     $google_price = $db->f("price");
     $google_quantity = $db->f("quantity");
     $google_category = "";
     $count = 0;
     $sql = "SELECT c.category_name FROM " . $table_prefix . "items_categories ic, " . $table_prefix . "categories c WHERE ic.category_id=c.category_id AND ic.item_id=" . $dbh->tosql($google_item_id, INTEGER);
     $dbh->query($sql);
     while ($dbh->next_record()) {
         if ($count > 0) {
             $google_category .= " / ";
         }
         $count++;
         $google_category .= $dbh->f("category_name");
     }
     $t->set_var("google_sku_code", str_replace("\"", "\\\"", htmlspecialchars($google_sku_code)));
     $t->set_var("google_item_name", str_replace(array("\"", "'"), array("\\\"", "\\'"), htmlspecialchars($google_item_name)));
     $t->set_var("google_price", $google_price);
     $t->set_var("google_quantity", $google_quantity);
     $t->set_var("google_category", str_replace(array("\"", "'"), array("\\\"", ""), htmlspecialchars($google_category)));
     $t->sparse("google_items", true);
 }
Ejemplo n.º 4
0
<?php

if (isset($_REQUEST['id']) && isset($_REQUEST['rating']) && is_numeric($_REQUEST['id']) && is_numeric($_REQUEST['rating'])) {
    include_once "../includes/var_definition.php";
    include_once "../includes/constants.php";
    include_once "../includes/db_{$db_lib}.php";
    include_once "../includes/common_functions.php";
    $db = new VA_SQL();
    $db->DBType = $db_type;
    $db->DBDatabase = $db_name;
    $db->DBHost = $db_host;
    $db->DBPort = $db_port;
    $db->DBUser = $db_user;
    $db->DBPassword = $db_password;
    $db->DBPersistent = $db_persistent;
    $product_id = $db->tosql($_REQUEST['id'], INTEGER);
    $sql = "INSERT INTO `va_reviews` (`review_id`, `item_id`, `user_id`, `admin_id`, `recommended`, `approved`, `rating`, `summary`, `user_name`, `user_email`, `remote_address`, `comments`, `admin_id_approved_by`, `admin_id_modified_by`, `date_added`, `date_modified`, `date_approved`) VALUES (NULL, '" . $product_id . "', '0', '0', '1', '1', '" . $db->tosql($_REQUEST['rating'], INTEGER) . "', 'Web', 'Visitor', '*****@*****.**', '" . $_SERVER['REMOTE_ADDR'] . "', 'Fantastic product', NULL, NULL, NOW(), NOW(), NOW())";
    $db->query($sql);
    $votes = get_db_value("SELECT COUNT(*) FROM " . $table_prefix . "reviews WHERE approved=1 AND rating <> 0 AND item_id=" . $product_id);
    $points = get_db_value("SELECT SUM(rating) FROM " . $table_prefix . "reviews WHERE approved=1 AND rating <> 0 AND item_id=" . $product_id);
    $sql = "UPDATE " . $table_prefix . "items SET votes=" . $votes . ", points=" . $points . " WHERE item_id=" . $product_id;
    $db->query($sql);
} else {
    echo "Wrong or missing parameters";
    header('HTTP', true, 500);
}
Ejemplo n.º 5
0
     xml_add_url($item_url);
 }
 if ($show_products) {
     $show_category_id = 0;
     $sql = " SELECT i.item_id, i.friendly_url, i.date_added, i.date_modified ";
     $sql .= " FROM (";
     if ($multisites_version && isset($site_id)) {
         if (isset($site_id)) {
             $sql .= "(";
         }
     }
     $sql .= $table_prefix . "items i LEFT JOIN " . $table_prefix . "items_categories ic ON ic.item_id=i.item_id) ";
     if ($multisites_version && isset($site_id)) {
         $sql .= " LEFT JOIN " . $table_prefix . "items_sites its ON i.sites_all = 0 AND i.item_id = its.item_id)";
     }
     $sql .= " WHERE ic.category_id=" . $dbp->tosql($show_category_id, INTEGER);
     $sql .= " AND i.is_approved=1 AND i.is_showing=1 ";
     $sql .= " AND " . format_binary_for_sql("i.guest_access_level", VIEW_ITEMS_PERM);
     if ($multisites_version) {
         if (isset($site_id)) {
             $sql .= " AND ( i.sites_all = 1 OR its.site_id=" . $db->tosql($site_id, INTEGER, true, false) . ") ";
         } else {
             $sql .= " AND i.sites_all = 1";
         }
     }
     $dbp->query($sql);
     while ($dbp->next_record()) {
         if ($dbp->f("friendly_url") && $friendly_urls) {
             $item_url = $settings["site_url"] . $dbp->f('friendly_url') . $friendly_extension;
         } else {
             $item_url = $settings["site_url"] . "product_details.php?category_id=" . $show_category_id . "&item_id=" . $dbp->f('item_id');
Ejemplo n.º 6
0
function sync_wishlist($user_id)
{
    if (isset($_COOKIE['wishlist_user_id']) && is_numeric($_COOKIE['wishlist_user_id'])) {
        global $db, $table_prefix;
        $dba = new VA_SQL();
        $dba->DBType = $db->DBType;
        $dba->DBDatabase = $db->DBDatabase;
        $dba->DBUser = $db->DBUser;
        $dba->DBPassword = $db->DBPassword;
        $dba->DBHost = $db->DBHost;
        $dba->DBPort = $db->DBPort;
        $dba->DBPersistent = $db->DBPersistent;
        // 1st sync step: add cookie wishlist items to user wishlist items by updating the user_id
        $sql = "UPDATE " . $table_prefix . "saved_items SET user_id=" . $db->tosql($user_id, INTEGER) . " WHERE user_id=" . $db->tosql($_COOKIE['wishlist_user_id'], INTEGER) . " AND item_id NOT IN (SELECT item_id FROM (SELECT DISTINCT item_id FROM va_saved_items WHERE user_id = " . $db->tosql($user_id, INTEGER) . ") AS tmptable)";
        $dba->query($sql);
        // 2nd sync step: get and load items to the cookie wishlist
        $sql = "SELECT DISTINCT item_id, item_name, quantity, price, date_added FROM " . $table_prefix . "saved_items WHERE user_id=" . $db->tosql($user_id, INTEGER) . " AND item_id NOT IN (SELECT item_id FROM (SELECT DISTINCT item_id FROM va_saved_items WHERE user_id = " . $db->tosql($_COOKIE['wishlist_user_id'], INTEGER) . ") AS tmptable)";
        $dba->query($sql);
        if ($dba->next_record()) {
            $wishlist_item_values = "(NULL, 1, '" . $dba->f("item_id") . "', 0, '" . $dba->tosql($_COOKIE['wishlist_user_id'], INTEGER) . "', '1', '" . $dba->f("item_name") . "', '" . $dba->f("quantity") . "', 0, '" . $dba->f("price") . "', TIMESTAMP('" . $dba->f("date_added") . "'))";
            while ($dba->next_record()) {
                $wishlist_item_values .= ",(NULL, 1, '" . $dba->f("item_id") . "', 0, '" . $dba->tosql($_COOKIE['wishlist_user_id'], INTEGER) . "', '1', '" . $dba->f("item_name") . "', '" . $dba->f("quantity") . "', 0, '" . $dba->f("price") . "', TIMESTAMP('" . $dba->f("date_added") . "'))";
            }
            $sql = "INSERT INTO `va_saved_items` (`cart_item_id`, `site_id`, `item_id`, `cart_id`, `user_id`, `type_id`, `item_name`, `quantity`, `quantity_bought`, `price`, `date_added`) VALUES " . $wishlist_item_values;
            $dba->query($sql);
        }
    }
}