Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function calculate() {
- $this->total = 0;
- $this->weight = 0;
- if (!is_array($this->contents)) return 0;
- foreach ($this->contents as $line) {
- $products_id = intval ($line['id']);
- $qty = $line['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='".$products_id."'") or die(mysql_error());
- 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 = '" . $products_id. "' and status = '1'") or die(mysql_error());
- if (tep_db_num_rows ($specials_query)) {
- $specials = tep_db_fetch_array($specials_query);
- $products_price = $specials['specials_new_products_price'];
- }
- $this->total += tep_add_tax($products_price, $products_tax) * $qty;
- $this->weight += ($qty * $products_weight);
- }
- }
- }
- function get_products() {
- global $languages_id;
- if (!is_array($this->contents)) return 0;
- $products_array = array();
- foreach ($this->contents as $line) {
- $products_id = intval ($line['id']);
- $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id='" . $products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'") or die (mysql_error ());
- 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'") or die(mysql_error());
- 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'],
- 'price' => $products_price,
- 'quantity' => $this->contents[$products_id]['qty'],
- 'weight' => $products['products_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'] : ''));
- } else {
- echo 'products_query Failed';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement