Jump to content
scendent

Seperate Pricing Per Customer v3.5

Recommended Posts

Did you look at the product_listing.php of QPBPB for SPPC? That is quite a bit of code that need to be added to master_listing.php to have that information available. I wonder if you added all that code...

 

Perhaps you can save yourself some work by making use of PriceFormatterStore.php. The class function PriceFormatterStore.php takes the list of product_id's in the cart to do basically the same work as need to be added to master_listing.php. If you copy that function, paste it again, rename it and change it to accept a variable (which would be an array with all the product_id's that are in the listing: something like function MasterListingStore($productid_array) and then first check if that pricebreak already has been stored (look at function getPriceBreak($product_id) how that is done) before you do the $this->addPriceBreakData($product_info[$x]['products_id'], $product_info[$x]); you can call PriceFormatter with $pf->loadProduct($product_id) and subsequently call the functions of PriceFormatter.

 

You could add your own as described above by you.

 

Ok - figured out how to make it work by entering the if statement and the table inside of the case: MASTER_LIST_BUY_NOW

 

Now I have one thing left - I'd like to show the price without the extra 0's. Right now if I echo $listing[$x]['products_price1'] I get $28.9800 and I just want it to be $28.98 USD (the same way the other prices show). Any ideas on how to do that? The USD is set through the Admin but doesn't seem to attach to the Price Breaks products_price1.

 

Thanks again!


~Tracy
 

Share this post


Link to post
Share on other sites

(I posted this in wrong spot earlier, sorry)

Hello there! Getting ready to have SPPC installed for its retail/ wholesale benefits. I am now realizing that I can enter all the pretty colors of one product that I want into OSC- but each color won't have it's own inventory without some additional configgin'. Can anyone point me in the right direction of a modification that works with SPPC? (& which to install first)

Thanks!!! - Lisa

Share this post


Link to post
Share on other sites
(I posted this in wrong spot earlier, sorry)

Hello there! Getting ready to have SPPC installed for its retail/ wholesale benefits. I am now realizing that I can enter all the pretty colors of one product that I want into OSC- but each color won't have it's own inventory without some additional configgin'. Can anyone point me in the right direction of a modification that works with SPPC? (& which to install first)

Thanks!!! - Lisa

 

You might try Master Products (contrib. # 1681) - it does work with SPPC but you do have to make a few tweaks.

 

Other than that, maybe somebody else has a thought on Inventory of Options ?


~Tracy
 

Share this post


Link to post
Share on other sites
Now I have one thing left - I'd like to show the price without the extra 0's. Right now if I echo $listing[$x]['products_price1'] I get $28.9800 and I just want it to be $28.98 USD (the same way the other prices show). Any ideas on how to do that? The USD is set through the Admin but doesn't seem to attach to the Price Breaks products_price1.

You seem to be echo'ing the "raw" products_price1. How about using:

echo $currencies->display_price($listing[$x]['products_price1'], tep_get_tax_rate($listing[$x]['products_tax_class_id']));

Share this post


Link to post
Share on other sites
You seem to be echo'ing the "raw" products_price1. How about using:

echo $currencies->display_price($listing[$x]['products_price1'], tep_get_tax_rate($listing[$x]['products_tax_class_id']));

 

Thanks Jan!! Worked like a charm!! :thumbsup:


~Tracy
 

Share this post


Link to post
Share on other sites

Guys

 

I have looked through this thread and i have been unable to find the solution

 

Like a few others here I have this error

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in W:\www\business\includes\functions\database.php on line 104

 

Has there been a solution to this?

 

If I turn the box off that I think causes this it goes away but then appears on product_info.php and on most other pages as well

 

Any help appreciated

 

Thanks

Share this post


Link to post
Share on other sites
I have looked through this thread and i have been unable to find the solution

That is right because it is caused by incorrectly adding the SPPC code. Somewhere there is a check on the numbers of row a query has returned but you messed up, so there was no query done. Therefore the "command" to return the number of rows is invalid.

Hard to say where you went wrong.

Share this post


Link to post
Share on other sites
That is right because it is caused by incorrectly adding the SPPC code. Somewhere there is a check on the numbers of row a query has returned but you messed up, so there was no query done. Therefore the "command" to return the number of rows is invalid.

Hard to say where you went wrong.

 

Do you have any idea what file it may have been added wrong?

 

I have checked and even used the contribution supplied product_listing.php file to no avail

 

Thanks

Share this post


Link to post
Share on other sites
Do you have any idea what file it may have been added wrong?

I don't have psychic powers but searching the new_install_directions.txt for the string tep_db_num_rows turns up that the particular functions is used in (at least) the following files changed for SPPC:

 

catalog\includes\modules\new_products.php

catalog\includes\modules\product_listing.php

catalog\products_new.php

catalog\specials.php

 

Where exactly in the source code of the page this error is echo'ed also often gives a clue in what particular module of box the error is.... Compare that to the php of the page and you often know what is called on that spot judging on where the HTML ends and the error starts.

Share this post


Link to post
Share on other sites

OK I ahve gone over it with a fine tooth comb and got rid of those errors - I now have this error

 

Parse error: parse error, unexpected T_IF, expecting ')' in W:\www\entloaded\includes\classes\order.php on line 115

 

The file is...(Line 115 is in red)

 

<?php

/*

$Id: order.php,v 1.33 2003/06/09 22:25:35 hpdl Exp $

 

Modified for MVS V1.0 2006/03/25 JCK/CWG

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2006 osCommerce

 

Released under the GNU General Public License

*/

 

class order {

var $info, $totals, $products, $customer, $delivery, $content_type;

 

function order($order_id = '') {

$this->info = array();

$this->totals = array();

$this->products = array();

$this->customer = array();

$this->delivery = array();

 

if (tep_not_null($order_id)) {

$this->query($order_id);

} else {

$this->cart();

}

}

 

function query($order_id) {

global $languages_id;

 

$order_id = tep_db_prepare_input($order_id);

 

$order_query = tep_db_query("select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");

$order = tep_db_fetch_array($order_query);

 

$totals_query = tep_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order");

while ($totals = tep_db_fetch_array($totals_query)) {

$this->totals[] = array('title' => $totals['title'],

'text' => $totals['text']);

}

 

$order_total_query = tep_db_query("select text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_total'");

$order_total = tep_db_fetch_array($order_total_query);

 

$shipping_method_query = tep_db_query("select title from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_shipping'");

$shipping_method = tep_db_fetch_array($shipping_method_query);

 

$order_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . $order['orders_status'] . "' and language_id = '" . (int)$languages_id . "'");

$order_status = tep_db_fetch_array($order_status_query);

 

$this->info = array('currency' => $order['currency'],

'currency_value' => $order['currency_value'],

'payment_method' => $order['payment_method'],

'cc_type' => $order['cc_type'],

'cc_owner' => $order['cc_owner'],

'cc_number' => $order['cc_number'],

'cc_expires' => $order['cc_expires'],

'date_purchased' => $order['date_purchased'],

'orders_status' => $order_status['orders_status_name'],

'last_modified' => $order['last_modified'],

'total' => strip_tags($order_total['text']),

'shipping_method' => ((substr($shipping_method['title'], -1) == ':') ? substr(strip_tags($shipping_method['title']), 0, -1) : strip_tags($shipping_method['title'])));

 

$this->customer = array('id' => $order['customers_id'],

'name' => $order['customers_name'],

'company' => $order['customers_company'],

'street_address' => $order['customers_street_address'],

'suburb' => $order['customers_suburb'],

'city' => $order['customers_city'],

'postcode' => $order['customers_postcode'],

'state' => $order['customers_state'],

'country' => $order['customers_country'],

'format_id' => $order['customers_address_format_id'],

'telephone' => $order['customers_telephone'],

'email_address' => $order['customers_email_address']);

 

$this->delivery = array('name' => $order['delivery_name'],

'company' => $order['delivery_company'],

'street_address' => $order['delivery_street_address'],

'suburb' => $order['delivery_suburb'],

'city' => $order['delivery_city'],

'postcode' => $order['delivery_postcode'],

'state' => $order['delivery_state'],

'country' => $order['delivery_country'],

'format_id' => $order['delivery_address_format_id']);

 

if (empty($this->delivery['name']) && empty($this->delivery['street_address'])) {

$this->delivery = false;

}

 

$this->billing = array('name' => $order['billing_name'],

'company' => $order['billing_company'],

'street_address' => $order['billing_street_address'],

'suburb' => $order['billing_suburb'],

'city' => $order['billing_city'],

'postcode' => $order['billing_postcode'],

'state' => $order['billing_state'],

'country' => $order['billing_country'],

'format_id' => $order['billing_address_format_id']);

 

$index = 0;

$orders_products_query = tep_db_query("select orders_products_id, products_id, products_name, products_model, products_price, products_returned, products_exchanged, products_exchanged_id, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");

while ($orders_products = tep_db_fetch_array($orders_products_query)) {

$this->products[$index] = array('qty' => $orders_products['products_quantity'],

'id' => $orders_products['products_id'],

'name' => $orders_products['products_name'],

'model' => $orders_products['products_model'],

'tax' => $orders_products['products_tax'],

'price' => $orders_products['products_price'],

'final_price' => $orders_products['final_price'],

// BOF Separate Pricing Per Customer

if(!tep_session_is_registered('sppc_customer_group_id')) {

$customer_group_id = '0';

} else {

$customer_group_id = $sppc_customer_group_id;

}

 

if ($customer_group_id != '0'){

$orders_customers_price = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '". $customer_group_id . "' and products_id = '" . $products[$i]['id'] . "'");

if ($orders_customers = tep_db_fetch_array($orders_customers_price)){

$this->products[$index] = array('price' => $orders_customers['customers_group_price'], 'final_price' => $orders_customers['customers_group_price']);

}

}

// EOF Separate Pricing Per Customer

'id' => $orders_products['products_id'],

'return' => $orders_products['products_returned'],

'exchange' => $orders_products['products_exchanged'],

'exchange_id' => $orders_products['products_exchanged_id'],);

 

$subindex = 0;

$attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");

if (tep_db_num_rows($attributes_query)) {

while ($attributes = tep_db_fetch_array($attributes_query)) {

$this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'],

'value' => $attributes['products_options_values'],

'prefix' => $attributes['price_prefix'],

'price' => $attributes['options_values_price']);

 

$subindex++;

}

}

 

$this->info['tax_groups']["{$this->products[$index]['tax']}"] = '1';

 

$index++;

}

}

 

function cart() {

global $customer_id, $sendto, $billto, $cart, $languages_id, $currency, $currencies, $shipping, $payment;

 

$this->content_type = $cart->get_content_type();

 

// PWA BOF

if ($customer_id == 0) {

global $pwa_array_customer, $pwa_array_address, $pwa_array_shipping;

 

// customers address

$country_query = tep_db_query("select c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, z.zone_name from " . TABLE_COUNTRIES . " c left join " . TABLE_ZONES . " z on z.zone_id = '" . intval($pwa_array_address['entry_zone_id']) . "' where countries_id = '" . intval($pwa_array_address['entry_country_id']) . "'");

$country = tep_db_fetch_array($country_query);

$address = array_merge($country,

array('customers_firstname' => $pwa_array_customer['customers_firstname'],

'customers_lastname' => $pwa_array_customer['customers_lastname'],

'entry_firstname' => $pwa_array_customer['customers_firstname'],

'entry_lastname' => $pwa_array_customer['customers_lastname'],

'customers_telephone' => $pwa_array_customer['customers_telephone'],

'customers_email_address' => $pwa_array_customer['customers_email_address'],

'entry_company' => (isset($pwa_array_address['entry_company'])? $pwa_array_address['entry_company']:''),

'entry_street_address' => $pwa_array_address['entry_street_address'],

'entry_suburb' => $pwa_array_address['entry_suburb'],

'entry_postcode' => $pwa_array_address['entry_postcode'],

'entry_city' => $pwa_array_address['entry_city'],

'entry_zone_id' => $pwa_array_address['entry_zone_id'],

'countries_id' => $pwa_array_address['entry_country_id'],

'entry_country_id' => $pwa_array_address['entry_country_id'],

'entry_state' => $pwa_array_address['entry_state']));

 

$customer_address = $billing_address = $address;

 

if (isset($pwa_array_shipping) && is_array($pwa_array_shipping) && count($pwa_array_shipping)) {

// separately shipping address

$country_query = tep_db_query("select c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, z.zone_name from " . TABLE_COUNTRIES . " c left join " . TABLE_ZONES . " z on z.zone_id = '" . intval($pwa_array_shipping['entry_zone_id']) . "' where countries_id = '" . intval($pwa_array_shipping['entry_country_id']) . "'");

$country = tep_db_fetch_array($country_query);

$shipping_address = array_merge($country,

array('customers_firstname' => $pwa_array_shipping['entry_firstname'],

'customers_lastname' => $pwa_array_shipping['entry_lastname'],

'entry_firstname' => $pwa_array_shipping['entry_firstname'],

'entry_lastname' => $pwa_array_shipping['entry_lastname'],

'customers_telephone' => $pwa_array_customer['customers_telephone'],

'customers_email_address' => $pwa_array_customer['customers_email_address'],

'entry_company' => (isset($pwa_array_shipping['entry_company'])? $pwa_array_shipping['entry_company']:''),

'entry_street_address' => $pwa_array_shipping['entry_street_address'],

'entry_suburb' => $pwa_array_shipping['entry_suburb'],

'entry_postcode' => $pwa_array_shipping['entry_postcode'],

'entry_city' => $pwa_array_shipping['entry_city'],

'entry_zone_id' => $pwa_array_shipping['entry_zone_id'],

'countries_id' => $pwa_array_shipping['entry_country_id'],

'entry_country_id' => $pwa_array_shipping['entry_country_id'],

'entry_state' => $pwa_array_shipping['entry_state']));

 

} else {

// non separately shipping address

$shipping_address = $address;

}

$tax_address = array('entry_country_id' => $pwa_array_address['entry_country_id'], 'entry_zone_id' => $pwa_array_address['entry_zone_id']);

// address label #0

$this->pwa_label_customer =

array('firstname' => $customer_address['customers_firstname'],

'lastname' => $customer_address['customers_lastname'],

'company' => $customer_address['entry_company'],

'street_address' => $customer_address['entry_street_address'],

'suburb' => $customer_address['entry_suburb'],

'city' => $customer_address['entry_city'],

'postcode' => $customer_address['entry_postcode'],

'state' => $customer_address['entry_state'],

'zone_id' => $customer_address['entry_zone_id'],

'country_id' => $customer_address['entry_country_id']);

// address label #1

$this->pwa_label_shipping =

array('firstname' => $shipping_address['customers_firstname'],

'lastname' => $shipping_address['customers_lastname'],

'company' => $shipping_address['entry_company'],

'street_address' => $shipping_address['entry_street_address'],

'suburb' => $shipping_address['entry_suburb'],

'city' => $shipping_address['entry_city'],

'postcode' => $shipping_address['entry_postcode'],

'state' => $shipping_address['entry_state'],

'zone_id' => $shipping_address['entry_zone_id'],

'country_id' => $shipping_address['entry_country_id']);

} else {

// PWA EOF

 

$customer_address_query = tep_db_query("select c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id) where c.customers_id = '" . (int)$customer_id . "' and ab.customers_id = '" . (int)$customer_id . "' and c.customers_default_address_id = ab.address_book_id");

$customer_address = tep_db_fetch_array($customer_address_query);

 

$shipping_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$sendto . "'");

$shipping_address = tep_db_fetch_array($shipping_address_query);

 

$billing_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$billto . "'");

$billing_address = tep_db_fetch_array($billing_address_query);

 

$tax_address_query = tep_db_query("select ab.entry_country_id, ab.entry_zone_id from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)($this->content_type == 'virtual' ? $billto : $sendto) . "'");

$tax_address = tep_db_fetch_array($tax_address_query);

// PWA BOF

}

// PWA EOF

 

$this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID,

'currency' => $currency,

'currency_value' => $currencies->currencies[$currency]['value'],

'payment_method' => $payment,

'cc_type' => (isset($GLOBALS['cc_type']) ? $GLOBALS['cc_type'] : ''),

'cc_owner' => (isset($GLOBALS['cc_owner']) ? $GLOBALS['cc_owner'] : ''),

'cc_number' => (isset($GLOBALS['cc_number']) ? $GLOBALS['cc_number'] : ''),

'cc_expires' => (isset($GLOBALS['cc_expires']) ? $GLOBALS['cc_expires'] : ''),

'shipping_method' => $shipping['title'],

'shipping_cost' => $shipping['cost'],

//MVS Start

'shipping_tax' => $shipping['shipping_tax_total'],

'subtotal' => 0,

'tax' => 0 + $shipping['shipping_tax_total'],

//MVS End

'tax_groups' => array(),

'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : ''));

 

if (isset($GLOBALS[$payment]) && is_object($GLOBALS[$payment])) {

$this->info['payment_method'] = $GLOBALS[$payment]->title;

 

if ( isset($GLOBALS[$payment]->order_status) && is_numeric($GLOBALS[$payment]->order_status) && ($GLOBALS[$payment]->order_status > 0) ) {

$this->info['order_status'] = $GLOBALS[$payment]->order_status;

}

}

 

$this->customer = array('firstname' => $customer_address['customers_firstname'],

'lastname' => $customer_address['customers_lastname'],

'company' => $customer_address['entry_company'],

'street_address' => $customer_address['entry_street_address'],

'suburb' => $customer_address['entry_suburb'],

'city' => $customer_address['entry_city'],

'postcode' => $customer_address['entry_postcode'],

'state' => ((tep_not_null($customer_address['entry_state'])) ? $customer_address['entry_state'] : $customer_address['zone_name']),

'zone_id' => $customer_address['entry_zone_id'],

'country' => array('id' => $customer_address['countries_id'], 'title' => $customer_address['countries_name'], 'iso_code_2' => $customer_address['countries_iso_code_2'], 'iso_code_3' => $customer_address['countries_iso_code_3']),

'format_id' => $customer_address['address_format_id'],

'telephone' => $customer_address['customers_telephone'],

'email_address' => $customer_address['customers_email_address']);

 

$this->delivery = array('firstname' => $shipping_address['entry_firstname'],

'lastname' => $shipping_address['entry_lastname'],

'company' => $shipping_address['entry_company'],

'street_address' => $shipping_address['entry_street_address'],

'suburb' => $shipping_address['entry_suburb'],

'city' => $shipping_address['entry_city'],

'postcode' => $shipping_address['entry_postcode'],

'state' => ((tep_not_null($shipping_address['entry_state'])) ? $shipping_address['entry_state'] : $shipping_address['zone_name']),

'zone_id' => $shipping_address['entry_zone_id'],

'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']),

