Guest User

Untitled

a guest
Nov 28th, 2012
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function calculate() {
  2.       $this->total = 0;
  3.       $this->weight = 0;
  4.       if (!is_array($this->contents)) return 0;
  5.  
  6. foreach ($this->contents as $line) {
  7.        $products_id = intval ($line['id']);
  8.         $qty = $line['qty'];
  9.  
  10. // products price
  11.         $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());
  12.         if ($product = tep_db_fetch_array($product_query)) {
  13.           $prid = $product['products_id'];
  14.           $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
  15.           $products_price = $product['products_price'];
  16.           $products_weight = $product['products_weight'];
  17.  
  18.           $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());
  19.           if (tep_db_num_rows ($specials_query)) {
  20.             $specials = tep_db_fetch_array($specials_query);
  21.             $products_price = $specials['specials_new_products_price'];
  22.           }
  23.  
  24.           $this->total += tep_add_tax($products_price, $products_tax) * $qty;
  25.           $this->weight += ($qty * $products_weight);
  26.         }
  27.  
  28.       }
  29.     }
  30.  
  31.  
  32.  
  33.     function get_products() {
  34.       global $languages_id;
  35.       if (!is_array($this->contents)) return 0;
  36.       $products_array = array();
  37.       foreach ($this->contents as $line) {
  38.        $products_id = intval ($line['id']);
  39.         $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 ());
  40.  
  41.         if ($products = tep_db_fetch_array($products_query)) {
  42.           $prid = $products['products_id'];
  43.           $products_price = $products['products_price'];
  44.  
  45.           $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());
  46.           if (tep_db_num_rows($specials_query)) {
  47.             $specials = tep_db_fetch_array($specials_query);
  48.             $products_price = $specials['specials_new_products_price'];
  49.           }
  50.  
  51.           $products_array[] = array('id' => $products_id,
  52.                                     'name' => $products['products_name'],
  53.                                     'model' => $products['products_model'],
  54.                                     'price' => $products_price,
  55.                                     'quantity' => $this->contents[$products_id]['qty'],
  56.                                     'weight' => $products['products_weight'],
  57.                                     'final_price' => ($products_price + $this->attributes_price($products_id)),
  58.                                     'tax_class_id' => $products['products_tax_class_id'],
  59.                                     'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
  60.         } else {
  61. echo 'products_query Failed';
  62. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×