kimm Posted August 13, 2008 Share Posted August 13, 2008 (edited) Hi Jan! I need your help please. Have installed this on a very modified store and everything on admin side seems good as does the catalog. When I go to checkout I get this error. Fatal error: Call to a member function on a non-object in /mnt/w0509/d22/s31/b029d318/www/DivasDen/catalog/includes/classes/shopping_cart.php on line 487 Here is my shopping_cart I would appreciate any help I am very new at php coding. <?php /* $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url] Copyright © 2003 osCommerce Released under the GNU General Public License */ class shoppingCart { //start gift registry var $contents, $total, $weight, $cartID, $content_type, $registry_id, $registry_customers_id; //end gift registry function shoppingCart() { $this->reset(); } function restore_contents() { //CCGV Replace Line global $customer_id, $gv_id, $REMOTE_ADDR; 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) . "', '" . $qty . "', '" . date('Ymd') . "')"); if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')"); } } } else { tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } } //ADDED FOR CCGV - START if (tep_session_is_registered('gv_id')) { $gv_query = tep_db_query("insert into " . TABLE_COUPON_REDEEM_TRACK . " (coupon_id, customer_id, redeem_date, redeem_ip) values ('" . $gv_id . "', '" . (int)$customer_id . "', now(),'" . $REMOTE_ADDR . "')"); $gv_update = tep_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id = '" . $gv_id . "'"); tep_gv_account_update($customer_id, $gv_id); tep_session_unregister('gv_id'); } //ADDED FOR CCGV - END } // 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 $attributes_query = tep_db_query("select products_options_id, products_options_value_id 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']; } } $this->cleanup(); } function reset($reset_database = false) { global $customer_id; $this->contents = array(); $this->total = 0; $this->weight = 0; $this->content_type = false; //start gift registry $this->registry_id = 0; $this->registry_customers_id = 0; //end gift registry 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); $attributes_pass_check = true; if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { if (!is_numeric($option) || !is_numeric($value)) { $attributes_pass_check = false; break; } } } 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' => $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)) { $this->contents[$products_id_string]['attributes'][$option] = $value; // insert into database 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) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "')"); } } } $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(); } } } //start gift registry function add_cart_not_in_db($products_id, $qty = '', $attributes = '', $notify = true, $reg_id= 0, $reg_cust_id = 0) { global $new_products_id_in_cart, $customer_id; $products_id = tep_get_uprid($products_id, $attributes); if ($notify == true) { $new_products_id_in_cart = $products_id; tep_session_register('new_products_id_in_cart'); } if ($this->in_cart($products_id)) { $this->update_quantity($products_id, $qty, $attributes); } else { if ($qty == '') $qty = '1'; // if no quantity is supplied, then add '1' to the customers basket $this->contents[] = array($products_id); $this->contents[$products_id] = array('qty' => $qty); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { $this->contents[$products_id]['attributes'][$option] = $value; } } } $this->cleanup(); //add the registry owner id to the cart $this->registry_id = $reg_id; $this->registry_customers_id = $reg_cust_id; // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } //end gift registry 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); $attributes_pass_check = true; if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { if (!is_numeric($option) || !is_numeric($value)) { $attributes_pass_check = false; break; } } } 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' => $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)) { $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 . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "' and products_options_id = '" . (int)$option . "'"); } } } } 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); // start Get 1 free // If this product qualifies for free product(s) add in the number of free products if (is_array ($free_product = $this->get1free ($products_id))) { $total_items += $free_product['quantity']; } // end Get 1 free } } 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; 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) . "'"); } // start Get 1 Free // If this product qualifies for free product(s) remove the free products if (is_array ($free_product = $this->get1free ($products_id))) { $pid = (int)$free_product['id']; print '<br>Found Product: ' . $pid; unset($this->contents[$pid]); // 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($pid) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($pid) . "'"); } } // end Get 1 Free // 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() { $this->total_virtual = 0; // CCGV $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)) { // CCGV ADDED - START $no_count = 1; $gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $gv_result = tep_db_fetch_array($gv_query); if (ereg('^GIFT', $gv_result['products_model'])) { $no_count = 0; } // CCGV ADDED - END $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_virtual += tep_add_tax($products_price, $products_tax) * $qty * $no_count;// CCGV $this->weight_virtual += ($qty * $products_weight) * $no_count;// CCGV $this->total += tep_add_tax($products_price, $products_tax) * $qty; $this->weight += ($qty * $products_weight); // start Get 1 Free // If this product qualifies for free product(s) add in the total weight of free products if (is_array ($free_product = $this->get1free ($products_id))) { $this->weight += $free_product['quantity'] * $free_product['weight']; } // end Get 1 Free } // 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 // changed completely for Separate Pricing Per Customer, attributes mod function attributes_price($products_id) { // global variable (session) $sppc_customer_group_id -> class variable cg_id $this->cg_id = $this->get_customer_group_id(); 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 = ''; 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'] == '+') { $attributes_price += $attribute_price[$n]['options_values_price']; } else { $attributes_price -= $attribute_price[$n]['options_values_price']; } } // end for ($n = 0; $n < count($attribute_price); $n++) return $attributes_price; } else { // end if (tep_db_num_rows($attribute_price_query)) return 0; } } else { // end if (isset($this->contents[$products_id]['attributes'])) return 0; } } // end of function attributes_price, modified for SPPC with attributes 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_bundle, 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, 'bundle' => $products['products_bundle'], 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], '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'] : '')); // start Get 1 free if (is_array ($free_product = $this->get1free ($products_id))) { // Add the free product to the shopping cart (Customer cannot alter this) $products_array[] = array('id' => $free_product['id'], 'name' => $free_product['name'], 'model' => $free_product['model'], 'image' => $free_product['image'], 'price' => 0, 'quantity' => $free_product['quantity'], 'weight' => $free_product['weight'], 'final_price' => 0, 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => '', 'free' => 1 ); } //if (is_array // end Get 1 free } } 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); //CCGV Edited begin 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 { // CCGV Edited end // CCGV ADDED - BEGIN if ($this->show_weight() == 0) { $wvirtual_check_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'"); $wvirtual_check = tep_db_fetch_array($wvirtual_check_query); if ($wvirtual_check['products_weight'] == 0) { switch ($this->content_type) { case 'physical': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'virtual_weight'; break; } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } } } elseif ($this->show_weight() == 0) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $virtual_check_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'"); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['products_weight'] == 0) { switch ($this->content_type) { case 'physical': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'virtual_weight'; break; } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } // CCGV ADDED - END } 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)wink.gif { $key=$kv['key']; if (gettype($this->$key)!="user function") $this->$key=$kv['value']; } } // start Get 1 Free function get1free ($products_id) { global $languages_id; $get_1_free_query = tep_db_query("select products_free_id, products_free_quantity, products_qualify_quantity, products_multiple, get_1_free_expires_date from " . TABLE_GET_1_FREE . " where products_id = '" . (int)$products_id . "' and status = '1'" ); if (tep_db_num_rows($get_1_free_query) > 0) { $get_1_free = tep_db_fetch_array($get_1_free_query); //Check that the offer has not expired //MNK bugfix 13.08.2007 if (($get_1_free['get_1_free_expires_date'] <= date('Y-m-d H:i:s')) && ($get_1_free['get_1_free_expires_date'] != '0000-00-00 00:00:00')) { //offer has expired, so update the database and return false tep_db_query("update " . TABLE_GET_1_FREE . " set status = '0', date_status_change = now() where products_id = '" . (int)$products_id . "'" ); return false; } else { // Offer is valid, so check if the quantity qualifies $products_quantity = $this->contents[$products_id]['qty']; if ($products_quantity >= $get_1_free['products_qualify_quantity']) { // Qualifies, so get the quantity of free products $free_quantity = 1; if ($get_1_free['products_multiple'] > 1) { $free_quantity = floor ($products_quantity / $get_1_free['products_qualify_quantity']); if ($free_quantity > $get_1_free['products_multiple']) { $free_quantity = $get_1_free['products_multiple']; } } // Get the info on the free product $products_free_query = tep_db_query("select pd.products_name, p.products_model, p.products_image, p.products_weight from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$get_1_free['products_free_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'" ); $products_free = tep_db_fetch_array($products_free_query); // Return an array of free product values $output = array ( 'id' => $get_1_free['products_free_id'], 'quantity' => $free_quantity, 'name' => $products_free['products_name'], 'model' => $products_free['products_model'], 'image' => $products_free['products_image'], 'weight' => $products_free['products_weight'] ); return $output; } //if ($products_quantity } //else }//if (tep_db_num_rows // offer was not valid (disabled or expired) return false; }//function // end Get 1 Free // CCGV ADDED - START function count_contents_virtual() { // get total number of items in cart disregard gift vouchers $total_items = 0; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $no_count = false; $gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'"); $gv_result = tep_db_fetch_array($gv_query); if (ereg('^GIFT', $gv_result['products_model'])) { $no_count=true; } if (NO_COUNT_ZERO_WEIGHT == 1) { $gv_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($products_id) . "'"); $gv_result=tep_db_fetch_array($gv_query); if ($gv_result['products_weight']<=MINIMUM_WEIGHT) { $no_count=true; } } if (!$no_count) $total_items += $this->get_quantity($products_id); } } return $total_items; } // CCGV ADDED - END // 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; } } ?> Thank you for your time Kim Edited August 13, 2008 by Jan Zonjee Quote Link to comment Share on other sites More sharing options...
ChantalC Posted August 13, 2008 Share Posted August 13, 2008 I don't see why product_info.php should be the source of the problem (I can't see an obvious problem and if it was working without SPPC I don't see why it suddenly wouldn't work now). It could also be application_top.php or includes/classes/shopping_cart.php. Hi Jan, I believe that the problem must be in product_info, because for QTpro and SPPC I have to change the same lines of the original text. Let me explain in code: This piece of code of a original product_info is should be replaced by QTpro: <?php $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'"); $products_attributes = tep_db_fetch_array($products_attributes_query); if ($products_attributes['total'] > 0) { ?> <table border="0" cellspacing="0" cellpadding="2"> <tr> <td class="main" colspan="2"><?php echo TEXT_PRODUCT_OPTIONS; ?></td> </tr> <?php $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name"); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $products_options_array = array(); $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'"); while ($products_options = tep_db_fetch_array($products_options_query)) { $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); if ($products_options['options_values_price'] != '0') { $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } } if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]; } else { $selected_attribute = false; } ?> <tr> <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td> <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td> </tr> <?php } ?> </table> <?php } ?> QTpro code: //++++ QT Pro: Begin Changed code if (tep_not_null($product_info['products_image'])) { ?> </td> </tr> </table> <?php } //++++ QT Pro: End Changed Code $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'"); $products_attributes = tep_db_fetch_array($products_attributes_query); if ($products_attributes['total'] > 0) { //++++ QT Pro: Begin Changed code $products_id=(preg_match("/^\d{1,10}(\{\d{1,10}\}\d{1,10})*$/",$HTTP_GET_VARS['products_id']) ? $HTTP_GET_VARS['products_id'] : (int)$HTTP_GET_VARS['products_id']); require(DIR_WS_CLASSES . 'pad_' . PRODINFO_ATTRIBUTE_PLUGIN . '.php'); $class = 'pad_' . PRODINFO_ATTRIBUTE_PLUGIN; $pad = new $class($products_id); echo $pad->draw(); } //Display a table with which attributecombinations is on stock to the customer? if(PRODINFO_ATTRIBUTE_DISPLAY_STOCK_LIST == 'True'): require(DIR_WS_MODULES . "qtpro_stock_table.php"); endif; //++++ QT Pro: End Changed Code ?> A part of the code of original product_info as above should only be replace by below code for SPPC: // BOF SPPC Hide attributes from customer groups $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 "); $products_attributes = tep_db_fetch_array($products_attributes_query); if ($products_attributes['total'] > 0) { ?> <table border="0" cellspacing="0" cellpadding="2"> <tr> <td class="main" colspan="2"><?php echo TEXT_PRODUCT_OPTIONS; ?></td> </tr> <?php $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name"); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $products_options_array = array(); $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0"); $list_of_prdcts_attributes_id = ''; $products_options = array(); // makes sure this array is empty again while ($_products_options = tep_db_fetch_array($products_options_query)) { $products_options[] = $_products_options; $list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].","; } if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_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 = '" . $customer_group_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($products_options); $n++) { for ($i = 0; $i < count($cg_attr_prices) ; $i++) { if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) { $products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix']; $products_options[$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') for ($n = 0 ; $n < count($products_options); $n++) { $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']); if ($products_options[$n]['options_values_price'] != '0') { $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } } // EOF SPPC attributes mod As for now in my current product_info file I only have the QTpro code installed. I don't know how to insert the SPPC code. Please help me if you can. Thank you so much. Chantal Quote Link to comment Share on other sites More sharing options...
igan Posted August 13, 2008 Share Posted August 13, 2008 (edited) hi folks i have SPPC installed on my OSC RC1 using manual installation. Everything works just fine, until i test fake order and i'm using credit card as the payment method. However the checkout process successfully without any problem, but after i checked the admin panel to see the log transaction that have made the credit card and cc owner does not shown and cc owner and number does not stored in the database also :o . After i restore my back up file and find the problem from each type of PHP file, finally i found the problem in includes/classes/order.php that i have tweaks using SPPC manual installation. Because when i use includes/classes/order.php from the default file of RC1 and test fake transaction using credit card, the credit card shown in the admin panel log transaction. So is there anyhow i can still use the "includes/classes/order.php" but the credit card stored in the database and can be see in the admin panel or is it ok if i just use the "includes/classes/order.php" from the original RC1 ? Thank You very much Edited August 13, 2008 by igan Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted August 13, 2008 Share Posted August 13, 2008 i have SPPC installed on my OSC RC1 using manual installation. Everything works just fine, until i test fake order and i'm using credit card as the payment method. However the checkout process successfully without any problem, but after i checked the admin panel to see the log transaction that have made the credit card and cc owner does not shown and cc owner and number does not stored in the database also :o . After i restore my back up file and find the problem from each type of PHP file, finally i found the problem in includes/classes/order.php that i have tweaks using SPPC manual installation. Because when i use includes/classes/order.php from the default file of RC1 and test fake transaction using credit card, the credit card shown in the admin panel log transaction. So is there anyhow i can still use the "includes/classes/order.php" but the credit card stored in the database and can be see in the admin panel or is it ok if i just use the "includes/classes/order.php" from the original RC1 ? When I compare the two files (RC1 and RC2) I notice that in RC2 that kind of information is not stored anymore in the database (you are not supposed to store that information because of security reasons). So if you used the file from the latest version that would explain it but you are telling us you didn't do that. I have no explanation for that then because SPPC does not interfere with that part. Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted August 13, 2008 Share Posted August 13, 2008 I believe that the problem must be in product_info, because for QTpro and SPPC I have to change the same lines of the original text. Yes and so what? The buy now button on product_info.php is sending a form to the server that in it's GET parameters tells what product id the product has: <form name="cart_quantity" action="http://127.0.0.1/catalog/product_info.php?cPath=3_10&products_id=12&action=add_product" method="post"> And through the post variables for the attributes the server knows if and which attributes were ticked. But nothing is registered in the shopping_cart you say. You seem to use the same PHP code for the form so what could be wrong with that? Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted August 13, 2008 Share Posted August 13, 2008 I need your help please. Have installed this on a very modified store and everything on admin side seems good as does the catalog. When I go to checkout I get this error. Fatal error: Call to a member function on a non-object in /mnt/w0509/d22/s31/b029d318/www/DivasDen/catalog/includes/classes/shopping_cart.php on line 487 Here is my shopping_cart I would appreciate any help I am very new at php coding. And that is why we have to go try to find out what member function is the error at? And what line 487 is? From putting your code in between code tags I think that line 487 might be using $currencies->calculate_price which is a new function from RC1. This was warned for in the install instructions: IMPORTANT: If you have an older installation of osC and start adding files from this contribution be aware that some things have been changed. You might get an error about includes/classes/currencies.php missing the function calculate_price (this was added in RC1, see a download of RC2a, folder extras for the instructions on how to update) and the function tep_hide_session that has always been present and only used on the catalog side was also added to the admin side in catalog/admin/includes/functions/html_output.php (RC1 again). So check if that is the problem. Quote Link to comment Share on other sites More sharing options...
ChantalC Posted August 14, 2008 Share Posted August 14, 2008 Quote Link to comment Share on other sites More sharing options...
ChantalC Posted August 14, 2008 Share Posted August 14, 2008 (edited) Hi Jan, Sorry to inform you that I have removed all of SPPC. I just kept having errors. Maybe I will retry if a special SPPC with adjustments for QTpro is available. Thank you anyway for your help. Chantal Edited August 14, 2008 by ChantalC Quote Link to comment Share on other sites More sharing options...
Guest Posted August 17, 2008 Share Posted August 17, 2008 Is there a way to make a product only visible to wholesale customers? My problem is my client only wants to sell her product to wholesale customers by the case (25 products). Any ideas???? Thanks Brian Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted August 17, 2008 Share Posted August 17, 2008 (edited) Is there a way to make a product only visible to wholesale customers? My problem is my client only wants to sell her product to wholesale customers by the case (25 products). Any ideas???? Been available for a few years now: Hide products from customer groups for SPPC (recently updated for the latest version/RC2a.) Edited August 17, 2008 by Jan Zonjee Quote Link to comment Share on other sites More sharing options...
badcape Posted August 17, 2008 Share Posted August 17, 2008 Hi, i've installed SPPC 421a on my osCommerce 2.2-MS2 version(not a fresh one...many contribs already on) and every thing seems to run quite well except: i can't create more than one customers group (except retail that was already in) and in this new group i can't add or tranfer more than two customers ... i've tried many times, checked my (manual) installation but i can't find out where the problem is... does anyone had this problem before ? Thanks, Thierry. Quote Thanks to the whole osCommerce Community. Prod Server: Percona Server via UNIX socket Percona Server version: 5.5.40-36.1-log - Percona Server (GPL), Release 36.1, Revision 707 phpMyAdmin 3.5.8.2 Database version: libmysql - 5.0.96 PHP extension: mysqliversion Oscommerce-RC2A php 5.3 with many add-ons/up-dates ...... and liters of coffee !Local dev: EasyPHP DevServer 14.1 VC9 "Minakami" avec oscom 2.3.1 + Them switcher, Grid system et css 24 col 1280 px width, KissIT_image thumbnailer, lightbox, Invoice editor, Superfish horizontal navbar, Quick inventory, margin report, PWA (purshase without account), Products field groups, Products Extra fields Footer boxes... modified to my personnal needs.... Link to comment Share on other sites More sharing options...
Guest Posted August 17, 2008 Share Posted August 17, 2008 Been available for a few years now: Hide products from customer groups for SPPC (recently updated for the latest version/RC2a.) Thanks Jan Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted August 17, 2008 Share Posted August 17, 2008 i can't create more than one customers group (except retail that was already in) and in this new group i can't add or tranfer more than two customers ... i've tried many times, checked my (manual) installation but i can't find out where the problem is... A. This is a ridiculous error, nothing has been changed radically in SPPC for years and suddenly there are two people who claim this? Programming wise it doesn't make any sense. B. You are not giving any information on what the error messages are, in which files they are, on what line they are. We are not psychic here, especially with these kind of outlandish claims. Quote Link to comment Share on other sites More sharing options...
Guest Posted August 17, 2008 Share Posted August 17, 2008 Jan, I added the "Hide products (and categories) from customer groups for SPPC" v2.0.3 contribution and it is great. I am having a problem with hiding the categories and I think it is because I am using the contribution Category Box as Nested Unordered List for EZ(er) CSS & Dynamic menus v 1.00 So I don't think the file I moded in catalog/includes/boxes/categories.php is being called at all. I think it is calling catalog/includes/boxes/ul_categories.php instead. Below is the code for that (ul_categories.php) file. I couldn't figure out what changes I needed to make to make it work with the hide categories contribution. I am a newbie at PHP!!!! Any help would be greatly appreciated. <?php /* $Id: ul_categories.php,v 1.00 2006/04/30 01:13:58 nate_02631 Exp $ Outputs the store category list as a proper unordered list, opening up possibilities to use CSS to style as drop-down/flyout, collapsable or other menu types. osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2006 Nate Welch http://www.natewelch.com Released under the GNU General Public License */ // BEGIN Configuration options // Set to false to display the unordered list only. Set to true to display in // a regular box. The former is useful for better integrating the menu with your layout. $show_ulcats_as_box = true; // Indicates whether or not to render your entire category list or just the root categories // and the currently selected submenu tree. Rendering the full list is useful for dynamic menu // generation where you want the user to have instant access to all categories. The other option // is the default oSC behaviour, when the subcats aren't available until the parent is clicked. $show_full_tree = true; // This is the CSS *ID* you want to assign to the UL (unordered list) containing // your category menu. Used in conjuction with the CSS list you create for the menu. // This value cannot be blank. $idname_for_menu = 'nav'; // This is the *CLASSNAME* you want to tag a LI to indicate the selected category. // The currently selected category (and its parents, if any) will be tagged with // this class. Modify your stylesheet as appropriate. Leave blank or set to false to not assign a class. $classname_for_selected = 'selected'; // This is the *CLASSNAME* you want to tag a LI to indicate a category has subcategores. // Modify your stylesheet to draw an indicator to show the users that subcategories are // available. Leave blank or set to false to not assign a class. $classname_for_parent = 'daddy'; // This is the HTML that you would like to appear before your categories menu if *not* // displaying in a standard "box". This is useful for reconciling tables or clearing // floats, depending on your layout needs. $before_nobox_html = ''; // This is the HTML that you would like to appear after your categories menu if *not* // displaying in a standard "box". This is useful for reconciling tables or clearing // floats, depending on your layout needs. $after_nobox_html = '<div style="clear: both;">'; // END Configuration options // Global Variables $GLOBALS['this_level'] = 0; // Initialize HTML and info_box class if displaying inside a box if ($show_ulcats_as_box) { echo '<tr><td>'; $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES); new infoBoxHeading($info_box_contents, true, false); } // Generate a bulleted list (uses configuration options above) $categories_string = tep_make_cat_ullist(); // Output list inside a box if specified, otherwise just output unordered list if ($show_ulcats_as_box) { $info_box_contents = array(); $info_box_contents[] = array('text' => $categories_string); new infoBox($info_box_contents); echo '</td></tr>'; } else { echo $before_nobox_html; echo $categories_string; echo $after_nobox_html; } // Create the root unordered list function tep_make_cat_ullist($rootcatid = 0, $maxlevel = 0){ global $idname_for_menu, $cPath_array, $show_full_tree, $languages_id; // Modify category query if not fetching all categories (limit to root cats and selected subcat tree) if (!$show_full_tree) { $parent_query = 'AND (c.parent_id = "0"'; if (isset($cPath_array)) { $cPath_array_temp = $cPath_array; foreach($cPath_array_temp AS $key => $value) { $parent_query .= ' OR c.parent_id = "'.$value.'"'; } unset($cPath_array_temp); } $parent_query .= ')'; } else { $parent_query = ''; } $result = tep_db_query('select c.categories_id, cd.categories_name, c.parent_id from ' . TABLE_CATEGORIES . ' c, ' . TABLE_CATEGORIES_DESCRIPTION . ' cd where c.categories_id = cd.categories_id and cd.language_id="' . (int)$languages_id .'" '.$parent_query.' order by sort_order, cd.categories_name'); while ($row = tep_db_fetch_array($result)) { $table[$row['parent_id']][$row['categories_id']] = $row['categories_name']; } $output .= '<ul id="'.$idname_for_menu.'">'; $output .= tep_make_cat_ulbranch($rootcatid, $table, 0, $maxlevel); // Close off nested lists for ($nest = 0; $nest <= $GLOBALS['this_level']; $nest++) { $output .= '</ul>'; } return $output; } // Create the branches of the unordered list function tep_make_cat_ulbranch($parcat, $table, $level, $maxlevel) { global $cPath_array, $classname_for_selected, $classname_for_parent; $list = $table[$parcat]; while(list($key,$val) = each($list)){ if ($GLOBALS['this_level'] != $level) { if ($GLOBALS['this_level'] < $level) { $output .= "\n".'<ul>'; } else { for ($nest = 1; $nest <= ($GLOBALS['this_level'] - $level); $nest++) { $output .= '</ul></li>'."\n"; } /* if ($GLOBALS['this_level'] -1 == $level) $output .= '</ul></li>'."\n"; elseif ($GLOBALS['this_level'] -2 == $level) $output .= '</ul></li></ul></li>'."\n"; elseif ($GLOBALS['this_level'] -3 == $level) $output .= '</ul></li></ul></li></ul></li>'."\n"; elseif ($GLOBALS['this_level'] -4 == $level) $output .= '</ul></li></ul></li></ul></li></ul></li>'."\n"; */ } $GLOBALS['this_level'] = $level; } if (isset($cPath_array) && in_array($key, $cPath_array) && $classname_for_selected) { $this_cat_class = $classname_for_selected . ' '; } else { $this_cat_class = ''; } $output .= '<li class="'.$this_cat_class.'cat_lev_'.$level.'"><a class="link_lev_' .$level.'" href="'; if (!$level) { unset($GLOBALS['cPath_set']); $GLOBALS['cPath_set'][0] = $key; $cPath_new = 'cPath=' . $key; } else { $GLOBALS['cPath_set'][$level] = $key; $cPath_new = 'cPath=' . implode("_", array_slice($GLOBALS['cPath_set'], 0, ($level+1))); } if (tep_has_category_subcategories($key) && $classname_for_parent) { $this_parent_class = ' class="'.$classname_for_parent.'"'; } else { $this_parent_class = ''; } $output .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '"'.$this_parent_class.'>'.$val; if (SHOW_COUNTS == 'true') { $products_in_category = tep_count_products_in_category($key); if ($products_in_category > 0) { $output .= ' ' .'</a>'. '(' . $products_in_category . ')'; } } $output .= ''; if (!tep_has_category_subcategories($key)) { $output .= '</li>'."\n"; } if ((isset($table[$key])) AND (($maxlevel > $level + 1) OR ($maxlevel == '0'))) { $output .= tep_make_cat_ulbranch($key,$table,$level + 1,$maxlevel); } } // End while loop return $output; } ?> Quote Link to comment Share on other sites More sharing options...
yenhun Posted August 19, 2008 Share Posted August 19, 2008 Hi, successful install. Anybody can tell me where to find this function ? When I log in as admin in admin area, it doesn't have this select box. I tried to find it but seems cannot find where it located and which file associate with it. Please guide. Thanks. Quote Link to comment Share on other sites More sharing options...
SuperSewist Posted August 20, 2008 Share Posted August 20, 2008 yenhun, in mine it is in catalog/login.php, around line 89 (I have many mods so YMMV), starting with: // BOF Separate Pricing Per Customer: choice for logging in under any customer_group_id it is only on the customer side so you can test being a member of different groups. Not needed on the admin side. also my SPPC is from 2006 - just logged in to see what's new with the mod! Quote Toward Continued Success - - > Carol Hawkey - - > KidsLearnToSew.com - - > Wyoming, USA Mods Installed - - > Authnet AIM2 - Bundled Products 1.4 - Fancier Invoice 6.1 - Email_HTML_Order_Link_Fixed - Header Tags Controller - Login aLa Amazon - JustOneAttribute - Article Manager - SPPC w/PB - spiders.txt - Dangling Carrot/Olive - Printable Catalog - CCGV(trad) Planned Mods - - > Purchase Without Account - USPS Label - Ultimate SEO Link to comment Share on other sites More sharing options...
yenhun Posted August 20, 2008 Share Posted August 20, 2008 yenhun, in mine it is in catalog/login.php, around line 89 (I have many mods so YMMV), starting with:// BOF Separate Pricing Per Customer: choice for logging in under any customer_group_id it is only on the customer side so you can test being a member of different groups. Not needed on the admin side. also my SPPC is from 2006 - just logged in to see what's new with the mod! on customer side ? But I tried to log in as a customer on website but just a normal log in. Don't have such selection.. even though I have assign it as reseller.. sigh ~~~ Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted August 20, 2008 Share Posted August 20, 2008 on customer side ? But I tried to log in as a customer on website but just a normal log in. Don't have such selection.. even though I have assign it as reseller.. sigh ~~~ Read the documentation that comes with the download please: separate_price_422/documentation/index.htm -> What it does -> link: Administrator Log-On. goes to: separate_price_422/documentation/login.htm Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted August 20, 2008 Share Posted August 20, 2008 I am having a problem with hiding the categories and I think it is because I am using the contribution Category Box as Nested Unordered List for EZ(er) CSS & Dynamic menus v 1.00 So I don't think the file I moded in catalog/includes/boxes/categories.php is being called at all. I think it is calling catalog/includes/boxes/ul_categories.php instead. Below is the code for that (ul_categories.php) file. I couldn't figure out what changes I needed to make to make it work with the hide categories contribution. Looks like you only need to make some changes to the function tep_make_cat_ullist like: function tep_make_cat_ullist($rootcatid = 0, $maxlevel = 0){ global $idname_for_menu, $cPath_array, $show_full_tree, $languages_id; // BOF Separate Pricing Per Customer if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') { $customer_group_id = $_SESSION['sppc_customer_group_id']; } else { $customer_group_id = '0'; } // EOF Separate Pricing Per Customer // Modify category query if not fetching all categories (limit to root cats and selected subcat tree) if (!$show_full_tree) { $parent_query = 'AND (c.parent_id = "0"'; if (isset($cPath_array)) { $cPath_array_temp = $cPath_array; foreach($cPath_array_temp AS $key => $value) { $parent_query .= ' OR c.parent_id = "'.$value.'"'; } unset($cPath_array_temp); } $parent_query .= ')'; } else { $parent_query = ''; } $result = tep_db_query('select c.categories_id, cd.categories_name, c.parent_id from ' . TABLE_CATEGORIES . ' c, ' . TABLE_CATEGORIES_DESCRIPTION . ' cd where c.categories_id = cd.categories_id and cd.language_id="' . (int)$languages_id .'" '.$parent_query.' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name'); Quote Link to comment Share on other sites More sharing options...
Guest Posted August 21, 2008 Share Posted August 21, 2008 Looks like you only need to make some changes to the function tep_make_cat_ullist like: Thanks Jan, that worked.... well actually there was an error but believe it or not I managed to figure it out. It was in the last line, there were 2 " that weren't supposed to be there. I will post it below for future reference for anyone using UL_categories and SPPC. Thanks again Jan Full code function tep_make_cat_ullist($rootcatid = 0, $maxlevel = 0){ global $idname_for_menu, $cPath_array, $show_full_tree, $languages_id; // BOF Separate Pricing Per Customer if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') { $customer_group_id = $_SESSION['sppc_customer_group_id']; } else { $customer_group_id = '0'; } // EOF Separate Pricing Per Customer // Modify category query if not fetching all categories (limit to root cats and selected subcat tree) if (!$show_full_tree) { $parent_query = 'AND (c.parent_id = "0"'; if (isset($cPath_array)) { $cPath_array_temp = $cPath_array; foreach($cPath_array_temp AS $key => $value) { $parent_query .= ' OR c.parent_id = "'.$value.'"'; } unset($cPath_array_temp); } $parent_query .= ')'; } else { $parent_query = ''; } $result = tep_db_query('select c.categories_id, cd.categories_name, c.parent_id from ' . TABLE_CATEGORIES . ' c, ' . TABLE_CATEGORIES_DESCRIPTION . ' cd where c.categories_id = cd.categories_id and cd.language_id="' . (int)$languages_id .'" '.$parent_query.' and find_in_set(' . $customer_group_id . ', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name'); Quote Link to comment Share on other sites More sharing options...
Magma-tech Posted August 21, 2008 Share Posted August 21, 2008 I am getting this error code, I have searched the forums and can't find any fix... Parse error: parse error, unexpected T_ELSE in /admin/customers.php on line 1337 Any help would be greatly appreciated. Thanks Rick P.S. I didn't want to post the whole customer.php until someone asked me to. Let me know what to do..... Quote Link to comment Share on other sites More sharing options...
Magma-tech Posted August 21, 2008 Share Posted August 21, 2008 (edited) Edited August 21, 2008 by Magma-tech Quote Link to comment Share on other sites More sharing options...
Magma-tech Posted August 22, 2008 Share Posted August 22, 2008 I will post it here..... I am not sure if I did something wrong in the code or not.... Rick ?php /* $Id: customers.php,v 1.82 2003/06/30 13:54:14 dgw_ Exp $ adapted for Separate Pricing Per Customer v4.2.1 2008/03/09 (exempt specific tax rates added in v4.2.0, order total modules allowed in v4.2.1) customer_sort_admin_v1 http://www.oscommerce.com/community/contributions,223 added (modified) osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com ________________________________________________________________________________ ______________________ I found the problem... I did not cut all of the code out in one section. Deleted the code and tht solved this problem. Thanks Rick Quote Link to comment Share on other sites More sharing options...
Magma-tech Posted August 22, 2008 Share Posted August 22, 2008 Quote Link to comment Share on other sites More sharing options...
Magma-tech Posted August 23, 2008 Share Posted August 23, 2008 Thanks All..... I just got frustrated enough that I just went ahead and removed the "separate pricing" mod. Things are back to normal... Might retry it again later. I think that it is having some problems or conflicts with the Washington State Tax mod. It's more important to have the tax mod working, as I have to charge tax based on the delivery address by each street location, and then report the collected tax by each delivery address. We have insane people here in Washington State Gov't. 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.