'country_id' => $shipping_address['entry_country_id'],

'format_id' => $shipping_address['address_format_id']);

 

$this->billing = array('firstname' => $billing_address['entry_firstname'],

'lastname' => $billing_address['entry_lastname'],

'company' => $billing_address['entry_company'],

'street_address' => $billing_address['entry_street_address'],

'suburb' => $billing_address['entry_suburb'],

'city' => $billing_address['entry_city'],

'postcode' => $billing_address['entry_postcode'],

'state' => ((tep_not_null($billing_address['entry_state'])) ? $billing_address['entry_state'] : $billing_address['zone_name']),

'zone_id' => $billing_address['entry_zone_id'],

'country' => array('id' => $billing_address['countries_id'], 'title' => $billing_address['countries_name'], 'iso_code_2' => $billing_address['countries_iso_code_2'], 'iso_code_3' => $billing_address['countries_iso_code_3']),

'country_id' => $billing_address['entry_country_id'],

'format_id' => $billing_address['address_format_id']);

//MVS start

$orders_shipping_id = '';

$check_new_vendor_data_query = tep_db_query("select orders_shipping_id, orders_id, vendors_id, vendors_name, shipping_module, shipping_method, shipping_cost from " . TABLE_ORDERS_SHIPPING . " where orders_id = '" . (int)$order_id . "'");

while ($checked_data = tep_db_fetch_array($check_new_vendor_data_query)) {

$this->orders_shipping_id = $checked_data['orders_shipping_id'];

} //MVS End

$index = 0;

$products = $cart->get_products();

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

$this->products[$index] = array('qty' => $products[$i]['quantity'],

'name' => $products[$i]['name'],

'model' => $products[$i]['model'],

'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']),

'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']),

'price' => $products[$i]['price'],

'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),

//MVS start

'vendors_id' => $products[$i]['vendors_id'],

'vendors_name' => $products[$i]['vendors_name'],

//MVS end

'weight' => $products[$i]['weight'],

'id' => $products[$i]['id']);

// BOF Separate Pricing Per Customer

if(!tep_session_is_registered('sppc_customer_group_id')) {

$customer_group_id = '0';

} else {

$customer_group_id = $sppc_customer_group_id;

}

if ($customer_group_id != '0'){

$orders_customers_price = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '". $customer_group_id . "' and products_id = '" . $products[$i]['id'] . "'");

$orders_customers = tep_db_fetch_array($orders_customers_price);

if ($orders_customers = tep_db_fetch_array($orders_customers_price)) {

$this->products[$index] = array('price' => $orders_customers['customers_group_price'],

'final_price' => $orders_customers['customers_group_price'] + $cart->attributes_price($products[$i]['id']));

}

}

// EOF Separate Pricing Per Customer

 

if ($products[$i]['attributes']) {

$subindex = 0;

reset($products[$i]['attributes']);

while (list($option, $value) = each($products[$i]['attributes'])) {

$attributes_query = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'");

$attributes = tep_db_fetch_array($attributes_query);

 

$this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'],

'value' => $attributes['products_options_values_name'],

'option_id' => $option,

'value_id' => $value,

'prefix' => $attributes['price_prefix'],

'price' => $attributes['options_values_price']);

 

$subindex++;

}

}

 

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

 

$products_tax = $this->products[$index]['tax'];

$products_tax_description = $this->products[$index]['tax_description'];

// BOF Separate Pricing Per Customer, show_tax modification

// next line was original code

// if (DISPLAY_PRICE_WITH_TAX == 'true') {

global $sppc_customer_group_show_tax;

if(!tep_session_is_registered('sppc_customer_group_show_tax')) {

$customer_group_show_tax = '1';

} else {

$customer_group_show_tax = $sppc_customer_group_show_tax;

}

if (DISPLAY_PRICE_WITH_TAX == 'true' && $customer_group_show_tax == '1') {

// EOF Separate Pricing Per Customer, show_tax modification

$this->info['tax'] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));

if (isset($this->info['tax_groups']["$products_tax_description"])) {

$this->info['tax_groups']["$products_tax_description"] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));

} else {

$this->info['tax_groups']["$products_tax_description"] = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));

}

} else {

$this->info['tax'] += ($products_tax / 100) * $shown_price;

if (isset($this->info['tax_groups']["$products_tax_description"])) {

$this->info['tax_groups']["$products_tax_description"] += ($products_tax / 100) * $shown_price;

} else {

//MVS Start add shipping tax

$this->info['tax_groups']["$products_tax_description"] = ($products_tax / 100) * $shown_price + $shipping['shipping_tax_total'];

//MVS end

}

}

 

$index++;

}

 

// BOF Separate Pricing Per Customer, show_tax modification

// next line was original code

// if (DISPLAY_PRICE_WITH_TAX == 'true') {

global $sppc_customer_group_show_tax;

if(!tep_session_is_registered('sppc_customer_group_show_tax')) {

$customer_group_show_tax = '1';

} else {

$customer_group_show_tax = $sppc_customer_group_show_tax;

}

if ((DISPLAY_PRICE_WITH_TAX == 'true') && ($customer_group_show_tax == '1')) {

// EOF Separate Pricing Per Customer, show_tax modification

$this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'];

} else {

$this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost'];

}

}

}

?>

 

Thanks

Share this post


Link to post
Share on other sites

OK I have resolved it

 

Changed this

 

'final_price' => $orders_products['final_price'],
// BOF Separate Pricing Per Customer
 if(!tep_session_is_registered('sppc_customer_group_id')) {
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }

  if ($customer_group_id != '0'){
  $orders_customers_price = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '". $customer_group_id . "' and products_id = '" . $products[$i]['id'] . "'");
  if ($orders_customers = tep_db_fetch_array($orders_customers_price)){
  $this->products[$index] = array('price' => $orders_customers['customers_group_price'], 'final_price' => $orders_customers['customers_group_price']);
 }
}
// EOF Separate Pricing Per Customer
									'id' => $orders_products['products_id'],
									'return' => $orders_products['products_returned'],
									'exchange' => $orders_products['products_exchanged'],
									'exchange_id' => $orders_products['products_exchanged_id'],);

 

