RyanSmith Posted January 7, 2005 Posted January 7, 2005 Hello, I'm writing some custom code to create a new attribute system that pulls its values out of a new database table. I have it working pretty well, however I can't get the price to increment when they select the new attribute. Does anyone know how this code works? Could someone explain it to me so I can figure out what I'm doing wrong. Thanks osCommerce is a great piece of software with wonderful contributions. Spend some time in the contribution area. There are a lot of gems there.
crashwave Posted January 10, 2005 Posted January 10, 2005 a little more info might help. Some code? Are you using just = or += to assign values q_|_|| _|9~~J >-o>-o q_|_|| )| q_|| )
RyanSmith Posted January 10, 2005 Author Posted January 10, 2005 a little more info might help.Some code? Are you using just = or += to assign values <{POST_SNAPBACK}> Thanks for your reply. I figured it out. I'm adding a dollar to any product using the new attribute system. If anyone would like to see where I edited the code here it is. function calculate() { $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 += tep_add_tax($products_price, $products_tax) * $qty; $this->weight += ($qty * $products_weight); } // attributes price 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)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } else { $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } //nthcs - Ryan Smith. January 7, 2005 //Checks for name drops and adds 1 dollar if ($option == 9 && $value != 1000) { //if (strstr ($value, 'nd')) { $this->total += $qty * tep_add_tax(1, $products_tax); } } } } } 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); if ($attribute_price['price_prefix'] == '+') { $attributes_price += $attribute_price['options_values_price']; } else { $attributes_price -= $attribute_price['options_values_price']; } //nthcs - Ryan Smith. January 7, 2005 //Checks for name drops and adds 1 dollar if ($option == 9 && $value != 1000) { //if (strstr ($value, 'nd')) { $attributes_price += 1; } } } return $attributes_price; } osCommerce is a great piece of software with wonderful contributions. Spend some time in the contribution area. There are a lot of gems there.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.