Mike8 Posted January 6, 2010 Share Posted January 6, 2010 Hey Jan, it works! Great! Thank you a lot! Mike Quote Link to comment Share on other sites More sharing options...
rosemaryann Posted January 13, 2010 Share Posted January 13, 2010 Hey everyone, I'm trying to combine this add-on with the Options Types 2.0 add-on. I just about have it (I think) but having a tough time with the text values being added to the shopping cart. I believe I've narrowed it down to the shopping cart class... (/includes/classes/shopping_cart.php) I was wondering if anyone has these two installed or if you can look at what I have, because I need a 2nd pair of eyes. I'm still not quite sure how the hidden attributes work in this add-on. I believe my problem is somewhere in this area: /includes/classes/shopping_cart.php // insert current cart contents in database if (is_array($this->contents)) { reset($this->contents); // BOF SPPC attribute hide/invalid check: loop through the shopping cart and check the attributes if they // are hidden for the now logged-in customer $this->cg_id = $this->get_customer_group_id(); while (list($products_id, ) = each($this->contents)) { // only check attributes if they are set for the product in the cart if (isset($this->contents[$products_id]['attributes'])) { $check_attributes_query = tep_db_query("select options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . tep_get_prid($products_id) . "'"); while ($_check_attributes = tep_db_fetch_array($check_attributes_query)) { $check_attributes[] = $_check_attributes; } // end while ($_check_attributes = tep_db_fetch_array($check_attributes_query)) $no_of_check_attributes = count($check_attributes); $change_products_id = '0'; foreach($this->contents[$products_id]['attributes'] as $attr_option => $attr_option_value) { $valid_option = '0'; for ($x = 0; $x < $no_of_check_attributes ; $x++) { if ($attr_option == $check_attributes[$x]['options_id'] && $attr_option_value == $check_attributes[$x]['options_values_id']) { $valid_option = '1'; if ($check_attributes[$x]['hide_attr_status'] == '1') { // delete hidden attributes from array attributes, change products_id accordingly later $change_products_id = '1'; unset($this->contents[$products_id]['attributes'][$attr_option]); } } // end if ($attr_option == $check_attributes[$x]['options_id'].... } // end for ($x = 0; $x < $no_of_check_attributes ; $x++) if ($valid_option == '0') { // after having gone through the options for this product and not having found a matching one // we can conclude that apparently this is not a valid option for this product so remove it unset($this->contents[$products_id]['attributes'][$attr_option]); // change products_id accordingly later $change_products_id = '1'; } } // end foreach($this->contents[$products_id]['attributes'] as $attr_option => $attr_option_value) if ($change_products_id == '1') { $original_products_id = $products_id; $products_id = tep_get_prid($original_products_id); $products_id = tep_get_uprid($products_id, $this->contents[$original_products_id]['attributes']); // add the product without the hidden attributes to the cart $this->contents[$products_id] = $this->contents[$original_products_id]; // delete the originally added product with the hidden attributes unset($this->contents[$original_products_id]); } } // end if (isset($this->contents[$products_id]['attributes'])) } // end while (list($products_id, ) = each($this->contents)) reset($this->contents); // reset the array otherwise the cart will be emptied // EOF SPPC attribute hide/invalid check 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) . "', '" . tep_db_input($qty) . "', '" . date('Ymd') . "')"); if (isset($this->contents[$products_id]['attributes'])) { //BOF - Zappo - Option Types v2 - Update query to include attribute value && Check for Uploads from customer and copy to Upload dir $uploads_query = tep_db_query("select files_uploaded_name from " . TABLE_FILES_UPLOADED . " where sesskey = '" . tep_session_id() . "'"); while ($uploads_array = tep_db_fetch_array($uploads_query)) { if (file_exists(TMP_DIR . $uploads_array['files_uploaded_name'])) { // Customer upload found in TMP dir --> Copy to Upload Dir @rename(TMP_DIR . $uploads_array['files_uploaded_name'], UPL_DIR . $uploads_array['files_uploaded_name']); // Set Customer_ID for the files that are found tep_db_query("update " . TABLE_FILES_UPLOADED . " set customers_id = '" . (int)$customer_id . "' where sesskey = '" . tep_session_id() . "' and files_uploaded_name = '" . $uploads_array['files_uploaded_name'] . "'"); } } reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attr_value = $this->contents[$products_id]['attributes_values'][$option]; tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')"); //EOF - Zappo - Option Types v2 - Update query to include attribute value && Check for Uploads from customer and copy to Upload dir } } } else { tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . tep_db_input($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 //BOF - Zappo - Option Types v2 - Update query to pull attribute value_text. This is needed for text attributes. $attributes_query = tep_db_query("select products_options_id, products_options_value_id, products_options_value_text 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']; // - Zappo - Option Types v2 - If attribute is Text, set additional information if ($attributes['products_options_value_id'] == OPTIONS_VALUE_TEXT_ID) { $this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text']; } //EOF - Zappo - Option Types v2 - Update query to pull attribute value_text. This is needed for text attributes. } } $this->cleanup(); } Quote Link to comment Share on other sites More sharing options...
Guest Posted January 15, 2010 Share Posted January 15, 2010 Anyone get this fixed? I am having a hard time to: Fatal error: Call to undefined method shoppingCart::get_customer_group_id() /includes/classes/shopping_cart.php on line 147 The function is there! <?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); // BOF SPPC attribute hide/invalid check: loop through the shopping cart and check the attributes if they // are hidden for the now logged-in customer $this->cg_id = $this->get_customer_group_id(); while (list($products_id, ) = each($this->contents)) { // only check attributes if they are set for the product in the cart if (isset($this->contents[$products_id]['attributes'])) { $check_attributes_query = tep_db_query("select options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . tep_get_prid($products_id) . "'"); while ($_check_attributes = tep_db_fetch_array($check_attributes_query)) { $check_attributes[] = $_check_attributes; } // end while ($_check_attributes = tep_db_fetch_array($check_attributes_query)) $no_of_check_attributes = count($check_attributes); $change_products_id = '0'; foreach($this->contents[$products_id]['attributes'] as $attr_option => $attr_option_value) { $valid_option = '0'; for ($x = 0; $x < $no_of_check_attributes ; $x++) { if ($attr_option == $check_attributes[$x]['options_id'] && $attr_option_value == $check_attributes[$x]['options_values_id']) { $valid_option = '1'; if ($check_attributes[$x]['hide_attr_status'] == '1') { // delete hidden attributes from array attributes, change products_id accordingly later $change_products_id = '1'; unset($this->contents[$products_id]['attributes'][$attr_option]); } } // end if ($attr_option == $check_attributes[$x]['options_id'].... } // end for ($x = 0; $x < $no_of_check_attributes ; $x++) if ($valid_option == '0') { // after having gone through the options for this product and not having found a matching one // we can conclude that apparently this is not a valid option for this product so remove it unset($this->contents[$products_id]['attributes'][$attr_option]); // change products_id accordingly later $change_products_id = '1'; } } // end foreach($this->contents[$products_id]['attributes'] as $attr_option => $attr_option_value) if ($change_products_id == '1') { $original_products_id = $products_id; $products_id = tep_get_prid($original_products_id); $products_id = tep_get_uprid($products_id, $this->contents[$original_products_id]['attributes']); // add the product without the hidden attributes to the cart $this->contents[$products_id] = $this->contents[$original_products_id]; // delete the originally added product with the hidden attributes unset($this->contents[$original_products_id]); } } // end if (isset($this->contents[$products_id]['attributes'])) } // end while (list($products_id, ) = each($this->contents)) reset($this->contents); // reset the array otherwise the cart will be emptied // EOF SPPC attribute hide/invalid check 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) . "', '" . tep_db_input($qty) . "', '" . date('Ymd') . "')"); if (isset($this->contents[$products_id]['attributes'])) { //BOF - Zappo - Option Types v2 - Update query to include attribute value && Check for Uploads from customer and copy to Upload dir $uploads_query = tep_db_query("select files_uploaded_name from " . TABLE_FILES_UPLOADED . " where sesskey = '" . tep_session_id() . "'"); while ($uploads_array = tep_db_fetch_array($uploads_query)) { if (file_exists(TMP_DIR . $uploads_array['files_uploaded_name'])) { // Customer upload found in TMP dir --> Copy to Upload Dir @rename(TMP_DIR . $uploads_array['files_uploaded_name'], UPL_DIR . $uploads_array['files_uploaded_name']); // Set Customer_ID for the files that are found tep_db_query("update " . TABLE_FILES_UPLOADED . " set customers_id = '" . (int)$customer_id . "' where sesskey = '" . tep_session_id() . "' and files_uploaded_name = '" . $uploads_array['files_uploaded_name'] . "'"); } } reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attr_value = $this->contents[$products_id]['attributes_values'][$option]; tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')"); //EOF - Zappo - Option Types v2 - Update query to include attribute value && Check for Uploads from customer and copy to Upload dir } } } else { tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . tep_db_input($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 //BOF - Zappo - Option Types v2 - Update query to pull attribute value_text. This is needed for text attributes. $attributes_query = tep_db_query("select products_options_id, products_options_value_id, products_options_value_text 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']; // - Zappo - Option Types v2 - If attribute is Text, set additional information if ($attributes['products_options_value_id'] == OPTIONS_VALUE_TEXT_ID) { $this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text']; } //EOF - Zappo - Option Types v2 - Update query to pull attribute value_text. This is needed for text attributes. } } $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; // BOF Separate Pricing Per Customer $this->cg_id = $this->get_customer_group_id(); // EOF Separate Pricing Per Customer $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; //BOF - Zappo - Option Types v2 - Because of Text and Upload options, $option AND $value don't have to be numeric! /* if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { if (!is_numeric($option) || !is_numeric($value)) { $attributes_pass_check = false; break; } } } */ //EOF - Zappo - Option Types v2 - Because of Text and Upload options, $option AND $value don't have to be numeric! if (is_numeric($products_id) && is_numeric($qty) && ($attributes_pass_check == true)) { // BOF SPPC attribute hide check, original query expanded to include attributes $check_product_query = tep_db_query("select p.products_status, options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_ATTRIBUTES . " using(products_id) where p.products_id = '" . (int)$products_id . "'"); while ($_check_product = tep_db_fetch_array($check_product_query)) { $check_product[] = $_check_product; } // end while ($_check_product = tep_db_fetch_array($check_product_query)) $no_of_check_product = count($check_product); if (is_array($attributes)) { foreach($attributes as $attr_option => $attr_option_value) { $valid_option = '0'; for ($x = 0; $x < $no_of_check_product ; $x++) { if ($attr_option == $check_product[$x]['options_id'] && $attr_option_value == $check_product[$x]['options_values_id']) { $valid_option = '1'; if ($check_product[$x]['hide_attr_status'] == '1') { // delete hidden attributes from array attributes unset($attributes[$attr_option]); } } // end if ($attr_option == $check_product[$x]['options_id'].... } // end for ($x = 0; $x < $no_of_check_product ; $x++) if ($valid_option == '0') { // after having gone through the options for this product and not having found a matching one // we can conclude that apparently this is not a valid option for this product so remove it unset($attributes[$attr_option]); } } // end foreach($attributes as $attr_option => $attr_option_value) } // end if (is_array($attributes)) // now attributes have been checked and hidden and invalid ones deleted make the $products_id_string again $products_id_string = tep_get_uprid($products_id, $attributes); if ((isset($check_product) && tep_not_null($check_product)) && ($check_product[0]['products_status'] == '1')) { // EOF SPPC attribute hide check 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_string) . "', '" . (int)$qty . "', '" . date('Ymd') . "')"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { //BOF - Zappo - Option Types v2 - Check options loop, and add attributes accordingly... $attr_value = NULL; $blank_value = FALSE; if (strstr($option, TEXT_PREFIX)) { //Check for Text and Upload Options if (trim($value) == NULL) { //Check if the Text Option has a value (Or is the value blank?) $blank_value = TRUE; } else { //Value is valid and contains data --> Add Text Option value $option = str_replace(TEXT_PREFIX,'',$option); $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES); $value = OPTIONS_VALUE_TEXT_ID; $this->contents[$products_id_string]['attributes_values'][$option] = $attr_value; } } if (!$blank_value) { // If the Value is valid and Contains Data, add the option to the Cart.... $this->contents[$products_id_string]['attributes'][$option] = $value; // insert into database // - Zappo - Option Types v2 - Added products_options_value_text For saving Text and Upload Option Values 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, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . $option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')"); } //EOF - Zappo - Option Types v2 - Check options loop, and add attributes accordingly... } } } $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; $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_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 = '" . (int)$quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "'"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { //BOF - Zappo - Option Types v2 - Check options loop for Text & Uploads, and add attributes accordingly... $attr_value = NULL; $blank_value = FALSE; if (strstr($option, TEXT_PREFIX)) { //Check for Text and Upload Options if (trim($value) == NULL) { //Check if the Text Option has a value (Or is the value blank?) $blank_value = TRUE; } else { //Value is valid and contains data --> Prepare for database $option = str_replace(TEXT_PREFIX,'',$option); $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES); $value = OPTIONS_VALUE_TEXT_ID; $this->contents[$products_id_string]['attributes_values'][$option] = $attr_value; } } if (!$blank_value) { $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 . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'"); } //EOF - Zappo - Option Types v2 - Check options loop for Text & Uploads, and add attributes accordingly... } } } } 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; //BOF - Zappo - Option Types v2 - ONE LINE - Add call to tep_get_uprid to correctly format product ids containing quotes $products_id = tep_get_uprid($products_id, $attributes); 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; // BOF Separate Pricing Per Customer // global variable (session) $sppc_customer_group_id -> class variable cg_id $this->cg_id = $this->get_customer_group_id(); // EOF Separate Pricing Per Customer 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']; // BOF Separate Pricing Per Customer $specials_price = tep_get_products_special_price((int)$prid); if (tep_not_null($specials_price)) { $products_price = $specials_price; } elseif ($this->cg_id != 0){ $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$prid . "' and customers_group_id = '" . $this->cg_id . "'"); if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) { $products_price = $customer_group_price['customers_group_price']; } } // EOF Separate Pricing Per Customer $this->total += $currencies->calculate_price($products_price, $products_tax, $qty); $this->weight += ($qty * $products_weight); } // attributes price // attributes price // BOF SPPC attributes mod 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 = '" . (int)$option . "' AND options_values_id = '" . (int)$value . "') OR ("; } $where=substr($where, 0, -5) . ')'; $attribute_price_query = tep_db_query("SELECT products_attributes_id, options_values_price, price_prefix FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . (int)$products_id . "'" . $where .""); if (tep_db_num_rows($attribute_price_query)) { $list_of_prdcts_attributes_id = ''; // empty array $attribute_price $attribute_price = array(); while ($attributes_price_array = tep_db_fetch_array($attribute_price_query)) { $attribute_price[] = $attributes_price_array; $list_of_prdcts_attributes_id .= $attributes_price_array['products_attributes_id'].","; } if (tep_not_null($list_of_prdcts_attributes_id) && $this->cg_id != '0') { $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")"; $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $this->cg_id . "'"); while ($pag_array = tep_db_fetch_array($pag_query)) { $cg_attr_prices[] = $pag_array; } // substitute options_values_price and prefix for those for the customer group (if available) if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) { for ($n = 0 ; $n < count($attribute_price); $n++) { for ($i = 0; $i < count($cg_attr_prices) ; $i++) { if ($cg_attr_prices[$i]['products_attributes_id'] == $attribute_price[$n]['products_attributes_id']) { $attribute_price[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix']; $attribute_price[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price']; } } // end for ($i = 0; $i < count($cg_att_prices) ; $i++) } } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices)) } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') // now loop through array $attribute_price to add up/substract attribute prices for ($n = 0 ; $n < count($attribute_price); $n++) { if ($attribute_price[$n]['price_prefix'] == '+') { $this->total += $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax, $qty); } else { $this->total -= $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax, $qty); } } // end for ($n = 0 ; $n < count($attribute_price); $n++) } // end if (tep_db_num_rows($attribute_price_query)) } // end if (isset($this->contents[$products_id]['attributes'])) } } // EOF SPPC attributes mod 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']; } } } return $attributes_price; } function get_products() { global $languages_id; // BOF Separate Pricing Per Customer $this->cg_id = $this->get_customer_group_id() ; // EOF Separate Pricing Per Customer 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']; // BOF Separate Pricing Per Customer $specials_price = tep_get_products_special_price($prid); if (tep_not_null($specials_price)) { $products_price = $specials_price; } elseif ($this->cg_id != 0){ $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$prid . "' and customers_group_id = '" . $this->cg_id . "'"); if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) { $products_price = $customer_group_price['customers_group_price']; } } // EOF Separate Pricing Per Customer $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], //BOF - Zappo - Option Types v2 - ONE LINE - Include attribute value_text. This is needed for text attributes. 'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''), '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'] : '')); } } 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']; } } } // added for Separate Pricing Per Customer, returns customer_group_id function get_customer_group_id() { if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') { $_cg_id = $_SESSION['sppc_customer_group_id']; } else { $_cg_id = 0; } return $_cg_id; } ?> Quote Link to comment Share on other sites More sharing options...
TracyS Posted January 15, 2010 Share Posted January 15, 2010 I'm thinking you might be missing a bit of code. My 'function restore_contents () { ' section has this in it: // BOF Separate Pricing Per Customer global $customer_id, $sppc_customer_group_id; if (!tep_session_is_registered('customer_id')) return false; if(!tep_session_is_registered('sppc_customer_group_id')) { $this->cg_id = '0'; } else { $this->cg_id = $sppc_customer_group_id; } // EOF Separate Pricing Per Customer Anyone get this fixed? I am having a hard time to: Fatal error: Call to undefined method shoppingCart::get_customer_group_id() /includes/classes/shopping_cart.php on line 147 The function is there! <?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); // BOF SPPC attribute hide/invalid check: loop through the shopping cart and check the attributes if they // are hidden for the now logged-in customer $this->cg_id = $this->get_customer_group_id(); while (list($products_id, ) = each($this->contents)) { // only check attributes if they are set for the product in the cart if (isset($this->contents[$products_id]['attributes'])) { $check_attributes_query = tep_db_query("select options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . tep_get_prid($products_id) . "'"); while ($_check_attributes = tep_db_fetch_array($check_attributes_query)) { $check_attributes[] = $_check_attributes; } // end while ($_check_attributes = tep_db_fetch_array($check_attributes_query)) $no_of_check_attributes = count($check_attributes); $change_products_id = '0'; foreach($this->contents[$products_id]['attributes'] as $attr_option => $attr_option_value) { $valid_option = '0'; for ($x = 0; $x < $no_of_check_attributes ; $x++) { if ($attr_option == $check_attributes[$x]['options_id'] && $attr_option_value == $check_attributes[$x]['options_values_id']) { $valid_option = '1'; if ($check_attributes[$x]['hide_attr_status'] == '1') { // delete hidden attributes from array attributes, change products_id accordingly later $change_products_id = '1'; unset($this->contents[$products_id]['attributes'][$attr_option]); } } // end if ($attr_option == $check_attributes[$x]['options_id'].... } // end for ($x = 0; $x < $no_of_check_attributes ; $x++) if ($valid_option == '0') { // after having gone through the options for this product and not having found a matching one // we can conclude that apparently this is not a valid option for this product so remove it unset($this->contents[$products_id]['attributes'][$attr_option]); // change products_id accordingly later $change_products_id = '1'; } } // end foreach($this->contents[$products_id]['attributes'] as $attr_option => $attr_option_value) if ($change_products_id == '1') { $original_products_id = $products_id; $products_id = tep_get_prid($original_products_id); $products_id = tep_get_uprid($products_id, $this->contents[$original_products_id]['attributes']); // add the product without the hidden attributes to the cart $this->contents[$products_id] = $this->contents[$original_products_id]; // delete the originally added product with the hidden attributes unset($this->contents[$original_products_id]); } } // end if (isset($this->contents[$products_id]['attributes'])) } // end while (list($products_id, ) = each($this->contents)) reset($this->contents); // reset the array otherwise the cart will be emptied // EOF SPPC attribute hide/invalid check 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) . "', '" . tep_db_input($qty) . "', '" . date('Ymd') . "')"); if (isset($this->contents[$products_id]['attributes'])) { //BOF - Zappo - Option Types v2 - Update query to include attribute value && Check for Uploads from customer and copy to Upload dir $uploads_query = tep_db_query("select files_uploaded_name from " . TABLE_FILES_UPLOADED . " where sesskey = '" . tep_session_id() . "'"); while ($uploads_array = tep_db_fetch_array($uploads_query)) { if (file_exists(TMP_DIR . $uploads_array['files_uploaded_name'])) { // Customer upload found in TMP dir --> Copy to Upload Dir @rename(TMP_DIR . $uploads_array['files_uploaded_name'], UPL_DIR . $uploads_array['files_uploaded_name']); // Set Customer_ID for the files that are found tep_db_query("update " . TABLE_FILES_UPLOADED . " set customers_id = '" . (int)$customer_id . "' where sesskey = '" . tep_session_id() . "' and files_uploaded_name = '" . $uploads_array['files_uploaded_name'] . "'"); } } reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attr_value = $this->contents[$products_id]['attributes_values'][$option]; tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')"); //EOF - Zappo - Option Types v2 - Update query to include attribute value && Check for Uploads from customer and copy to Upload dir } } } else { tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . tep_db_input($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 //BOF - Zappo - Option Types v2 - Update query to pull attribute value_text. This is needed for text attributes. $attributes_query = tep_db_query("select products_options_id, products_options_value_id, products_options_value_text 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']; // - Zappo - Option Types v2 - If attribute is Text, set additional information if ($attributes['products_options_value_id'] == OPTIONS_VALUE_TEXT_ID) { $this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text']; } //EOF - Zappo - Option Types v2 - Update query to pull attribute value_text. This is needed for text attributes. } } $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; // BOF Separate Pricing Per Customer $this->cg_id = $this->get_customer_group_id(); // EOF Separate Pricing Per Customer $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; //BOF - Zappo - Option Types v2 - Because of Text and Upload options, $option AND $value don't have to be numeric! /* if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { if (!is_numeric($option) || !is_numeric($value)) { $attributes_pass_check = false; break; } } } */ //EOF - Zappo - Option Types v2 - Because of Text and Upload options, $option AND $value don't have to be numeric! if (is_numeric($products_id) && is_numeric($qty) && ($attributes_pass_check == true)) { // BOF SPPC attribute hide check, original query expanded to include attributes $check_product_query = tep_db_query("select p.products_status, options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_ATTRIBUTES . " using(products_id) where p.products_id = '" . (int)$products_id . "'"); while ($_check_product = tep_db_fetch_array($check_product_query)) { $check_product[] = $_check_product; } // end while ($_check_product = tep_db_fetch_array($check_product_query)) $no_of_check_product = count($check_product); if (is_array($attributes)) { foreach($attributes as $attr_option => $attr_option_value) { $valid_option = '0'; for ($x = 0; $x < $no_of_check_product ; $x++) { if ($attr_option == $check_product[$x]['options_id'] && $attr_option_value == $check_product[$x]['options_values_id']) { $valid_option = '1'; if ($check_product[$x]['hide_attr_status'] == '1') { // delete hidden attributes from array attributes unset($attributes[$attr_option]); } } // end if ($attr_option == $check_product[$x]['options_id'].... } // end for ($x = 0; $x < $no_of_check_product ; $x++) if ($valid_option == '0') { // after having gone through the options for this product and not having found a matching one // we can conclude that apparently this is not a valid option for this product so remove it unset($attributes[$attr_option]); } } // end foreach($attributes as $attr_option => $attr_option_value) } // end if (is_array($attributes)) // now attributes have been checked and hidden and invalid ones deleted make the $products_id_string again $products_id_string = tep_get_uprid($products_id, $attributes); if ((isset($check_product) && tep_not_null($check_product)) && ($check_product[0]['products_status'] == '1')) { // EOF SPPC attribute hide check 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_string) . "', '" . (int)$qty . "', '" . date('Ymd') . "')"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { //BOF - Zappo - Option Types v2 - Check options loop, and add attributes accordingly... $attr_value = NULL; $blank_value = FALSE; if (strstr($option, TEXT_PREFIX)) { //Check for Text and Upload Options if (trim($value) == NULL) { //Check if the Text Option has a value (Or is the value blank?) $blank_value = TRUE; } else { //Value is valid and contains data --> Add Text Option value $option = str_replace(TEXT_PREFIX,'',$option); $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES); $value = OPTIONS_VALUE_TEXT_ID; $this->contents[$products_id_string]['attributes_values'][$option] = $attr_value; } } if (!$blank_value) { // If the Value is valid and Contains Data, add the option to the Cart.... $this->contents[$products_id_string]['attributes'][$option] = $value; // insert into database // - Zappo - Option Types v2 - Added products_options_value_text For saving Text and Upload Option Values 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, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . $option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')"); } //EOF - Zappo - Option Types v2 - Check options loop, and add attributes accordingly... } } } $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; $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_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 = '" . (int)$quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "'"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { //BOF - Zappo - Option Types v2 - Check options loop for Text & Uploads, and add attributes accordingly... $attr_value = NULL; $blank_value = FALSE; if (strstr($option, TEXT_PREFIX)) { //Check for Text and Upload Options if (trim($value) == NULL) { //Check if the Text Option has a value (Or is the value blank?) $blank_value = TRUE; } else { //Value is valid and contains data --> Prepare for database $option = str_replace(TEXT_PREFIX,'',$option); $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES); $value = OPTIONS_VALUE_TEXT_ID; $this->contents[$products_id_string]['attributes_values'][$option] = $attr_value; } } if (!$blank_value) { $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 . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'"); } //EOF - Zappo - Option Types v2 - Check options loop for Text & Uploads, and add attributes accordingly... } } } } 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; //BOF - Zappo - Option Types v2 - ONE LINE - Add call to tep_get_uprid to correctly format product ids containing quotes $products_id = tep_get_uprid($products_id, $attributes); 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; // BOF Separate Pricing Per Customer // global variable (session) $sppc_customer_group_id -> class variable cg_id $this->cg_id = $this->get_customer_group_id(); // EOF Separate Pricing Per Customer 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']; // BOF Separate Pricing Per Customer $specials_price = tep_get_products_special_price((int)$prid); if (tep_not_null($specials_price)) { $products_price = $specials_price; } elseif ($this->cg_id != 0){ $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$prid . "' and customers_group_id = '" . $this->cg_id . "'"); if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) { $products_price = $customer_group_price['customers_group_price']; } } // EOF Separate Pricing Per Customer $this->total += $currencies->calculate_price($products_price, $products_tax, $qty); $this->weight += ($qty * $products_weight); } // attributes price // attributes price // BOF SPPC attributes mod 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 = '" . (int)$option . "' AND options_values_id = '" . (int)$value . "') OR ("; } $where=substr($where, 0, -5) . ')'; $attribute_price_query = tep_db_query("SELECT products_attributes_id, options_values_price, price_prefix FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . (int)$products_id . "'" . $where .""); if (tep_db_num_rows($attribute_price_query)) { $list_of_prdcts_attributes_id = ''; // empty array $attribute_price $attribute_price = array(); while ($attributes_price_array = tep_db_fetch_array($attribute_price_query)) { $attribute_price[] = $attributes_price_array; $list_of_prdcts_attributes_id .= $attributes_price_array['products_attributes_id'].","; } if (tep_not_null($list_of_prdcts_attributes_id) && $this->cg_id != '0') { $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")"; $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $this->cg_id . "'"); while ($pag_array = tep_db_fetch_array($pag_query)) { $cg_attr_prices[] = $pag_array; } // substitute options_values_price and prefix for those for the customer group (if available) if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) { for ($n = 0 ; $n < count($attribute_price); $n++) { for ($i = 0; $i < count($cg_attr_prices) ; $i++) { if ($cg_attr_prices[$i]['products_attributes_id'] == $attribute_price[$n]['products_attributes_id']) { $attribute_price[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix']; $attribute_price[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price']; } } // end for ($i = 0; $i < count($cg_att_prices) ; $i++) } } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices)) } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') // now loop through array $attribute_price to add up/substract attribute prices for ($n = 0 ; $n < count($attribute_price); $n++) { if ($attribute_price[$n]['price_prefix'] == '+') { $this->total += $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax, $qty); } else { $this->total -= $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax, $qty); } } // end for ($n = 0 ; $n < count($attribute_price); $n++) } // end if (tep_db_num_rows($attribute_price_query)) } // end if (isset($this->contents[$products_id]['attributes'])) } } // EOF SPPC attributes mod 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']; } } } return $attributes_price; } function get_products() { global $languages_id; // BOF Separate Pricing Per Customer $this->cg_id = $this->get_customer_group_id() ; // EOF Separate Pricing Per Customer 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']; // BOF Separate Pricing Per Customer $specials_price = tep_get_products_special_price($prid); if (tep_not_null($specials_price)) { $products_price = $specials_price; } elseif ($this->cg_id != 0){ $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$prid . "' and customers_group_id = '" . $this->cg_id . "'"); if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) { $products_price = $customer_group_price['customers_group_price']; } } // EOF Separate Pricing Per Customer $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], //BOF - Zappo - Option Types v2 - ONE LINE - Include attribute value_text. This is needed for text attributes. 'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''), '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'] : '')); } } 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']; } } } // added for Separate Pricing Per Customer, returns customer_group_id function get_customer_group_id() { if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') { $_cg_id = $_SESSION['sppc_customer_group_id']; } else { $_cg_id = 0; } return $_cg_id; } ?> Quote ~Tracy Link to comment Share on other sites More sharing options...
multimixer Posted January 16, 2010 Share Posted January 16, 2010 Hello people I just posted a working merging attempt of SPPC and OptionTypes v2 at the option types forum. It would be great if somebody who got busy with this issue before could take a look and comment about. It's far away from being "perfect" but it works without any mistakes as far as I could test My post is here merge SPPC and Option Types v2 Quote My community profile | Template system for osCommerce - New: Responsive | Feedback channel Link to comment Share on other sites More sharing options...
Jan Zonjee Posted January 16, 2010 Share Posted January 16, 2010 Anyone get this fixed? I am having a hard time to: Fatal error: Call to undefined method shoppingCart::get_customer_group_id() /includes/classes/shopping_cart.php on line 147 The function is there! Indeed, but outside the class. You need to move a parentheses that is now directly above the function to below it: function unserialize($broken) { for(reset($broken);$kv=each($broken);) { $key=$kv['key']; if (gettype($this->$key)!="user function") $this->$key=$kv['value']; } } // this one has to go } // added for Separate Pricing Per Customer, returns customer_group_id function get_customer_group_id() { if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') { $_cg_id = $_SESSION['sppc_customer_group_id']; } else { $_cg_id = 0; } return $_cg_id; } } // end of shopping cart class ?> Quote Link to comment Share on other sites More sharing options...
wkdwich Posted January 18, 2010 Share Posted January 18, 2010 I wish I had the time to scour the 271 pages of posts to this contribution, but this week I don't so forgive me if this was answered.. I have a customer with and office & sales that originate from the US and an office & sales that originate in CA.. If Item A sells for $20 US$ it does not always sell for the exact amount of whatever todays exhange rate is.. in other words.. if the exchange rate made it $22.50CA$ it might actually be selling for $25CA$ I know that SPPC will allow the pricing to be independantly kept which is great.. but I want the group assigned to the CA pricing to be in CA$ not US$ Is there any way to force that group's pricing to CA$??? Both offices also do distributor sales so I was hoping to set up 4 groups: 1 - retail US$ 2 - retail CA$ 3 - wholesale US$ 4 - wholesale CA$ right now I think I have to add the hide prices from unregistered, as well the office will need to approve all accounts, verifying the customer chose the proper category when registering.. If anyone sees any flaws or better ideas, I would really appreciate that.. Debbie Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com Link to comment Share on other sites More sharing options...
Guest Posted January 19, 2010 Share Posted January 19, 2010 Hello, I successfuly install this great contribution. Everything works great, but... why I can't use order total modules for retail group? If I create new group, everything works great in that group, but not in retail group. I check documentation and now I came here for answer. Its 280 pages for this contribution on this forum, so its hard to find quick answer. Would somebody please help me? Thanks, Bojan Quote Link to comment Share on other sites More sharing options...
TracyS Posted January 19, 2010 Share Posted January 19, 2010 Isn't this set through Localization in the admin area and then automatically selected based on what country the visitors web browser says they are from? I wish I had the time to scour the 271 pages of posts to this contribution, but this week I don't so forgive me if this was answered.. I have a customer with and office & sales that originate from the US and an office & sales that originate in CA.. If Item A sells for $20 US$ it does not always sell for the exact amount of whatever todays exhange rate is.. in other words.. if the exchange rate made it $22.50CA$ it might actually be selling for $25CA$ I know that SPPC will allow the pricing to be independantly kept which is great.. but I want the group assigned to the CA pricing to be in CA$ not US$ Is there any way to force that group's pricing to CA$??? Both offices also do distributor sales so I was hoping to set up 4 groups: 1 - retail US$ 2 - retail CA$ 3 - wholesale US$ 4 - wholesale CA$ right now I think I have to add the hide prices from unregistered, as well the office will need to approve all accounts, verifying the customer chose the proper category when registering.. If anyone sees any flaws or better ideas, I would really appreciate that.. Debbie Quote ~Tracy Link to comment Share on other sites More sharing options...
wkdwich Posted January 19, 2010 Share Posted January 19, 2010 Isn't this set through Localization in the admin area and then automatically selected based on what country the visitors web browser says they are from? Well it might very well be. I have no experience with multiple currencies.. I do plan on showing the currency box there.. all current customers will be notified they need to use that box to see pricing in their $$.. I may be over thi king this issue :) I;m confused about it at this point :) Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com Link to comment Share on other sites More sharing options...
Jan Zonjee Posted January 19, 2010 Share Posted January 19, 2010 Well it might very well be. I have no experience with multiple currencies.. I do plan on showing the currency box there.. all current customers will be notified they need to use that box to see pricing in their $$.. I may be over thi king this issue :) I;m confused about it at this point :) I have never looked very well at the currency issue but my understanding is that osC treats the numbers in the table column products_price as being in the default currency and will calculate an equivalent price using rates for another currency. That is not what you want. You want the number to be in a currency that you choose for the customer. Perhaps one of the things you will have to do is avoiding the recalculation in currencies, function format: // class methods function format($number, $calculate_currency_value = false, $currency_type = '', $currency_value = '') { In application_top.php there is also a part that deals with currency (around line 300): // currency if (!tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) { if (!tep_session_is_registered('currency')) tep_session_register('currency'); if (isset($HTTP_GET_VARS['currency']) && $currencies->is_set($HTTP_GET_VARS['currency'])) { $currency = $HTTP_GET_VARS['currency']; } else { $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY; } } You will probably have to extend customers_groups with a column currency and query/set that in the session variables when logging in. Of course logged in customers should not be able to use the currency box to switch currency I think. How to deal with non-logged in customers.... Perhaps changing the customer group based on chosen currency too? That will take changes in quite a few files. This is unchartered territory so no easy answers here... Quote Link to comment Share on other sites More sharing options...
wkdwich Posted January 19, 2010 Share Posted January 19, 2010 I have never looked very well at the currency issue but my understanding is that osC treats the numbers in the table column products_price as being in the default currency and will calculate an equivalent price using rates for another currency. That is not what you want. You want the number to be in a currency that you choose for the customer. Perhaps one of the things you will have to do is avoiding the recalculation in currencies, function format: // class methods function format($number, $calculate_currency_value = false, $currency_type = '', $currency_value = '') { In application_top.php there is also a part that deals with currency (around line 300): // currency if (!tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) { if (!tep_session_is_registered('currency')) tep_session_register('currency'); if (isset($HTTP_GET_VARS['currency']) && $currencies->is_set($HTTP_GET_VARS['currency'])) { $currency = $HTTP_GET_VARS['currency']; } else { $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY; } } You will probably have to extend customers_groups with a column currency and query/set that in the session variables when logging in. Of course logged in customers should not be able to use the currency box to switch currency I think. How to deal with non-logged in customers.... Perhaps changing the customer group based on chosen currency too? That will take changes in quite a few files. This is unchartered territory so no easy answers here... Jan I NEVER have easy questions :) which leads to never getting easy answers :) I thank you oh so much for taking the time to think about this issue.. I do plan on installing the contribution that hides the prices from non-logged in peeps.. I also will have the owners approve and verify all new registrations to be sure the proper user group was chosen.. so that will take care of the non logged in peeps, and registered peeps prior to being approved.. If I can get SPPC to auto use one or the other currency that would be fantastic and I would then not need the currency box.. do you think it will be a complex thing to get the groups forced to one currency or the other?? I am thinking if its going to be a real ordeal, they will have to deal with it.. the CA person will just have to do backwards math, taking what she determines is the CA$ price and convert it back to US$?? then have the currency box active and at every opportunity let the CA people know they must change currencies.. am I thinking right here??? Oh just in case it makes any difference to you this cart will be osCMax v2.0.4.. so SPPC is already installed, but I am not 100% sure what version it is.. Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com Link to comment Share on other sites More sharing options...
wkdwich Posted January 20, 2010 Share Posted January 20, 2010 I'm having a brain cramp.. how/where do I set it up so all registrations need to be approved?? is that am SPPC thing or something else I installed on another cart???? Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com Link to comment Share on other sites More sharing options...
multimixer Posted January 22, 2010 Share Posted January 22, 2010 Hi people If somebody is interested, I just posted a "new version" about how to merge SPPC and Option Types v2 Quote My community profile | Template system for osCommerce - New: Responsive | Feedback channel Link to comment Share on other sites More sharing options...
TracyS Posted January 22, 2010 Share Posted January 22, 2010 I don't know if this will help or not - but we only show US Dollar currency on our site, regardless of what country the visitor is from. I went in and commented out the browser check to switch languages and currencies based on where the visitors browser says they are from (I believe it was in application_top). I set our currencies option in Admin to just USD (and I placed that text after the dollar amount, so prices show as $14.99 USD) and that way the customer knows they are looking at US dollar prices and will be charged US dollar prices for their purchase. Would that work for your store, rather than trying to charge them in their currency? Jan I NEVER have easy questions :) which leads to never getting easy answers :) I thank you oh so much for taking the time to think about this issue.. I do plan on installing the contribution that hides the prices from non-logged in peeps.. I also will have the owners approve and verify all new registrations to be sure the proper user group was chosen.. so that will take care of the non logged in peeps, and registered peeps prior to being approved.. If I can get SPPC to auto use one or the other currency that would be fantastic and I would then not need the currency box.. do you think it will be a complex thing to get the groups forced to one currency or the other?? I am thinking if its going to be a real ordeal, they will have to deal with it.. the CA person will just have to do backwards math, taking what she determines is the CA$ price and convert it back to US$?? then have the currency box active and at every opportunity let the CA people know they must change currencies.. am I thinking right here??? Oh just in case it makes any difference to you this cart will be osCMax v2.0.4.. so SPPC is already installed, but I am not 100% sure what version it is.. Quote ~Tracy Link to comment Share on other sites More sharing options...
wkdwich Posted January 22, 2010 Share Posted January 22, 2010 I don't know if this will help or not - but we only show US Dollar currency on our site, regardless of what country the visitor is from. I went in and commented out the browser check to switch languages and currencies based on where the visitors browser says they are from (I believe it was in application_top). I set our currencies option in Admin to just USD (and I placed that text after the dollar amount, so prices show as $14.99 USD) and that way the customer knows they are looking at US dollar prices and will be charged US dollar prices for their purchase. Would that work for your store, rather than trying to charge them in their currency? thanks Tracy that might help for sure.. I think if I added the USD after the price like you did and left the currency selector there so the CA people can switch that would def do the trick.. hum.. but no.. wait.. if they switched to CAD then it would still say USD so no, thats not my answer.. I did set up 2 customer groups.. and the 2 owners can switch them customers to the appropriate group.. the US lady sells more than the CA lady.. I've already instructed her she needs to let her people know they need to use the currancy switch.. But I would appreciate if you cou;d point me to where that checking code is so I can take a closer look.. I was not aware osc did that checking.. so if it does then I have to assume that a good percentage of the time the cart will auto switch to CAD - USD will be default. Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com Link to comment Share on other sites More sharing options...
geronimo978 Posted January 22, 2010 Share Posted January 22, 2010 I have installed this mod and am very happy with how it functions. However, I am having issues with my create account page. When a customer creates an account without a tax id, everything runs smoothly. However, when a customer enters a tax id and hits submit I get a 500 internal server error. BUT.... the customers info goes through and they can login in the future. Does anyone know where the problem may lie? Also, is the red light in the RA field supposed to go away after you change their group?? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
geronimo978 Posted January 23, 2010 Share Posted January 23, 2010 I have installed this mod and am very happy with how it functions. However, I am having issues with my create account page. When a customer creates an account without a tax id, everything runs smoothly. However, when a customer enters a tax id and hits submit I get a 500 internal server error. BUT.... the customers info goes through and they can login in the future. Does anyone know where the problem may lie? Also, is the red light in the RA field supposed to go away after you change their group?? Thanks in advance. Update: I called my host and it is nothing on their end as I figured. I think I just screwed up somewhere. So any advise there would be awesome. Also, I can't believe that I didn't see the turn off alert radio button.....so disregard the RA field question. Quote Link to comment Share on other sites More sharing options...
wkdwich Posted January 25, 2010 Share Posted January 25, 2010 Update to my situation.. I have 99% successfully merged "Hide products (and categories) from customer groups for SPPC" v2.0.3 into OSCmax.. I have a few issues. some background.. 2 store owners, 1 each on US and Canada, need separate stock but require 1 store. I chose OSCMax because it has SPPC along with many other mods already installed. We set up USD as the default, and added CAD as a currency option. I duplicated the payment and shipping modules al la adding extra "table" shipping found somewhere here. Created 5 customer groups default retail US wholesale US retail CA wholesale CA Within the groups I have successfully assigned both specific shipping and payments per the different owner needs. Products will be duplicated in each respective category (they 99.9% sell the same items) each will be appended with "us" or "ca" respectively so each owner can see easily all products came from the assigned customer groups. Both owners will get all mails per their requests ================ The first test run after the merge (especially challenging because of all the mods already added into OSCmax) and I had no customer side index page.. I found a coding error I made and fixed that. Admin side had another issue or 3 that I found and fixed. As of right now I can successfully hide an existing or new product. The tick boxes and customer group names appear, the icon shows on the admin products page, I tested and indeed they are hidden when logged into the group they should be hidden from. Problem #1 -- no tick boxes show when creating a new or edit an existing category. I triple checked that area of the code and all seems well - the tick boxes and customer groups are just not there.. Problem #2 -- I can add products and get all the way through to the confirm order page, when that is clicked, I get sent back to the payment page.. as well there is an error message on the billing address as shown on the confirm order page. Billing Address (Edit) Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/tuffen/public_html/includes/functions/general.php on line 48 The code there looks like: // Parse the data used in the html tags to ensure the tags will not break function tep_parse_input_field_data($data, $parse) { return strtr(trim($data), $parse); } function tep_output_string($string, $translate = false, $protected = false) { if ($protected == true) { return htmlspecialchars($string); } else { if ($translate == false) { return tep_parse_input_field_data($string, array('"' => '"')); } else { return tep_parse_input_field_data($string, $translate); } } } This section of code was untouched by this mod, so thats why I am so confused over it. I have read a ton of replies on this in both this forum and oscmax forums and can't find anything that looks like it is my answer.. One thing I know is it may not have anything to do with this mod.. it might have something to do with the payment modules, so I removed all but money prder payments and the error remains.. Any help with either of these would be appreciated Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com Link to comment Share on other sites More sharing options...
geronimo978 Posted January 25, 2010 Share Posted January 25, 2010 Update: I called my host and it is nothing on their end as I figured. I think I just screwed up somewhere. So any advise there would be awesome. Also, I can't believe that I didn't see the turn off alert radio button.....so disregard the RA field question. Found the solution: Turns out that because I was setting this all up on a fresh installation of OSC and didn't have any store info set up yet, it wasn't working. Once I put in the stores email address it worked fine. Quote Link to comment Share on other sites More sharing options...
TracyS Posted January 25, 2010 Share Posted January 25, 2010 You set the code for each currency amount you have - so U.S. Dollars would say USD and Candaian Dollars would say CAD depending on how you set it up. It's in Admin -> Localization -> Currencies As for stuff in includes/application_top.php - there is currency info here: // currency if (!tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) { if (!tep_session_is_registered('currency')) tep_session_register('currency'); if (isset($HTTP_GET_VARS['currency']) && $currencies->is_set($HTTP_GET_VARS['currency'])) { $currency = $HTTP_GET_VARS['currency']; } else { $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY; } } I didn't chage the currency block as I used the Admin area to make sure I only had USD Setup. Also in application top - I changed this: if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) { $lng->set_language($HTTP_GET_VARS['language']); } else { $lng->get_browser_language(); } to this: if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) { $lng->set_language($HTTP_GET_VARS['language']); } else { //$lng->get_browser_language(); $lng->set_language(DEFAULT_LANGUAGE); } In our case I made this change because I didn't have all of the language files correctly updated in their various folders and it was causing problems for visitors in other countries. Considering we only use English anyway - I made this change. thanks Tracy that might help for sure.. I think if I added the USD after the price like you did and left the currency selector there so the CA people can switch that would def do the trick.. hum.. but no.. wait.. if they switched to CAD then it would still say USD so no, thats not my answer.. I did set up 2 customer groups.. and the 2 owners can switch them customers to the appropriate group.. the US lady sells more than the CA lady.. I've already instructed her she needs to let her people know they need to use the currancy switch.. But I would appreciate if you cou;d point me to where that checking code is so I can take a closer look.. I was not aware osc did that checking.. so if it does then I have to assume that a good percentage of the time the cart will auto switch to CAD - USD will be default. Quote ~Tracy Link to comment Share on other sites More sharing options...
wkdwich Posted January 25, 2010 Share Posted January 25, 2010 Thanks Tracy I will try that.. Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com Link to comment Share on other sites More sharing options...
bhbilbao Posted January 28, 2010 Share Posted January 28, 2010 Jan , need help SPPC + CUSTOM PRODUCT BUILDER After adding a new custom to the shoping cart, there is no description of the product in shoping_cart.php page. The name of the new product is right (Build #16993) but there is no description of the componentes chosen. I modified to this in includes/modules/builder_add_attribute.php tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values (NULL, '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "', '" . (int)$products_options_sort_order . "', '@')"); The problem is here: catalog/includes/classes/shopping_cart.php Before, working: 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); //Custom Begin if (($check_product !== false)) { //Custom End if ($notify == true) { ... After, not working: 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); //Custom Begin // if (($check_product !== false)) { //Custom End // BOF SPPC attribute hide check, original query expanded to include attributes $check_product_query = tep_db_query("select p.products_status, options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_ATTRIBUTES . " using(products_id) where p.products_id = '" . (int)$products_id . "'"); while ($_check_product = tep_db_fetch_array($check_product_query)) { $check_product[] = $_check_product; } // end while ($_check_product = tep_db_fetch_array($check_product_query)) $no_of_check_product = count($check_product); if (is_array($attributes)) { foreach($attributes as $attr_option => $attr_option_value) { $valid_option = '0'; for ($x = 0; $x < $no_of_check_product ; $x++) { if ($attr_option == $check_product[$x]['options_id'] && $attr_option_value == $check_product[$x]['options_values_id']) { $valid_option = '1'; if ($check_product[$x]['hide_attr_status'] == '1') { // delete hidden attributes from array attributes unset($attributes[$attr_option]); } } // end if ($attr_option == $check_product[$x]['options_id'].... } // end for ($x = 0; $x < $no_of_check_product ; $x++) if ($valid_option == '0') { // after having gone through the options for this product and not having found a matching one // we can conclude that apparently this is not a valid option for this product so remove it unset($attributes[$attr_option]); } } // end foreach($attributes as $attr_option => $attr_option_value) } // end if (is_array($attributes)) // now attributes have been checked and hidden and invalid ones deleted make the $products_id_string again $products_id_string = tep_get_uprid($products_id, $attributes); if ((isset($check_product) && tep_not_null($check_product)) && ($check_product[0]['products_status'] == '1')) { // EOF SPPC attribute hide check if ($notify == true) { ... Quote Link to comment Share on other sites More sharing options...
bhbilbao Posted January 28, 2010 Share Posted January 28, 2010 More info: Only works if a customer is registered and login. If the customer is a visitor when finishing the custom builder and click on "add to cart" there is no description. I looked the database products_atributes 202 16627 3 6 0.0000 + 0 0 203 16627 3 6 0.0000 + 0 @ 204 16627 4 7 0.0000 + 0 0 205 16627 4 7 0.0000 + 0 @ Are duplicating the attributes when record values of the custom product???? Quote Link to comment Share on other sites More sharing options...
bhbilbao Posted January 29, 2010 Share Posted January 29, 2010 New question with SPPC + HIDE PRODUCTS SPPC + Atributes Cloner&Copier original code in admin/products_attributes.php: case 'clone_attributes': $clone_product_id_from = $HTTP_POST_VARS['clone_products_id_from']; $clone_product_id_to = $HTTP_POST_VARS['clone_products_id_to']; tep_db_query("delete from ".TABLE_PRODUCTS_ATTRIBUTES." WHERE products_id='".$clone_product_id_to."'"); $attributes = tep_db_query("select products_id, options_id, options_values_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES ." where products_id='".$clone_product_id_from."'"); while($attributes_values = tep_db_fetch_array($attributes)) { tep_db_query("INSERT INTO " . TABLE_PRODUCTS_ATTRIBUTES . " ( products_id, options_id, options_values_id, options_values_price, price_prefix ) VALUES (".$clone_product_id_to.", ".$attributes_values['options_id'].", ".$attributes_values['options_values_id'].", ".$attributes_values['options_values_price'].", '".$attributes_values['price_prefix']."')"); } break; Modified code: case 'clone_attributes': $clone_product_id_from = $HTTP_POST_VARS['clone_products_id_from']; $clone_product_id_to = $HTTP_POST_VARS['clone_products_id_to']; tep_db_query("delete from ".TABLE_PRODUCTS_ATTRIBUTES." WHERE products_id='".$clone_product_id_to."'"); $attributes = tep_db_query("select products_id, options_id, options_values_id, options_values_price, price_prefix, products_options_sort_order, attributes_hide_from_groups from " . TABLE_PRODUCTS_ATTRIBUTES ." where products_id='".$clone_product_id_from."'"); while($attributes_values = tep_db_fetch_array($attributes)) { tep_db_query("INSERT INTO " . TABLE_PRODUCTS_ATTRIBUTES . " ( products_id, options_id, options_values_id, options_values_price, price_prefix, products_options_sort_order, attributes_hide_from_groups ) VALUES (".$clone_product_id_to.", ".$attributes_values['options_id'].", ".$attributes_values['options_values_id'].", ".$attributes_values['options_values_price'].", '".$attributes_values['price_prefix']."', ".$attributes_values['products_options_sort_order'].", ".$attributes_values['attributes_hide_from_groups'].")"); } break; If the cloned attributes dont have a Hidden Status (defaunt @) gets an error. CANNOT BE NULL If the cloned attributes have Hidden Status (@,0) the following error: 1136 - Column count doesn't match value count at row 1 INSERT INTO products_attributes ( products_id, options_id, options_values_id, options_values_price, price_prefix, products_options_sort_order, attributes_hide_from_groups ) VALUES (9062, 1, 1, 5.0000, '+', 1, @,0) [TEP STOP] Only works if I remove "attributes_hide_from_groups" but default it asign a @ (the database default option). ¿? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.