To this

 

 'final_price' => $orders_products['final_price'],
									'id' => $orders_products['products_id'],
									'return' => $orders_products['products_returned'],
									'exchange' => $orders_products['products_exchanged'],
									'exchange_id' => $orders_products['products_exchanged_id'],);
									// BOF Separate Pricing Per Customer
 if(!tep_session_is_registered('sppc_customer_group_id')) {
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }

  if ($customer_group_id != '0'){
  $orders_customers_price = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '". $customer_group_id . "' and products_id = '" . $products[$i]['id'] . "'");
  if ($orders_customers = tep_db_fetch_array($orders_customers_price)){
  $this->products[$index] = array('price' => $orders_customers['customers_group_price'], 'final_price' => $orders_customers['customers_group_price']);
 }
}
// EOF Separate Pricing Per Customer

 

That will teach me to code when I have had a few glasses of wine - Left it and went back to it this morning and saw the error

 

Thanks if you tried to help

 

:)

Share this post


Link to post
Share on other sites

Well I figured out that I was also missing a $x in specials.php (line 109). Now all the specials are showing and linking up fine.

 

The very last little problem I'm having is that the price will not show up in specials.php, here's the code

 

<?php
/*
 $Id: specials.php,v 1.49 2003/06/09 22:35:33 hpdl Exp $
 adapted for Separate Pricing Per Customer v3.6 2005/03/08

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SPECIALS);

 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SPECIALS));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->

<script language="javascript"><!--
function popupWindow(url) {
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res
izable=yes,copyhistory=no,width=290,height=290,screenX=290,screenY=290,top=150,le
ft=150');
}
//--></script>

<!--  Start code -->
 <tr><td valign="top">
   <table border="0" cellspacing="0" cellpadding="0"> 
	<tr><td width="184" valign="top"><?php require(DIR_WS_INCLUDES . 'column_left.php'); ?></td>
		<td width="6"></td>
		<td width="561" valign="top">
		 <table border="0" cellspacing="0" cellpadding="0">
			  <tr><td><?=tep_image(DIR_WS_IMAGES.'m21.gif')?></td><td width="551" bgcolor="#FFFFFF"></td><td><?=tep_image(DIR_WS_IMAGES.'m22.gif')?></td></tr>
			  <tr><td width="561" height="100" bgcolor="#FFFFFF" colspan="3">

					<? new infoBoxHeading1($info_box_contents, true, false);?>


<!-- body //-->

<?php
 // BOF Separate Price Per Customer
//  global variable (session): $sppc_customers_group_id -> local variable $customer_group_id

 if(!tep_session_is_registered('sppc_customer_group_id')) {
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }

/*   $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added DESC"; */

 $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' and s.customers_group_id = ". (int)$customer_group_id." order by s.specials_date_added DESC";
 $specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);
