How to set up an E-iContact mailing list automatically?
Try iContact email marketing for free for 30 days. Click here to use coupon...
Get a free trial of iContact here. Click here for this special deal...
First off, How to set up an E-iContact mailing list automatically? Thanks for any answer. Another question I got... If I add the product with the quantity it will show price in minus in the shopping cart..
Here is the Shopping_cart.php.
<?php.
/*.
$Id: shopping_cart.php 1739 2007-12-20 00:52:16Z hpdl $.
OsCommerce, Open Source E-Commerce Solutions.
Http://www.oscommerce.com.
Copyright (c) 2003 osCommerce.
Released under the GNU General Public License.
*/.
Class shoppingCart {.
Var $contents, $total, $weight, $cartID, $content_type;.
Function shoppingCart() {.
$this->reset();.
}.
Function restore_contents() {.
Global $customer_id;.
If (!tep_session_is_registered('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 = tep_db_query("select products_id from "TABLE_CUSTOMERS_BASKET" where customers_id = '"(int)$customer_id"' and products_id = '"tep_db_input($products_id)"'");.
If (!tep_db_num_rows($product_query)) {.
Tep_db_query("insert into "TABLE_CUSTOMERS_BASKET" (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('"(int)$customer_id"', '"tep_db_input($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'])) {.
Tep_db_query("insert into "TABLE_CUSTOMERS_BASKET_ATTRIBUTES" (customers_id, products_id, products_options_id, products_options_value_id) values ('"(int)$customer_id"', '"tep_db_input($products_id)"', '"(int)$option"', '"(int)$value"')");.
}.
}.
} else {.
Tep_db_query("update "TABLE_CUSTOMERS_BASKET" set customers_basket_quantity = '"$qty"' where customers_id = '"(int)$customer_id"' and products_id = '"tep_db_input($products_id)"'");.
}.
}.
}.
// reset per-session cart contents, but not the database contents.
$this->reset(false);.
$products_query = tep_db_query("select products_id, customers_basket_quantity from "TABLE_CUSTOMERS_BASKET" where customers_id = '"(int)$customer_id"'");.
While ($products = tep_db_fetch_array($products_query)) {.
$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);.
// attributes.
$attributes_query = tep_db_query("select products_options_id, products_options_value_id from "TABLE_CUSTOMERS_BASKET_ATTRIBUTES" where customers_id = '"(int)$customer_id"' and products_id = '"tep_db_input($products['products_id'])"'");.
While ($attributes = tep_db_fetch_array($attributes_query)) {.
$this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];.
}.
}.
$this->cleanup();.
}.
Function reset($reset_database = false) {.
Global $customer_id;.
$this->contents = array();.
$this->total = 0;.
$this->weight = 0;.
$this->content_type = false;.
If (tep_session_is_registered('customer_id') && ($reset_database == true)) {.
Tep_db_query("delete from "TABLE_CUSTOMERS_BASKET" where customers_id = '"(int)$customer_id"'");.
Tep_db_query("delete from "TABLE_CUSTOMERS_BASKET_ATTRIBUTES" where customers_id = '"(int)$customer_id"'");.
}.
Unset($this->cartID);.
If (tep_session_is_registered('cartID')) tep_session_unregister('cartID');.
}.
Function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {.
Global $new_products_id_in_cart, $customer_id;.
$products_id_string = tep_get_uprid($products_id, $attributes);.
$products_id = tep_get_prid($products_id_string);.
If (defined('MAX_QTY_IN_CART') && (MAX_QTY_IN_CART > 0) && ((int)$qty > MAX_QTY_IN_CART)) {.
$qty = MAX_QTY_IN_CART;.
}.
$attributes_pass_check = true;.
If (is_array($attributes)) {.
Reset($attributes);.
While (list($option, $value) = each($attributes)) {.
If (!is_numeric($option) || !is_numeric($value)) {.
$attributes_pass_check = false;.
Break;.
}.
}.
}.
If (is_numeric($products_id) && is_numeric($qty) && ($attributes_pass_check == true)) {.
$check_product_query = tep_db_query("select products_status from "TABLE_PRODUCTS" where products_id = '"(int)$products_id"'");.
$check_product = tep_db_fetch_array($check_product_query);.
If (($check_product !== false) && ($check_product['products_status'] == '1')) {.
If ($notify == true) {.
$new_products_id_in_cart = $products_id;.
Tep_session_register('new_products_id_in_cart');.
}.
If ($this->in_cart($products_id_string)) {.
$this->update_quantity($products_id_string, $qty, $attributes);.
} else {.
$this->contents[$products_id_string] = array('qty' => (int)$qty);.
// insert into database.
If (tep_session_is_registered('customer_id')) tep_db_query("insert into "TABLE_CUSTOMERS_BASKET" (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('"(int)$customer_id"', '"tep_db_input($products_id)"', '"$qty"', '"date('Ymd')"')");.
If (is_array($attributes)) {.
Reset($attributes);.
While (list($option, $value) = each($attributes)) {.
$this->contents[$products_id_string]['attributes'][$option] = $value;.
// insert into database.
If (tep_session_is_registered('customer_id')) tep_db_query("insert into "TABLE_CUSTOMERS_BASKET_ATTRIBUTES" (customers_id, products_id, products_options_id, products_options_value_id) values ('"(int)$customer_id"', '"tep_db_input($products_id)"', '"(int)$option"', '"(int)$value"')");.
}.
}.
}.
$this->cleanup();.
// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure.
$this->cartID = $this->generate_cart_id();.
}.
}.
}.
Function update_quantity($products_id, $quantity = '', $attributes = '') {.
Global $customer_id;.
If (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true...
$products_id_string = tep_get_uprid($products_id, $attributes);.
$products_id = tep_get_prid($products_id_string);.
If (defined('MAX_QTY_IN_CART') && (MAX_QTY_IN_CART > 0) && ((int)$quantity > MAX_QTY_IN_CART)) {.
$quantity = MAX_QTY_IN_CART;.
}.
$attributes_pass_check = true;.
If (is_array($attributes)) {.
Reset($attributes);.
While (list($option, $value) = each($attributes)) {.
If (!is_numeric($option) || !is_numeric($value)) {.
$attributes_pass_check = false;.
Break;.
}.
}.
}.
If (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity) && ($attributes_pass_check == true)) {.
$this->contents[$products_id_string] = array('qty' => (int)$quantity);.
// update database.
If (tep_session_is_registered('customer_id')) tep_db_query("update "TABLE_CUSTOMERS_BASKET" set customers_basket_quantity = '"$quantity"' where customers_id = '"(int)$customer_id"' and products_id = '"tep_db_input($products_id)"'");.
If (is_array($attributes)) {.
Reset($attributes);.
While (list($option, $value) = each($attributes)) {.
$this->contents[$products_id_string]['attributes'][$option] = $value;.
// update database.
If (tep_session_is_registered('customer_id')) tep_db_query("update "TABLE_CUSTOMERS_BASKET_ATTRIBUTES" set products_options_value_id = '"(int)$value"' where customers_id = '"(int)$customer_id"' and products_id = '"tep_db_input($products_id)"' and products_options_id = '"(int)$option"'");.
}.
}.
}.
}.
Function cleanup() {.
Global $customer_id;.
Reset($this->contents);.
While (list($key,) = each($this->contents)) {.
If ($this->contents[$key]['qty'] < 1) {.
Unset($this->contents[$key]);.
// remove from database.
If (tep_session_is_registered('customer_id')) {.
Tep_db_query("delete from "TABLE_CUSTOMERS_BASKET" where customers_id = '"(int)$customer_id"' and products_id = '"tep_db_input($key)"'");.
Tep_db_query("delete from "TABLE_CUSTOMERS_BASKET_ATTRIBUTES" where customers_id = '"(int)$customer_id"' and products_id = '"tep_db_input($key)"'");.
}.
}.
}.
}.
Function count_contents() { // get total number of items in cart.
$total_items = 0;.
If (is_array($this->contents)) {.
Reset($this->contents);.
While (list($products_id, ) = each($this->contents)) {.
$total_items += $this->get_quantity($products_id);.
}.
}.
Return $total_items;.
}.
Function get_quantity($products_id) {.
If (isset($this->contents[$products_id])) {.
Return $this->contents[$products_id]['qty'];.
} else {.
Return 0;.
}.
}.
Function in_cart($products_id) {.
If (isset($this->contents[$products_id])) {.
Return true;.
} else {.
Return false;.
}.
}.
Function remove($products_id) {.
Global $customer_id;.
Unset($this->contents[$products_id]);.
// remove from database.
If (tep_session_is_registered('customer_id')) {.
Tep_db_query("delete from "TABLE_CUSTOMERS_BASKET" where customers_id = '"(int)$customer_id"' and products_id = '"tep_db_input($products_id)"'");.
Tep_db_query("delete from "TABLE_CUSTOMERS_BASKET_ATTRIBUTES" where customers_id = '"(int)$customer_id"' and products_id = '"tep_db_input($products_id)"'");.
}.
// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure.
$this->cartID = $this->generate_cart_id();.
}.
Function remove_all() {.
$this->reset();.
}.
Function get_product_id_list() {.
$product_id_list = '';.
If (is_array($this->contents)) {.
Reset($this->contents);.
While (list($products_id, ) = each($this->contents)) {.
$product_id_list .= ', '$products_id;.
}.
}.
Return substr($product_id_list, 2);.
}.
Function calculate() {.
Global $currencies;.
$this->total = 0;.
$this->weight = 0;.
If (!is_array($this->contents)) return 0;.
Reset($this->contents);.
While (list($products_id, ) = each($this->contents)) {.
$qty = $this->contents[$products_id]['qty'];.
// products price.
$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from "TABLE_PRODUCTS" where products_id = '"(int)$products_id"'");.
If ($product = tep_db_fetch_array($product_query)) {.
$prid = $product['products_id'];.
$products_tax = tep_get_tax_rate($product['products_tax_class_id']);.
$products_price = $product['products_price'];.
$products_weight = $product['products_weight'];.
$specials_query = tep_db_query("select specials_new_products_price from "TABLE_SPECIALS" where products_id = '"(int)$prid"' and status = '1'");.
If (tep_db_num_rows ($specials_query)) {.
$specials = tep_db_fetch_array($specials_query);.
$products_price = $specials['specials_new_products_price'];.
}.
$this->total += $currencies->calculate_price($products_price, $products_tax, $qty);.
$this->weight += ($qty * $products_weight);.
}.
// attributes price.
//.
// add-weight-to-product-attributes mod:.
$this->weight += ($qty * $attribute_price['options_values_weight']);.
} // END if(!empty($attribute_price['options_values_weight'])) {.
}.
}.
}.
}.
Function attributes_price($products_id) {.
$attributes_price = 0;.
If (isset($this->contents[$products_id]['attributes'])) {.
Reset($this->contents[$products_id]['attributes']);.
While (list($option, $value) = each($this->contents[$products_id]['attributes'])) {.
$attribute_price_query = tep_db_query("select options_values_price, price_prefix from "TABLE_PRODUCTS_ATTRIBUTES" where products_id = '"(int)$products_id"' and options_id = '"(int)$option"' and options_values_id = '"(int)$value"'");.
$attribute_price = tep_db_fetch_array($attribute_price_query);.
// Actual Attribute Price.
$price_prefix = $attribute_price['price_prefix'];.
$option_price = $attribute_price['options_values_price'];.
$products_query = tep_db_query("select products_price from "TABLE_PRODUCTS" where products_id = '"(int)$products_id"'");.
$products_stuff = tep_db_fetch_array($products_query);.
$products_price = $products_stuff['products_price'];.
If ($price_prefix == '+') {.
$attributes_price += $option_price;.
} elseif ($price_prefix == '-') {.
$attributes_price -= $option_price;.
} else {.
$attributes_price += tep_adjust_price($option_price, $products_price);.
}.
// Actual Attribute Price.
}.
}.
Return $attributes_price;.
}.
Function get_products() {.
Global $languages_id;.
If (!is_array($this->contents)) return false;.
$products_array = array();.
Reset($this->contents);.
While (list($products_id, ) = each($this->contents)) {.
$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from "TABLE_PRODUCTS" p, "TABLE_PRODUCTS_DESCRIPTION" pd where p.products_id = '"(int)$products_id"' and pd.products_id = p.products_id and pd.language_id = '"(int)$languages_id"'");.
If ($products = tep_db_fetch_array($products_query)) {.
$prid = $products['products_id'];.
$products_price = $products['products_price'];.
$specials_query = tep_db_query("select specials_new_products_price from "TABLE_SPECIALS" where products_id = '"(int)$prid"' and status = '1'");.
If (tep_db_num_rows($specials_query)) {.
$specials = tep_db_fetch_array($specials_query);.
$products_price = $specials['specials_new_products_price'];.
}.
$products_array[] = array('id' => $products_id,.
'name' => $products['products_name'],.
'model' => $products['products_model'],.
'image' => $products['products_image'],.
'price' => $products_price,.
'quantity' => $this->contents[$products_id]['qty'],.
'weight' => $products['products_weight'] + $attributes_total_weight,.
'final_price' => ($products_price + $this->attributes_price($products_id)),.
'tax_class_id' => $products['products_tax_class_id'],.
'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));.
// determine total weight of attributes to add to weight of product.
$attributes_total_weight = 0;.
If (isset($this->contents[$products_id]['attributes'])) {.
Reset($this->contents[$products_id]['attributes']);.
$where = ' AND ((';.
While (list($option, $value) = each($this->contents[$products_id]['attributes'])) {.
$where .= 'options_id='$option' AND options_values_id='$value') OR (';.
}.
$where=substr($where, 0, -5)')';.
$attribute_weight_query = tep_db_query('SELECT options_values_weight FROM 'TABLE_PRODUCTS_ATTRIBUTES' WHERE products_id='(int)$prid$where);.
If (tep_db_num_rows($attribute_weight_query)) {.
While ($attributes_weight_array = tep_db_fetch_array($attribute_weight_query)) {.
$attributes_total_weight += $attributes_weight_array['options_values_weight'];.
}.
} // end if (tep_db_num_rows($attribute_weight_query)).
} // end if (isset($this->contents[$products_id]['attributes'])).
}.
}.
Return $products_array;.
}.
Function show_total() {.
$this->calculate();.
Return $this->total;.
}.
Function show_weight() {.
$this->calculate();.
Return $this->weight;.
}.
Function generate_cart_id($length = 5) {.
Return tep_create_random_value($length, 'digits');.
}.
Function get_content_type() {.
$this->content_type = false;.
If ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {.
Reset($this->contents);.
While (list($products_id, ) = each($this->contents)) {.
If (isset($this->contents[$products_id]['attributes'])) {.
Reset($this->contents[$products_id]['attributes']);.
While (list(, $value) = each($this->contents[$products_id]['attributes'])) {.
$virtual_check_query = tep_db_query("select count(*) as total from "TABLE_PRODUCTS_ATTRIBUTES" pa, "TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD" pad where pa.products_id = '"(int)$products_id"' and pa.options_values_id = '"(int)$value"' and pa.products_attributes_id = pad.products_attributes_id");.
$virtual_check = tep_db_fetch_array($virtual_check_query);.
If ($virtual_check['total'] > 0) {.
Switch ($this->content_type) {.
Case 'physical':.
$this->content_type = 'mixed';.
Return $this->content_type;.
Break;.
Default:.
$this->content_type = 'virtual';.
Break;.
}.
} else {.
Switch ($this->content_type) {.
Case 'virtual':.
$this->content_type = 'mixed';.
Return $this->content_type;.
Break;.
Default:.
$this->content_type = 'physical';.
Break;.
}.
}.
}.
} else {.
Switch ($this->content_type) {.
Case 'virtual':.
$this->content_type = 'mixed';.
Return $this->content_type;.
Break;.
Default:.
$this->content_type = 'physical';.
Break;.
}.
}.
}.
} else {.
$this->content_type = 'physical';.
}.
Return $this->content_type;.
}.
Function unserialize($broken) {.
For(reset($broken);$kv=each($broken);) {.
$key=$kv['key'];.
If (gettype($this->$key)!="user function").
$this->$key=$kv['value'];.
}.
}.
}.
?>..