function vam_get_tax_description($class_id, $country_id = -1, $zone_id = -1) { if ($country_id == -1 && $zone_id == -1) { if (!isset($_SESSION['customer_id'])) { $country_id = STORE_COUNTRY; $zone_id = STORE_ZONE; } else { $country_id = $_SESSION['customer_country_id']; $zone_id = $_SESSION['customer_zone_id']; } } else { $country_id = $country_id; $zone_id = $zone_id; } $tax_query = vamDBquery("select tax_description from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . $country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . $zone_id . "') and tr.tax_class_id = '" . $class_id . "' order by tr.tax_priority"); if (vam_db_num_rows($tax_query, true)) { $tax_description = ''; while ($tax = vam_db_fetch_array($tax_query, true)) { $tax_description .= $tax['tax_description'] . ' + '; } $tax_description = substr($tax_description, 0, -3); return $tax_description; } else { return TEXT_UNKNOWN_TAX_RATE; } }
function permissions_check_for_install() { foreach ($this->req as $id => $require) { if (strtolower($require) == 'jos_commerce') { if (!$this->isJoscom()) { $this->error('This CIP is only for Jos-Commerce environment!'); return $this->error; } continue; } if (strtolower($require) == 'os_commerce') { if ($this->isJoscom()) { $this->error('This CIP is only for OSCommerce environment!'); return $this->error; } continue; } $query = 'select * from ' . TABLE_CIP . ' where cip_ident="' . $require . '"' . ($this->ver[$id] != NULL ? ' and cip_version="' . $this->ver[$id] . '"' : '') . ' and cip_installed=1'; $result = cip_db_query($query, 'return'); if (vam_db_num_rows($result) == 0) { //required CIP not installed $this->error('CIP ' . $require . ' is not installed and is required !'); return $this->error; } } return $this->error; }
function get_data_from_xml_parser($xml_data = '') { $this->data['cip_ident'] = $this->getTagText($xml_data, 'cip', 0); $this->data['cip_version'] = $this->getTagAttr($xml_data, 'cip', 0, 'version'); $active = false; if ($this->data['cip_ident'] == 'jos_commerce') { if ($this->isJoscom()) { $active = true; } } else { $query = 'select * from ' . TABLE_CIP . ' where cip_ident="' . $this->data['cip_ident'] . '"' . ($this->data['cip_version'] == NULL ? '' : ' and cip_version="' . $this->data['cip_version'] . '"') . ' and cip_installed=1'; $result = cip_db_query($query, 'return'); $active = vam_db_num_rows($result) > 0; } if ($active) { //if cip installed $obj = $xml_data->getElementsByTagName('active'); if (is_object($obj)) { $mtag = $obj->item(0); } } else { $obj = $xml_data->getElementsByTagName('inactive'); if (is_object($obj)) { $mtag = $obj->item(0); } } if (is_object($mtag)) { $this->getSubTags($mtag); } }
function vam_display_banner($action, $identifier) { if ($action == 'dynamic') { $banners_query = vam_db_query("select count(*) as count from " . TABLE_BANNERS . " where status = '1' and banners_group = '" . $identifier . "'"); $banners = vam_db_fetch_array($banners_query); if ($banners['count'] > 0) { $banner = vam_random_select("select banners_id, banners_title, banners_image, banners_html_text from " . TABLE_BANNERS . " where status = '1' and banners_group = '" . $identifier . "'"); } else { return '<b>VaM Shop ERROR! (vam_display_banner(' . $action . ', ' . $identifier . ') -> No banners with group \'' . $identifier . '\' found!</b>'; } } elseif ($action == 'static') { if (is_array($identifier)) { $banner = $identifier; } else { $banner_query = vam_db_query("select banners_id, banners_title, banners_image, banners_html_text from " . TABLE_BANNERS . " where status = '1' and banners_id = '" . $identifier . "'"); if (vam_db_num_rows($banner_query)) { $banner = vam_db_fetch_array($banner_query); } else { return '<b>VaM Shop ERROR! (vam_display_banner(' . $action . ', ' . $identifier . ') -> Banner with ID \'' . $identifier . '\' not found, or status inactive</b>'; } } } else { return '<b>VaM Shop ERROR! (vam_display_banner(' . $action . ', ' . $identifier . ') -> Unknown $action parameter value - it must be either \'dynamic\' or \'static\'</b>'; } if (vam_not_null($banner['banners_html_text'])) { $banner_string = $banner['banners_html_text']; } else { $banner_string = '<a href="' . vam_href_link(FILENAME_REDIRECT, 'action=banner&goto=' . $banner['banners_id']) . '" onclick="window.open(this.href); return false;">' . vam_image(DIR_WS_IMAGES . 'banner/' . $banner['banners_image'], $banner['banners_title']) . '</a>'; } vam_update_banner_display_count($banner['banners_id']); return $banner_string; }
function query($order_id) { $order_query = vam_db_query("select customers_name,\n customers_cid,\n customers_id,\n customers_vat_id,\n customers_company,\n customers_street_address,\n customers_suburb,\n customers_city,\n customers_postcode,\n customers_state,\n customers_country,\n customers_telephone,\n customers_email_address,\n customers_address_format_id,\n delivery_name,\n delivery_company,\n delivery_street_address,\n delivery_suburb,\n delivery_city,\n delivery_postcode,\n delivery_state,\n delivery_country,\n delivery_address_format_id,\n billing_name,\n billing_company,\n billing_street_address,\n billing_suburb,\n billing_city,\n billing_postcode,\n billing_state,\n billing_country,\n billing_address_format_id,\n payment_method,\n payment_class,\n\t\t\t\t shipping_class,\n\t\t\t\t cc_type,\n cc_owner,\n cc_number,\n cc_expires,\n cc_cvv,\n comments,\n currency,\n currency_value,\n date_purchased,\n orders_status,\n last_modified,\n orig_reference, \n login_reference,\n customers_status,\n customers_status_name,\n customers_status_image,\n customers_ip,\n language,\n customers_status_discount\n from " . TABLE_ORDERS . " where\n orders_id = '" . vam_db_input($order_id) . "'"); $order = vam_db_fetch_array($order_query); $totals_query = vam_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . vam_db_input($order_id) . "' order by sort_order"); while ($totals = vam_db_fetch_array($totals_query)) { $this->totals[] = array('title' => $totals['title'], 'text' => $totals['text']); } $this->info = array('currency' => $order['currency'], 'currency_value' => $order['currency_value'], 'payment_method' => $order['payment_method'], 'payment_class' => $order['payment_class'], 'shipping_class' => $order['shipping_class'], 'status' => $order['customers_status'], 'status_name' => $order['customers_status_name'], 'status_image' => $order['customers_status_image'], 'status_discount' => $order['customers_status_discount'], 'cc_type' => $order['cc_type'], 'cc_owner' => $order['cc_owner'], 'cc_number' => $order['cc_number'], 'cc_expires' => $order['cc_expires'], 'cc_cvv' => $order['cc_cvv'], 'comments' => $order['comments'], 'language' => $order['language'], 'date_purchased' => $order['date_purchased'], 'orders_status' => $order['orders_status'], 'last_modified' => $order['last_modified']); $this->customer = array('name' => $order['customers_name'], 'company' => $order['customers_company'], 'csID' => $order['customers_cid'], 'vat_id' => $order['customers_vat_id'], 'shop_id' => $order['shop_id'], 'ID' => $order['customers_id'], 'cIP' => $order['customers_ip'], 'street_address' => $order['customers_street_address'], 'suburb' => $order['customers_suburb'], 'city' => $order['customers_city'], 'postcode' => $order['customers_postcode'], 'state' => $order['customers_state'], 'country' => $order['customers_country'], 'format_id' => $order['customers_address_format_id'], 'telephone' => $order['customers_telephone'], 'email_address' => $order['customers_email_address'], 'orig_reference' => $order['orig_reference'], 'login_reference' => $order['login_reference']); $this->delivery = array('name' => $order['delivery_name'], 'company' => $order['delivery_company'], 'street_address' => $order['delivery_street_address'], 'suburb' => $order['delivery_suburb'], 'city' => $order['delivery_city'], 'postcode' => $order['delivery_postcode'], 'state' => $order['delivery_state'], 'country' => $order['delivery_country'], 'format_id' => $order['delivery_address_format_id']); $this->billing = array('name' => $order['billing_name'], 'company' => $order['billing_company'], 'street_address' => $order['billing_street_address'], 'suburb' => $order['billing_suburb'], 'city' => $order['billing_city'], 'postcode' => $order['billing_postcode'], 'state' => $order['billing_state'], 'country' => $order['billing_country'], 'format_id' => $order['billing_address_format_id']); $index = 0; $orders_products_query = vam_db_query("select\n orders_products_id,products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price,allow_tax, products_discount_made\n from\n " . TABLE_ORDERS_PRODUCTS . "\n where\n orders_id ='" . vam_db_input($order_id) . "'"); while ($orders_products = vam_db_fetch_array($orders_products_query)) { $this->products[$index] = array('qty' => $orders_products['products_quantity'], 'name' => $orders_products['products_name'], 'id' => $orders_products['products_id'], 'opid' => $orders_products['orders_products_id'], 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'price' => $orders_products['products_price'], 'discount' => $orders_products['products_discount_made'], 'final_price' => $orders_products['final_price'], 'allow_tax' => $orders_products['allow_tax']); $subindex = 0; $attributes_query = vam_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . vam_db_input($order_id) . "' and orders_products_id = '" . $orders_products['orders_products_id'] . "'"); if (vam_db_num_rows($attributes_query)) { while ($attributes = vam_db_fetch_array($attributes_query)) { $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price']); $subindex++; } } $index++; } }
function vam_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) { if ($country_id == -1 && $zone_id == -1) { if (!isset($_SESSION['customer_id'])) { $country_id = STORE_COUNTRY; $zone_id = STORE_ZONE; } else { $country_id = $_SESSION['customer_country_id']; $zone_id = $_SESSION['customer_zone_id']; } } else { $country_id = $country_id; $zone_id = $zone_id; } $tax_query = vamDBquery("select sum(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . $country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . $zone_id . "') and tr.tax_class_id = '" . $class_id . "' group by tr.tax_priority"); if (vam_db_num_rows($tax_query, true)) { $tax_multiplier = 1.0; while ($tax = vam_db_fetch_array($tax_query, true)) { $tax_multiplier *= 1.0 + $tax['tax_rate'] / 100; } return ($tax_multiplier - 1.0) * 100; } else { return 0; } }
function check() { if (!isset($this->_check)) { $check_query = vam_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_TOTAL_STATUS'"); $this->_check = vam_db_num_rows($check_query); } return $this->_check; }
function vam_expire_specials() { $specials_query = vam_db_query("select specials_id from " . TABLE_SPECIALS . " where status = '1' and now() >= expires_date and expires_date > 0"); if (vam_db_num_rows($specials_query)) { while ($specials = vam_db_fetch_array($specials_query)) { vam_set_specials_status($specials['specials_id'], '0'); } } }
function vam_get_address_format_id($country_id) { $address_format_query = vam_db_query("select address_format_id as format_id from " . TABLE_COUNTRIES . " where countries_id = '" . $country_id . "'"); if (vam_db_num_rows($address_format_query)) { $address_format = vam_db_fetch_array($address_format_query); return $address_format['format_id']; } else { return '1'; } }
function db_query($blz) { $blz_query = vam_db_query("SELECT * from " . TABLE_BANKTRANSFER . " WHERE blz = '" . $blz . "'"); if (vam_db_num_rows($blz_query)) { $data = vam_db_fetch_array($blz_query); } else { $data = -1; } return $data; }
function vam_get_zone_name($country_id, $zone_id, $default_zone) { $zone_query = vam_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . $country_id . "' and zone_id = '" . $zone_id . "'"); if (vam_db_num_rows($zone_query)) { $zone = vam_db_fetch_array($zone_query); return $zone['zone_name']; } else { return $default_zone; } }
function query($order_id) { global $shipping; $order_query = vam_db_query("select * from " . TABLE_ORDERS . " where orders_id = '" . (int) $order_id . "'"); $order = vam_db_fetch_array($order_query); $totals_query = vam_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int) $order_id . "' order by sort_order"); while ($totals = vam_db_fetch_array($totals_query)) { $this->totals[] = array('title' => $totals['title'], 'text' => $totals['text'], 'class' => $totals['class'], 'value' => $totals['value'], 'sort_order' => $totals['sort_order'], 'orders_total_id' => $totals['orders_total_id']); } $this->info = array('currency' => $order['currency'], 'currency_value' => $order['currency_value'], 'payment_method' => $order['payment_method'], 'payment_class' => $order['payment_class'], 'shipping_class' => $order['shipping_class'], 'status' => $order['customers_status'], 'status_name' => $order['customers_status_name'], 'status_image' => $order['customers_status_image'], 'status_discount' => $order['customers_status_discount'], 'cc_type' => $order['cc_type'], 'cc_owner' => $order['cc_owner'], 'cc_number' => $order['cc_number'], 'cc_expires' => $order['cc_expires'], 'cc_cvv' => $order['cc_cvv'], 'comments' => $order['comments'], 'language' => $order['language'], 'date_purchased' => $order['date_purchased'], 'orders_status' => $order['orders_status'], 'last_modified' => $order['last_modified'], 'shipping_method' => $shipping['title'], 'shipping_cost' => $shipping['cost'], 'shipping_id' => $order['shipping_module'], 'subtotal' => 0, 'tax' => 0, 'tax_groups' => array()); $this->customer = array('name' => $order['customers_name'], 'company' => $order['customers_company'], 'csID' => $order['customers_cid'], 'vat_id' => $order['customers_vat_id'], 'shop_id' => $order['shop_id'], 'ID' => $order['customers_id'], 'cIP' => $order['customers_ip'], 'street_address' => $order['customers_street_address'], 'suburb' => $order['customers_suburb'], 'city' => $order['customers_city'], 'postcode' => $order['customers_postcode'], 'state' => $order['customers_state'], 'country' => $order['customers_country'], 'country_id' => oe_get_country_id($order['customers_country']), 'zone_id' => oe_get_zone_id(oe_get_country_id($order['customers_country']), $order['customers_state']), 'format_id' => $order['customers_address_format_id'], 'telephone' => $order['customers_telephone'], 'email_address' => $order['customers_email_address'], 'orig_reference' => $order['orig_reference'], 'login_reference' => $order['login_reference']); $this->delivery = array('name' => $order['delivery_name'], 'company' => $order['delivery_company'], 'street_address' => $order['delivery_street_address'], 'suburb' => $order['delivery_suburb'], 'city' => $order['delivery_city'], 'postcode' => $order['delivery_postcode'], 'state' => $order['delivery_state'], 'country' => $order['delivery_country'], 'country_id' => oe_get_country_id($order['delivery_country']), 'zone_id' => oe_get_zone_id(oe_get_country_id($order['delivery_country']), $order['delivery_state']), 'format_id' => $order['delivery_address_format_id']); $this->billing = array('name' => $order['billing_name'], 'company' => $order['billing_company'], 'street_address' => $order['billing_street_address'], 'suburb' => $order['billing_suburb'], 'city' => $order['billing_city'], 'postcode' => $order['billing_postcode'], 'state' => $order['billing_state'], 'country' => $order['billing_country'], 'country_id' => oe_get_country_id($order['billing_country']), 'zone_id' => oe_get_zone_id(oe_get_country_id($order['billing_country']), $order['billing_state']), 'format_id' => $order['billing_address_format_id']); $index = 0; $orders_products_query = vam_db_query("select orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int) $order_id . "' order by orders_products_id"); while ($orders_products = vam_db_fetch_array($orders_products_query)) { $orders_products_tax_query = vam_db_query("select products_tax_class_id from " . TABLE_PRODUCTS . " where products_id = " . $orders_products['products_id'] . ""); $orders_products_tax = vam_db_fetch_array($orders_products_tax_query); $this->products[$index] = array('qty' => $orders_products['products_quantity'], 'name' => $orders_products['products_name'], 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'tax_description' => vam_get_tax_description($orders_products_tax['products_tax_class_id'], $this->delivery["country_id"], $this->delivery["zone_id"]), 'price' => $orders_products['products_price'], 'final_price' => $orders_products['products_price'] * $orders_products['products_quantity'], 'products_id' => $orders_products['products_id'], 'orders_products_id' => $orders_products['orders_products_id']); $subindex = 0; $attributes_query = vam_db_query("select products_options, products_options_values, options_values_price, price_prefix, orders_products_attributes_id from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int) $order_id . "' and orders_products_id = '" . (int) $orders_products['orders_products_id'] . "'"); if (vam_db_num_rows($attributes_query)) { while ($attributes = vam_db_fetch_array($attributes_query)) { $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price'], 'orders_products_attributes_id' => $attributes['orders_products_attributes_id']); $subindex++; } } $shown_price = vam_add_tax($this->products[$index]['price'], $this->products[$index]['tax']) * $this->products[$index]['qty']; $this->info['subtotal'] += $shown_price; $products_tax = $this->products[$index]['tax']; $products_tax_description = $this->products[$index]['tax_description']; if (DISPLAY_PRICE_WITH_TAX == 'true') { $this->info['tax'] += $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)); if (isset($this->info['tax_groups']["{$products_tax_description}"])) { $this->info['tax_groups']["{$products_tax_description}"] += $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)); } else { $this->info['tax_groups']["{$products_tax_description}"] = $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)); } } else { $this->info['tax'] += $products_tax / 100 * $shown_price; if (isset($this->info['tax_groups']["{$products_tax_description}"])) { $this->info['tax_groups']["{$products_tax_description}"] += $products_tax / 100 * $shown_price; } else { $this->info['tax_groups']["{$products_tax_description}"] = $products_tax / 100 * $shown_price; } } $index++; } if (DISPLAY_PRICE_WITH_TAX == 'true') { $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost']; } else { $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost']; } }
function vam_get_tax_class_rate($tax_class_id) { $tax_multiplier = 0; $tax_query = vam_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " WHERE tax_class_id = '" . $tax_class_id . "' GROUP BY tax_priority"); if (vam_db_num_rows($tax_query)) { while ($tax = vam_db_fetch_array($tax_query)) { $tax_multiplier += $tax['tax_rate']; } } return $tax_multiplier; }
function vam_get_spsr_zone_id($zone_id) { $spsr_zone_query = vam_db_query("select spsr_zone_id from " . TABLE_SPSR_ZONES . " where zone_id = '" . $zone_id . "'"); if (vam_db_num_rows($spsr_zone_query)) { $spsr_zone = vam_db_fetch_array($spsr_zone_query); $spsr_zone_id = $spsr_zone['spsr_zone_id']; return $spsr_zone_id; } else { return false; } }
function vam_activate_banners() { $banners_query = vam_db_query("select banners_id, date_scheduled from " . TABLE_BANNERS . " where date_scheduled != ''"); if (vam_db_num_rows($banners_query)) { while ($banners = vam_db_fetch_array($banners_query)) { if (date('Y-m-d H:i:s') >= $banners['date_scheduled']) { vam_set_banner_status($banners['banners_id'], '1'); } } } }
function checkAttribute($current_value_id, $current_pid, $current_product_option_id) { global $attribute_value_price, $sortorder, $attribute_value_weight, $attribute_value_weight_prefix, $attribute_value_prefix, $attribute_value_model, $products_attributes_is_pin, $attribute_value_stock, $posCheck, $negCheck, $posCheck_weight, $negCheck_weight, $attribute_value_download_count, $attribute_value_download_expire, $attribute_value_download_filename; $query = "SELECT * FROM " . TABLE_PRODUCTS_ATTRIBUTES . " where options_values_id = '" . $current_value_id . "' AND products_id = ' " . $current_pid . "' AND options_id = '" . $current_product_option_id . "'"; $result = vam_db_query($query); $isFound = vam_db_num_rows($result); if ($isFound) { while ($line = vam_db_fetch_array($result)) { // download function start $dl_sql = vam_db_query("SELECT products_attributes_maxdays, products_attributes_filename, products_attributes_maxcount, products_attributes_is_pin FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " WHERE products_attributes_id = '" . $line['products_attributes_id'] . "'") or die(mysql_error()); $dl_res = vam_db_fetch_array($dl_sql); $attribute_value_download_filename = $dl_res['products_attributes_filename']; $attribute_value_download_count = $dl_res['products_attributes_maxcount']; $attribute_value_download_expire = $dl_res['products_attributes_maxdays']; $products_attributes_is_pin = $dl_res['products_attributes_is_pin']; // download function end $attribute_value_price = $line['options_values_price']; $sortorder = $line['sortorder']; $attribute_value_prefix = $line['price_prefix']; $attribute_value_weight_prefix = $line['weight_prefix']; $attribute_value_model = $line['attributes_model']; $attribute_value_stock = $line['attributes_stock']; $attribute_value_weight = $line['options_values_weight']; if ($attribute_value_prefix == '+') { $posCheck = ' SELECTED'; $negCheck = ''; } else { $posCheck = ''; $negCheck = ' SELECTED'; } if ($attribute_value_weight_prefix == '+') { $posCheck_weight = ' SELECTED'; $negCheck_weight = ''; } else { $posCheck_weight = ''; $negCheck_weight = ' SELECTED'; } } return true; } else { $attribute_value_price = ''; $sortorder = ''; $attribute_value_weight = ''; $attribute_value_prefix = ''; $attribute_value_weight_prefix = ''; $attribute_value_model = ''; $attribute_value_stock = ''; $posCheck = ''; $negCheck = ''; $posCheck_weight = ''; $negCheck_weight = ''; return false; } }
function vam_get_languages_directory($code) { $language_query = vam_db_query("select languages_id, directory from " . TABLE_LANGUAGES . " where code = '" . $code . "'"); if (vam_db_num_rows($language_query)) { $lang = vam_db_fetch_array($language_query); $_SESSION['languages_id'] = $lang['languages_id']; return $lang['directory']; } else { return false; } }
function vam_random_select($query) { $random_product = ''; $random_query = vam_db_query($query); $num_rows = vam_db_num_rows($random_query); if ($num_rows > 0) { $random_row = vam_rand(0, $num_rows - 1); vam_db_data_seek($random_query, $random_row); $random_product = vam_db_fetch_array($random_query); } return $random_product; }
function vam_get_affiliate_tax_rate($class_id, $country_id, $zone_id) { $tax_query = vam_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za ON tr.tax_zone_id = za.geo_zone_id left join " . TABLE_GEO_ZONES . " tz ON tz.geo_zone_id = tr.tax_zone_id WHERE (za.zone_country_id IS NULL OR za.zone_country_id = '0' OR za.zone_country_id = '" . $country_id . "') AND (za.zone_id IS NULL OR za.zone_id = '0' OR za.zone_id = '" . $zone_id . "') AND tr.tax_class_id = '" . $class_id . "' GROUP BY tr.tax_priority"); if (vam_db_num_rows($tax_query)) { $tax_multiplier = 0; while ($tax = vam_db_fetch_array($tax_query)) { $tax_multiplier += $tax['tax_rate']; } return $tax_multiplier; } else { return 0; } }
function vam_findTitle($current_pid, $languageFilter) { $query = "SELECT * FROM " . TABLE_PRODUCTS_DESCRIPTION . " where language_id = '" . $_SESSION['languages_id'] . "' AND products_id = '" . $current_pid . "'"; $result = vam_db_query($query); $matches = vam_db_num_rows($result); if ($matches) { while ($line = vam_db_fetch_array($result)) { $productName = $line['products_name']; } return $productName; } else { return "Something isn't right...."; } }
function vam_gv_account_update($customer_id, $gv_id) { $customer_gv_query = vam_db_query("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . $customer_id . "'"); $coupon_gv_query = vam_db_query("select coupon_amount from " . TABLE_COUPONS . " where coupon_id = '" . $gv_id . "'"); $coupon_gv = vam_db_fetch_array($coupon_gv_query); if (vam_db_num_rows($customer_gv_query) > 0) { $customer_gv = vam_db_fetch_array($customer_gv_query); $new_gv_amount = $customer_gv['amount'] + $coupon_gv['coupon_amount']; //prepare for DB insert $new_gv_amount = str_replace(",", ".", $new_gv_amount); $gv_query = vam_db_query("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $new_gv_amount . "' where customer_id = '" . $customer_id . "'"); } else { $gv_query = vam_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $customer_id . "', '" . $coupon_gv['coupon_amount'] . "')"); } }
function vam_currency_exists($code) { $param = '/[^a-zA-Z]/'; $code = preg_replace($param, '', $code); $currency_code = vam_db_query("SELECT code, currencies_id from " . TABLE_CURRENCIES . " WHERE code = '" . $code . "' LIMIT 1"); if (vam_db_num_rows($currency_code)) { $curr = vam_db_fetch_array($currency_code); if ($curr['code'] == $code) { return $code; } else { return false; } } else { return false; } }
function vam_expire_banners() { $banners_query = vam_db_query("select b.banners_id, b.expires_date, b.expires_impressions, sum(bh.banners_shown) as banners_shown from " . TABLE_BANNERS . " b, " . TABLE_BANNERS_HISTORY . " bh where b.status = '1' and b.banners_id = bh.banners_id group by b.banners_id"); if (vam_db_num_rows($banners_query)) { while ($banners = vam_db_fetch_array($banners_query)) { if (vam_not_null($banners['expires_date'])) { if (date('Y-m-d H:i:s') >= $banners['expires_date']) { vam_set_banner_status($banners['banners_id'], '0'); } } elseif (vam_not_null($banners['expires_impressions'])) { if ($banners['banners_shown'] >= $banners['expires_impressions']) { vam_set_banner_status($banners['banners_id'], '0'); } } } } }
function ItemAttributsSetUp($current_product_id) { // I found the easiest way to do this is just delete the current attributes & start over =) // download function start $delete_sql = vam_db_query("SELECT products_attributes_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . $current_product_id . "'"); while ($delete_res = vam_db_fetch_array($delete_sql)) { $delete_download_sql = vam_db_query("SELECT products_attributes_filename FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " WHERE products_attributes_id = '" . $delete_res['prducts_attributes_id'] . "'"); $delete_download_file = vam_db_fetch_array($delete_download_sql); vam_db_query("DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " WHERE products_attributes_id = '" . $delete_res['products_attributes_id'] . "'"); } // download function end vam_db_query("DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . $current_product_id . "'"); // Simple, yet effective.. loop through the selected Option Values.. find the proper price & prefix.. insert.. yadda yadda yadda. for ($i = 0; $i < sizeof($_POST['optionValues']); $i++) { $query = "SELECT * FROM " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_values_id = '" . $_POST['optionValues'][$i] . "'"; $result = vam_db_query($query); $matches = vam_db_num_rows($result); while ($line = vam_db_fetch_array($result)) { $optionsID = $line['products_options_id']; } $cv_id = $_POST['optionValues'][$i]; $value_price = $_POST[$cv_id . '_price']; if (PRICE_IS_BRUTTO == 'true') { $value_price = $value_price / (vam_get_tax_rate(vam_get_tax_class_id($current_product_id)) + 100) * 100; } $value_price = vam_round($value_price, PRICE_PRECISION); $value_prefix = $_POST[$cv_id . '_prefix']; $value_sortorder = $_POST[$cv_id . '_sortorder']; $value_weight_prefix = $_POST[$cv_id . '_weight_prefix']; $value_model = $_POST[$cv_id . '_model']; $value_stock = $_POST[$cv_id . '_stock']; $value_weight = $_POST[$cv_id . '_weight']; vam_db_query("INSERT INTO " . TABLE_PRODUCTS_ATTRIBUTES . " (products_id, options_id, options_values_id, options_values_price, price_prefix ,attributes_model, attributes_stock, options_values_weight, weight_prefix,sortorder) VALUES ('" . $current_product_id . "', '" . $optionsID . "', '" . $_POST['optionValues'][$i] . "', '" . $value_price . "', '" . $value_prefix . "', '" . $value_model . "', '" . $value_stock . "', '" . $value_weight . "', '" . $value_weight_prefix . "','" . $value_sortorder . "')") or die(mysql_error()); $products_attributes_id = vam_db_insert_id(); if ($_POST[$cv_id . '_download_file'] != '') { if (DOWNLOAD_ENABLED == 'true') { $value_download_file = $_POST[$cv_id . '_download_file']; $value_download_expire = $_POST[$cv_id . '_download_expire']; $value_download_count = $_POST[$cv_id . '_download_count']; $value_is_pin = $_POST[$cv_id . '_ispin']; $products_attributes_is_pin = isset($value_is_pin) ? 1 : 0; vam_db_query("INSERT INTO " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " (products_attributes_id, products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount, products_attributes_is_pin) VALUES ('" . $products_attributes_id . "', '" . $value_download_file . "', '" . $value_download_expire . "', '" . $value_download_count . "', '" . $products_attributes_is_pin . "')") or die(mysql_error()); } } } }
function vam_get_product_path($products_id) { $cPath = ''; $category_query = "select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int) $products_id . "' and p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id != 0 limit 1"; $category_query = vamDBquery($category_query); if (vam_db_num_rows($category_query, true)) { $category = vam_db_fetch_array($category_query); $categories = array(); vam_get_parent_categories($categories, $category['categories_id']); $categories = array_reverse($categories); $cPath = implode('_', $categories); if (vam_not_null($cPath)) { $cPath .= '_'; } $cPath .= $category['categories_id']; } return $cPath; }
function vam_get_tax_rate_export($class_id, $country_id = -1, $zone_id = -1) { global $currency; // calculate currencies if ($country_id == -1 && $zone_id == -1) { $country_id = STORE_COUNTRY; $zone_id = STORE_ZONE; } $tax_query = vam_db_query("select sum(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . $country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . $zone_id . "') and tr.tax_class_id = '" . $class_id . "' group by tr.tax_priority"); if (vam_db_num_rows($tax_query)) { $tax_multiplier = 1.0; while ($tax = vam_db_fetch_array($tax_query)) { $tax_multiplier *= 1.0 + $tax['tax_rate'] / 100; } return ($tax_multiplier - 1.0) * 100; } else { return 0; } }
function vam_count_products_in_category($category_id, $include_inactive = false) { $products_count = 0; if ($include_inactive == true) { $products_query = "select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . $category_id . "'"; } else { $products_query = "select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . $category_id . "'"; } $products_query = vamDBquery($products_query); $products = vam_db_fetch_array($products_query, true); $products_count += $products['total']; $child_categories_query = "select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . $category_id . "'"; $child_categories_query = vamDBquery($child_categories_query); if (vam_db_num_rows($child_categories_query, true)) { while ($child_categories = vam_db_fetch_array($child_categories_query, true)) { $products_count += vam_count_products_in_category($child_categories['categories_id'], $include_inactive); } } return $products_count; }
function restore_contents() { if (!isset($_SESSION['customer_id'])) { return false; } // insert current cart contents in database if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; $product_query = vam_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . $_SESSION['customer_id'] . "' and products_id = '" . $products_id . "'"); if (!vam_db_num_rows($product_query)) { vam_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . $_SESSION['customer_id'] . "', '" . $products_id . "', '" . $qty . "', '" . date('Ymd') . "')"); if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attr_value = $this->contents[$products_id]['attributes_values'][$option]; vam_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . $_SESSION['customer_id'] . "', '" . $products_id . "', '" . $option . "', '" . $value . "', '" . vam_db_input($attr_value) . "')"); } } } else { vam_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = customers_basket_quantity+'" . $qty . "' where customers_id = '" . $_SESSION['customer_id'] . "' and products_id = '" . $products_id . "'"); } } } // reset per-session cart contents, but not the database contents $this->reset(false); $products_query = vam_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . $_SESSION['customer_id'] . "'"); while ($products = vam_db_fetch_array($products_query)) { $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']); // attributes $attributes_query = vam_db_query("select products_options_id, products_options_value_id, products_options_value_text from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . $_SESSION['customer_id'] . "' and products_id = '" . $products['products_id'] . "'"); while ($attributes = vam_db_fetch_array($attributes_query)) { $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id']; if ($attributes['products_options_value_text'] != '') { $this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text']; } } } $this->cleanup(); }
function vam_get_extra_fields_order($customer_id, $languages_id) { $extra_fields_query = vam_db_query("select ce.fields_id, ce.fields_input_type, ce.fields_required_status, cei.fields_name, ce.fields_status, ce.fields_input_type from " . TABLE_EXTRA_FIELDS . " ce, " . TABLE_EXTRA_FIELDS_INFO . " cei where ce.fields_status=1 and cei.fields_id=ce.fields_id and cei.languages_id =" . $languages_id); $extra_fields_string = ''; if (vam_db_num_rows($extra_fields_query) > 0) { while ($extra_fields = vam_db_fetch_array($extra_fields_query)) { $value = ''; if (isset($customer_id)) { $value_query = vam_db_query("select value from " . TABLE_CUSTOMERS_TO_EXTRA_FIELDS . " where customers_id=" . $customer_id . " and fields_id=" . $extra_fields['fields_id']); $value_info = vam_db_fetch_array($value_query); $value = $value_info['value']; } $extra_fields_string .= ' <tr> <td class="main"><b>' . $extra_fields['fields_name'] . ':</b></td> <td class="main">' . $value . '</td> </tr>'; } } return $extra_fields_string; }
function query($order_id) { $order_id = vam_db_prepare_input($order_id); $order_query = vam_db_query("SELECT\n *\n FROM " . TABLE_ORDERS . " WHERE\n orders_id = '" . vam_db_input($order_id) . "'"); $order = vam_db_fetch_array($order_query); $totals_query = vam_db_query("SELECT * FROM " . TABLE_ORDERS_TOTAL . " where orders_id = '" . vam_db_input($order_id) . "' order by sort_order"); while ($totals = vam_db_fetch_array($totals_query)) { $this->totals[] = array('title' => $totals['title'], 'text' => $totals['text'], 'value' => $totals['value']); } $order_total_query = vam_db_query("select text,value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $order_id . "' and class = 'ot_total'"); $order_total = vam_db_fetch_array($order_total_query); $shipping_method_query = vam_db_query("select title from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $order_id . "' and class = 'ot_shipping'"); $shipping_method = vam_db_fetch_array($shipping_method_query); $order_status_query = vam_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . $order['orders_status'] . "' and language_id = '" . $_SESSION['languages_id'] . "'"); $order_status = vam_db_fetch_array($order_status_query); $this->info = array('currency' => $order['currency'], 'currency_value' => $order['currency_value'], 'payment_method' => $order['payment_method'], 'cc_type' => $order['cc_type'], 'cc_owner' => $order['cc_owner'], 'cc_number' => $order['cc_number'], 'cc_expires' => $order['cc_expires'], 'cc_start' => $order['cc_start'], 'cc_issue' => $order['cc_issue'], 'cc_cvv' => $order['cc_cvv'], 'date_purchased' => $order['date_purchased'], 'orders_status' => $order_status['orders_status_name'], 'last_modified' => $order['last_modified'], 'total' => strip_tags($order_total['text']), 'total_value' => $order_total['value'], 'shipping_method' => substr($shipping_method['title'], -1) == ':' ? substr(strip_tags($shipping_method['title']), 0, -1) : strip_tags($shipping_method['title']), 'comments' => $order['comments']); $this->customer = array('id' => $order['customers_id'], 'name' => $order['customers_name'], 'firstname' => $order['customers_firstname'], 'secondname' => $order['customers_secondname'], 'lastname' => $order['customers_lastname'], 'csID' => $order['customers_cid'], 'company' => $order['customers_company'], 'street_address' => $order['customers_street_address'], 'suburb' => $order['customers_suburb'], 'city' => $order['customers_city'], 'postcode' => $order['customers_postcode'], 'state' => $order['customers_state'], 'country' => $order['customers_country'], 'format_id' => $order['customers_address_format_id'], 'telephone' => $order['customers_telephone'], 'email_address' => $order['customers_email_address']); $this->delivery = array('name' => $order['delivery_name'], 'firstname' => $order['delivery_firstname'], 'secondname' => $order['delivery_secondname'], 'lastname' => $order['delivery_lastname'], 'company' => $order['delivery_company'], 'street_address' => $order['delivery_street_address'], 'suburb' => $order['delivery_suburb'], 'city' => $order['delivery_city'], 'postcode' => $order['delivery_postcode'], 'state' => $order['delivery_state'], 'country' => $order['delivery_country'], 'format_id' => $order['delivery_address_format_id']); if (empty($this->delivery['name']) && empty($this->delivery['street_address'])) { $this->delivery = false; } $this->billing = array('name' => $order['billing_name'], 'firstname' => $order['billing_firstname'], 'secondname' => $order['billing_secondname'], 'lastname' => $order['billing_lastname'], 'company' => $order['billing_company'], 'street_address' => $order['billing_street_address'], 'suburb' => $order['billing_suburb'], 'city' => $order['billing_city'], 'postcode' => $order['billing_postcode'], 'state' => $order['billing_state'], 'country' => $order['billing_country'], 'format_id' => $order['billing_address_format_id']); $index = 0; $orders_products_query = vam_db_query("SELECT * FROM " . TABLE_ORDERS_PRODUCTS . " WHERE orders_id = '" . vam_db_input($order_id) . "'"); while ($orders_products = vam_db_fetch_array($orders_products_query)) { $this->products[$index] = array('qty' => $orders_products['products_quantity'], 'id' => $orders_products['products_id'], 'name' => $orders_products['products_name'], 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'price' => $orders_products['products_price'], 'shipping_time' => $orders_products['products_shipping_time'], 'final_price' => $orders_products['final_price']); $subindex = 0; $attributes_query = vam_db_query("SELECT * FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . vam_db_input($order_id) . "' and orders_products_id = '" . $orders_products['orders_products_id'] . "'"); if (vam_db_num_rows($attributes_query)) { while ($attributes = vam_db_fetch_array($attributes_query)) { $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price']); $subindex++; } } $this->info['tax_groups']["{$this->products[$index]['tax']}"] = '1'; $index++; } }