// EOF Separate Price Per Customer
 $specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);
 if (($specials_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0" class="sea_22">
 <tr>
<td class="smallText"><?php echo $specials_split->display_count(TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?></td>
<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $specials_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php } ?>
			   <table border="0" cellspacing="0" cellpadding="0" width="545" align="center">
<?php
$row=0;
$col=0;
$specials_query = tep_db_query($specials_split->sql_query);
	$no_of_specials = tep_db_num_rows($specials_query);
// get all product prices from the table products_groups in one query
// traverse specials_query for products_id's, store the query result in a numbered array
  while ($_specials = tep_db_fetch_array($specials_query)) {
$specials[] = $_specials;
$list_of_prdct_ids[] = $_specials['products_id'];
  } // end while ($_specials = tep_db_fetch_array($specials_query))
// a line needed for the selection of the products_id's
 $pg_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_specials > 1) {
  for ($n = 1; $n < count($list_of_prdct_ids); $n++) {
  $pg_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";
  }
}
// now get all the customers_group_price's
$pg_query = tep_db_query("select products_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where (".$pg_list_of_prdct_ids.") and customers_group_id =  '" . $customer_group_id . "'");
// put all the info in an array called new_prices
while ($pg_array = tep_db_fetch_array($pg_query)) {
$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['customers_group_price']);
}
// we already got the results from the query and put them into an array, can't use while now
//	while ($specials = tep_db_fetch_array($specials_query)) {
for ($x = 0; $x < $no_of_specials; $x++) {
	$products_new=$specials[$x];


$product_query=tep_db_query("select products_description  from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_new['products_id'] . "' and language_id = '" . (int)$languages_id . "'");
$product = tep_db_fetch_array($product_query);
$pn = $product['products_description'];

if (($col==0) && ($row!=0)) echo '
						  <tr><td colspan="3">'.tep_image(DIR_WS_IMAGES.'m31.gif').'</td></tr>';

if ($col==0) echo '

						  <tr><td width="272" valign="top">';
?>
					 <table border="0" cellspacing="0" cellpadding="0" width="242" align="center">
					  <tr><td height="5" colspan="3"></td></tr>
					  <tr><td><?=tep_image(DIR_WS_IMAGES.'m38.gif')?></td>
						  <td width="242" height="31" bgcolor="#ECEEF0">     <a class="ml1" href="<?=tep_href_link('product_info.php?products_id='.$products_new['products_id'])?>"><?=$products_new['products_name']?></a></td>
						  <td><?=tep_image(DIR_WS_IMAGES.'m39.gif')?></td></tr>
					  <tr><td height="5" colspan="3"></td></tr>
					  <tr><td width="242" height="1" class="bg" colspan="3"></td></tr>						  
					  <tr><td height="7" colspan="3"></td></tr>
					 </table>
					 <table border="0" cellspacing="0" cellpadding="0" width="242" align="center">
					  <tr><td width="8"></td>							  
						  <td width="154"><span class="tx3"><?=$currencies->display_price($specials['specials_new_products_price'],'')?></span> <s><?=$currencies->display_price($specials['products_price'],'')?></s><br style="line-height:1px;"><br style="line-height:8px;"><a href="<?=tep_href_link('product_info.php?products_id='.$products_new['products_id'])?>"><?=tep_image_button("button_details.gif");?></a><br style="line-height:1px;"><br style="line-height:4px;"><a href="<?= tep_href_link("products_new.php","action=buy_now&products_id=".$products_new['products_id'])?>"><?=tep_image_button("button_add_to_cart1.gif");?></a></td>
						  <td width="80" class="bd" align="center" valign="top"><a href="<?=tep_href_link('product_info.php?products_id='.$products_new['products_id'])?>"><?=tep_image(DIR_WS_IMAGES.$products_new['products_image'],$products_new['products_name'],SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)?></a></td></tr>												
					  <tr><td height="6" colspan="3"></td></tr>
					  <tr><td width="242" height="1" class="bg" colspan="3"></td></tr>
					  <tr><td height="10" colspan="3"></td></tr>								  
					 </table>
					 <table border="0" cellspacing="0" cellpadding="0" width="242" align="center">
					  <tr><td width="10"></td>
						  <td width="232"><?=preg_replace('/\s\S*$/i', '', substr($pn, 0, MAX_DESCR_1))?>...</td></tr>
					  <tr><td height="6" colspan="2"></td></tr>	  
					 </table>
<?
if ($col==1) {
	echo '';
	$col=0;
	$row++;
	// replace products prices with those from customers_group table
	if(!empty($new_prices)) {
	for ($i = 0; $i < count($new_prices); $i++) {
		if( $specials[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
		$specials[$x]['products_price'] = $new_prices[$i]['products_price'];
		}
	}
} // end if(!empty($new_prices)
} else {
	echo '		   
							</td>
							<td width="1" bgcolor="#DDDCDC"></td>
							<td width="272" valign="top">';
	$col++;
}
}
if ($col!=0) echo '
					  </td></tr>
					  ';
?>						


				<tr><td height="3" colspan="3"></td></tr>	
			   </table>

<?php
 if (($specials_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>	 
<table border="0" width="100%" cellspacing="0" cellpadding="0" class="sea_22">
				<tr><td height="6" colspan="2"></td></tr>	
				<tr><td width="561" height="1" class="bg" colspan="2"></td></tr>	
 <tr>
<td class="smallText"><?php echo $specials_split->display_count(TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?></td>
<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $specials_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>

<?php
 }
?>


<!-- body_eof //-->

<!-- End code -->
		  </td></tr>
		  <tr><td><?=tep_image(DIR_WS_IMAGES.'m23.gif')?></td><td width="551" bgcolor="#FFFFFF"></td><td><?=tep_image(DIR_WS_IMAGES.'m24.gif')?></td></tr>
		 </table> 
		<?php require(DIR_WS_BOXES . 'panel_bottom.php'); ?>
	</td></tr>
   </table>
 </td></tr> 

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

 

thanks to everyone who helped me out so far, I really appreciate the help.

 

Great, that took care of the warning but I still have problems with the Specials page (I guess I forgot to mention that before). It shows the box where the product/info should go but nothing is displayed. Its similar to the problem TracyS just helped me with... take a look http://www.aestheticdepot.com/shop/specials.php

Share this post


Link to post
Share on other sites

Now that i have solved most of the problem that I had I have found this one

 

When I use the supplied file for classes/shopping_cart.php the prices are fine

 

If I use mine that i have changed then it adds the retail price when it should be the wholesale price

 

I have MVS installed and I think this is causing the problem

 

Here is the code

 

<?php
/*
 $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $

 Modified for MVS V1.0 2006/03/25 JCK/CWG
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2006 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);
	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) . "'");
	  }
	}
  }

// 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;

  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;

  $products_id_string = tep_get_uprid($products_id, $attributes);
  $products_id = tep_get_prid($products_id_string);

  if (is_numeric($products_id) && is_numeric($qty)) {
	$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);

	if (($check_product !== false) && ($check_product['products_status'] == '1')) {
	  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();
	}
  }
}

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 (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity)) {
	$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);
	}
  }

  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) . "'");
  }

// 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 = 0;
  $this->weight = 0;
  if (!is_array($this->contents)) return 0;

  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
	$qty = $this->contents[$products_id]['qty'];
	// BOF Separate Pricing Per Customer
// global variable (session) $sppc_customer_group_id -> class variable cg_id
 global $sppc_customer_group_id;

 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

// 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'];

	  $special_price = tep_get_products_special_price($prid);
	  if ($special_price) {
		$products_price = $special_price;
	  }

	  $this->total += tep_add_tax($products_price, $products_tax) * $qty;
	  $this->weight += ($qty * $products_weight);
	}

// attributes price
	if (isset($this->contents[$products_id]['attributes'])) {
	  reset($this->contents[$products_id]['attributes']);
	  while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
		$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
		$attribute_price = tep_db_fetch_array($attribute_price_query);
		if ($attribute_price['price_prefix'] == '+') {
		  $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		} else {
		  $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		}
	  }
	}
  }
}
//////
//MVS Start
//  New method to provide cost, weight, quantity, and product IDs by vendor
//////
//Output array structure (example):
//shoppingcart Object
//(
//  [vendor_shipping] => array
//	(
//	  [0] => array   //Number is the vendor_id
//		(
//		  [weight] => 22.59
//		  [cost] => 12.95
//		  [qty] => 2
//		  [products_id] => array
//			(
//			  [0] => 12
//			  [1] => 47
//			)
//		)
//	  [12] => array
//		(
//		  [weight] => 32.74
//		  [cost] => 109.59
//		  [qty] => 5
//		  [products_id] => array
//			(
//			  [0] => 2
//			  [1] => 3
//			  [2] => 37
//			  [3] => 49
//			)
//		)
//	)
//)
function vendor_shipping() {

  if (!is_array($this->contents)) return 0;  //Cart is empty

  $this->vendor_shipping = array();  //Initialize the output array
  reset($this->contents);			//  and reset the input array
  foreach ($this->contents as $products_id => $value) {  //$value is never used
	$quantity = $this->contents[$products_id]['qty'];

	$products_query = tep_db_query("select products_id,
										   products_price,
										   products_tax_class_id,
										   products_weight,
										   vendors_id
									from " . TABLE_PRODUCTS . "
									where products_id = '" . (int)$products_id . "'"
								  );
	if ($products = tep_db_fetch_array($products_query)) {
	  $products_price = $products['products_price'];
	  $products_weight = $products['products_weight'];
	  $vendors_id = ($products['vendors_id'] <= 0) ? 1 : $products['vendors_id'];
	  $products_tax = tep_get_tax_rate($products['products_tax_class_id']);

	  //Find special prices (if any)
	  // BOF Separate Pricing Per Customer
/*		 $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows ($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  } */
  $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

	  //Add values to the output array
	  $this->vendor_shipping[$vendors_id]['weight'] += ($quantity * $products_weight);
	  $this->vendor_shipping[$vendors_id]['cost'] += tep_add_tax($products_price, $products_tax) * $quantity;
	  $this->vendor_shipping[$vendors_id]['qty'] += $quantity;
	  $this->vendor_shipping[$vendors_id]['products_id'][] = $products_id; //There can be more than one product
	}

	// Add/subtract attributes prices (if any)
	if (isset($this->contents[$products_id]['attributes'])) {
	  reset($this->contents[$products_id]['attributes']);
	  foreach ($this->contents[$products_id]['attributes'] as $option => $value) {
		$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'] == '+') {
		  $this->vendor_shipping[$vendors_id]['cost'] += $quantity * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		} else {
		  $this->vendor_shipping[$vendors_id]['cost'] -= $quantity * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		}
	  }
	}
  }

  return $this->vendor_shipping;
}
//MVS End

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
// global variable (session) $sppc_customer_group_id -> class variable cg_id
 global $sppc_customer_group_id;

 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

  if (!is_array($this->contents)) return false;

  $products_array = array();
  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
