function add_cart($products_id, $qty = '', $attributes = '')
 {
     $products_id = xtc_get_uprid($products_id, $attributes);
     if ($this->in_cart($products_id)) {
         $this->update_quantity($products_id, $qty, $attributes);
     } else {
         if ($qty == '') {
             $qty = '1';
         }
         // if no quantity is supplied, then add '1' to the customers basket
         $this->contents[] = array($products_id);
         $this->contents[$products_id] = array('qty' => $qty);
         // insert into database
         if ($_SESSION['customer_id']) {
             xtc_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 (is_array($attributes)) {
             reset($attributes);
             while (list($option, $value) = each($attributes)) {
                 $this->contents[$products_id]['attributes'][$option] = $value;
                 // insert into database
                 if ($_SESSION['customer_id']) {
                     xtc_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . $_SESSION['customer_id'] . "', '" . $products_id . "', '" . $option . "', '" . $value . "')");
                 }
             }
         }
         $_SESSION['new_products_id_in_cart'] = $products_id;
     }
     $this->cleanup();
 }
         xtc_redirect(xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['BUYproducts_id'], 'NONSSL'));
     }
     if ($_SESSION['customers_status']['customers_fsk18_display'] == '0' && $permission['products_fsk18'] == '1') {
         xtc_redirect(xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['BUYproducts_id'], 'NONSSL'));
     }
     // check for customer group
     if (GROUP_CHECK == 'true') {
         if ($permission['customer_group'] != '1') {
             xtc_redirect(xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['BUYproducts_id']));
         }
     }
     if (xtc_has_product_attributes($_GET['BUYproducts_id'])) {
         xtc_redirect(xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['BUYproducts_id']));
     } else {
         if (isset($_SESSION['cart'])) {
             $cart_quantity = $_SESSION['cart']->get_quantity(xtc_get_uprid($_GET['BUYproducts_id'], '')) + 1;
             if ($cart_quantity > MAX_PRODUCTS_QTY) {
                 $cart_quantity = MAX_PRODUCTS_QTY;
             }
             if (isset($econda) && is_object($econda)) {
                 $econda->_emptyCart();
                 $old_quantity = $_SESSION['cart']->get_quantity($_GET['BUYproducts_id']);
                 $econda->_addProduct($_GET['BUYproducts_id'], $cart_quantity, $old_quantity);
             }
             $_SESSION['cart']->add_cart($_GET['BUYproducts_id'], $cart_quantity);
         } else {
             xtc_redirect(xtc_href_link(FILENAME_DEFAULT));
         }
     }
 }
 xtc_redirect(xtc_href_link($goto, xtc_get_all_get_params(array('action', 'BUYproducts_id'))));
 /**
  * add_cart
  *
  * @param integer $products_id
  * @param integer $qty
  * @param string $attributes
  * @param boolean $notify
  */
 function add_cart($products_id, $qty = 1, $attributes = '', $notify = true)
 {
     global $new_products_id_in_cart;
     $products_id = xtc_get_uprid($products_id, $attributes);
     if ($notify == true) {
         $_SESSION['new_products_id_in_cart'] = $products_id;
     }
     if ($this->in_cart($products_id)) {
         $this->update_quantity($products_id, $qty, $attributes);
     } else {
         //$this->contents[] = array ($products_id); //web28 - 2010-08-15 - BUGFIX unnecessary code causes problems with download articles
         $this->contents[$products_id] = array('qty' => (int) $qty);
         // insert into database
         if (isset($_SESSION['customer_id'])) {
             $sql_data_array = array('customers_id' => $_SESSION['customer_id'], 'products_id' => $products_id, 'customers_basket_quantity' => $qty, 'customers_basket_date_added' => date('Ymd'));
             xtc_db_perform(TABLE_CUSTOMERS_BASKET, $sql_data_array);
         }
         if (is_array($attributes)) {
             reset($attributes);
             while (list($option, $value) = each($attributes)) {
                 $this->contents[$products_id]['attributes'][$option] = $value;
                 // insert into database
                 if (isset($_SESSION['customer_id'])) {
                     $sql_data_array = array('customers_id' => (int) $_SESSION['customer_id'], 'products_id' => $products_id, 'products_options_id' => (int) $option, 'products_options_value_id' => (int) $value);
                     xtc_db_perform(TABLE_CUSTOMERS_BASKET_ATTRIBUTES, $sql_data_array);
                 }
             }
         }
     }
     $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();
 }