//MVS start - added v.vendors_id, v.vendors_name, and v.vendors_id = p.vendors_id
	$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, v.vendors_id, v.vendors_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_VENDORS . " v where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and v.vendors_id = p.vendors_id and pd.language_id = '" . (int)$languages_id . "'");
	//MVS end
	if ($products = tep_db_fetch_array($products_query)) {
	  $prid = $products['products_id'];
	  $products_price = $products['products_price'];

	  $special_price = tep_get_products_special_price($prid);
	  if ($special_price) {
		$products_price = $special_price;
	  }

	  $products_array[] = array('id' => $products_id,
								'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'],
								//MVS start
								'vendors_id' => $products['vendors_id'],
								'vendors_name' => $products['vendors_name'],
								//MVS end
								'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'];
  }
}

 }
?>

 

Also on the front page it only shows the item price and nothing else (i.e. the product name)

 

Anyone know how to over come at least the wrong price being added

 

Thanks

Share this post


Link to post
Share on other sites
Anyone know how to over come at least the wrong price being added

A. Stay away from the booze :lol:

B. Perhaps because of that wine again you only added half of the code to the function calculate() and get_products().

In both cases you should replace:

		  if ($special_price) {
		$products_price = $special_price;
	  }

with:

	  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

Share this post


Link to post
Share on other sites
A. Stay away from the booze :lol:

 

Nah that's what keeps me going through the night :)

 

B. Perhaps because of that wine again you only added half of the code to the function calculate() and get_products().

 

:blush:

 

Couldn't see the wood for the trees

 

Thanks Janz - This is truly an awesome contribution

 

One of the best here :thumbsup:

 

What you making next ;)

Share this post


Link to post
Share on other sites
Well I figured out that I was also missing a $x in specials.php (line 109). Now all the specials are showing and linking up fine.

 

The very last little problem I'm having is that the price will not show up in specials.php, here's the code

Wow, what a smart template maker: in query $specials_query_raw products_name is retrieved from products_description but instead of simply adding pd.products_description to the query he/she queries that table for every single special that is listed. Smart move.... <_<

 

Changed a number of things. might have missed something...

  $specials_query_raw = "select p.products_id, pd.products_name, pd.products_description, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' and s.customers_group_id = ". (int)$customer_group_id." order by s.specials_date_added DESC";
 $specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);
// EOF Separate Price Per Customer
 $specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);
 if (($specials_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0" class="sea_22">
 <tr>
<td class="smallText"><?php echo $specials_split->display_count(TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?></td>
<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $specials_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php } ?>
			   <table border="0" cellspacing="0" cellpadding="0" width="545" align="center">
<?php
$row=0;
$col=0;
$specials_query = tep_db_query($specials_split->sql_query);
	$no_of_specials = tep_db_num_rows($specials_query);
// get all product prices from the table products_groups in one query
// traverse specials_query for products_id's, store the query result in a numbered array
  while ($_specials = tep_db_fetch_array($specials_query)) {
$specials[] = $_specials;
$list_of_prdct_ids[] = $_specials['products_id'];
  } // end while ($_specials = tep_db_fetch_array($specials_query))
// a line needed for the selection of the products_id's
 $pg_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_specials > 1) {
  for ($n = 1; $n < count($list_of_prdct_ids); $n++) {
  $pg_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";
  }
}
// now get all the customers_group_price's
$pg_query = tep_db_query("select products_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where (".$pg_list_of_prdct_ids.") and customers_group_id =  '" . $customer_group_id . "'");
// put all the info in an array called new_prices
while ($pg_array = tep_db_fetch_array($pg_query)) {
$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['customers_group_price']);
}

for ($x = 0; $x < $no_of_specials; $x++) {	
// replace products prices with those from customers_group table	  
	if(!empty($new_prices)) {
	for ($i = 0; $i < count($new_prices); $i++) {
		if( $specials[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
		$specials[$x]['products_price'] = $new_prices[$i]['products_price'];
		}
	}
} // end if(!empty($new_prices)

// we already got the results from the query and put them into an array, can't use while now
//	while ($specials = tep_db_fetch_array($specials_query)) {
for ($x = 0; $x < $no_of_specials; $x++) {
	$products_new=$specials[$x];

// added products_description to the query above		
/* $product_query=tep_db_query("select products_description  from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_new['products_id'] . "' and language_id = '" . (int)$languages_id . "'");
$product = tep_db_fetch_array($product_query); */
$pn = $specials[$x]['products_description'];

if (($col==0) && ($row!=0)) echo '
						  <tr><td colspan="3">'.tep_image(DIR_WS_IMAGES.'m31.gif').'</td></tr>';

if ($col==0) echo '

						  <tr><td width="272" valign="top">';
?>
					 <table border="0" cellspacing="0" cellpadding="0" width="242" align="center">
					  <tr><td height="5" colspan="3"></td></tr>
					  <tr><td><?=tep_image(DIR_WS_IMAGES.'m38.gif')?></td>
						  <td width="242" height="31" bgcolor="#ECEEF0">     <a class="ml1" href="<?=tep_href_link('product_info.php?products_id='.$products_new['products_id'])?>"><?php $products_new['products_name']?></a></td>
						  <td><?=tep_image(DIR_WS_IMAGES.'m39.gif')?></td></tr>
					  <tr><td height="5" colspan="3"></td></tr>
					  <tr><td width="242" height="1" class="bg" colspan="3"></td></tr>						  
					  <tr><td height="7" colspan="3"></td></tr>
					 </table>
					 <table border="0" cellspacing="0" cellpadding="0" width="242" align="center">
					  <tr><td width="8"></td>							  
						  <td width="154"><span class="tx3"><?php 
$currencies->display_price($specials[$x]['specials_new_products_price'],'')?></span> <s><?php $currencies->display_price($specials[$x]['products_price'],'')?></s><br style="line-height:1px;"><br style="line-height:8px;"><a href="<?=tep_href_link('product_info.php?products_id='.$products_new['products_id'])?>"><?php tep_image_button("button_details.gif");?></a><br style="line-height:1px;"><br style="line-height:4px;"><a href="<?= tep_href_link("products_new.php","action=buy_now&products_id=".$products_new['products_id'])?>"><?php tep_image_button("button_add_to_cart1.gif");?></a></td>
						  <td width="80" class="bd" align="center" valign="top"><a href="<?php tep_href_link('product_info.php?products_id='.$products_new['products_id'])?>"><?=tep_image(DIR_WS_IMAGES.$products_new['products_image'],$products_new['products_name'],SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)?></a></td></tr>												
					  <tr><td height="6" colspan="3"></td></tr>
					  <tr><td width="242" height="1" class="bg" colspan="3"></td></tr>
					  <tr><td height="10" colspan="3"></td></tr>								  
					 </table>
					 <table border="0" cellspacing="0" cellpadding="0" width="242" align="center">
					  <tr><td width="10"></td>
						  <td width="232"><?=preg_replace('/\s\S*$/i', '', substr($pn, 0, MAX_DESCR_1))?>...</td></tr>
					  <tr><td height="6" colspan="2"></td></tr>	  
					 </table>
<?
if ($col==1) {
	echo '';
	$col=0;
	$row++;
	// replace products prices with those from customers_group table
// already done above, too late here
/*		if(!empty($new_prices)) {
	for ($i = 0; $i < count($new_prices); $i++) {
		if( $specials[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
		$specials[$x]['products_price'] = $new_prices[$i]['products_price'];
		}
	}
} // end if(!empty($new_prices) */
} else {

Share this post


Link to post
Share on other sites

Hi,

 

just a quick question;

 

I am getting error 1066 when using the quick search, i assume it's an easy fix job, i wasn't able to find the answer in this thread however (a lot of pages) i'm thinking it's a mysql error but could be wrong, can anyone put me in the right direction to fixing it.

 

Cheers :thumbsup:

Rapid-

Share this post


Link to post
Share on other sites
Hi,

 

just a quick question;

 

I am getting error 1066 when using the quick search, i assume it's an easy fix job, i wasn't able to find the answer in this thread however (a lot of pages) i'm thinking it's a mysql error but could be wrong, can anyone put me in the right direction to fixing it.

 

Cheers :thumbsup:

Rapid-

 

sql error on advanced_search_results.php?

Share this post


Link to post
Share on other sites
sql error on advanced_search_results.php?

Both index.php and advanced_search_result.php will give trouble with MySQL5. There is a post with fixes on page 122 but I'm not sure about what mysql error 1066 is exactly.

Share this post


Link to post
Share on other sites

I just came accross this problem as well

 

1066 - Not unique table/alias: 'pd'

 

select count(distinct p.products_id) as total from products p left join manufacturers m using(manufacturers_id), products_description pd left join specials s on p.products_id = s.products_id, categories c, products_to_categories p2c, products_description pd, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and ((pd.products_name like '%test%' or p.products_model like '%test%' or m.manufacturers_name like '%test%' or pd.products_description like '%test%') )

 

[TEP STOP]

 

If anyone finds a solution please let us know =)

 

Both index.php and advanced_search_result.php will give trouble with MySQL5. There is a post with fixes on page 122 but I'm not sure about what mysql error 1066 is exactly.

Share this post


Link to post
Share on other sites

I have searched the topic, but can't find the answer to my problem. I have SPPC 4.1.5 installed and it's working just fine. I just installed Quantity Price Breaks 1.02 for SPPC and when I click on the Categories/Products under admin I get the following error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /catalog/admin/includes/functions/database.php on line 99

 

I thought I may have messed something up during the install, so I uninstalled it, verifed that everything still worked and installed it again with the same results. MySQL version is 4.1.21 and PHP is 4.4.4.

 

Not sure where to go from here.

 

Thanks


Currently running 76 contibutions.

Share this post


Link to post
Share on other sites

I have searched the topic, but can't find the answer to my problem. I have SPPC 4.1.5 installed and it's working just fine. I just installed Quantity Price Breaks 1.02 for SPPC and when I click on the Categories/Products under admin I get the following error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /catalog/admin/includes/functions/database.php on line 99

 

I thought I may have messed something up during the install, so I uninstalled it, verifed that everything still worked and installed it again with the same results. MySQL version is 4.1.21 and PHP is 4.4.4.

 

Not sure where to go from here.

 

Thanks


Currently running 76 contibutions.

Share this post


Link to post
Share on other sites
I have searched the topic, but can't find the answer to my problem. I have SPPC 4.1.5 installed and it's working just fine. I just installed Quantity Price Breaks 1.02 for SPPC and when I click on the Categories/Products under admin I get the following error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /catalog/admin/includes/functions/database.php on line 99

 

I thought I may have messed something up during the install, so I uninstalled it, verifed that everything still worked and installed it again with the same results. MySQL version is 4.1.21 and PHP is 4.4.4.

 

Not sure where to go from here.

Me neither. This is such a general error that is impossible to answer. Basically it means that in the code you are asking for the results of a query, but the query itself hasn't been executed. Try a file comparison program to see where the missing query might be (maybe stuck in an if/else part that isn't executed?).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×