Jump to content
Jan Zonjee

[Contrib] Admin Specials by Categories for SPPC

Recommended Posts

This is the support thread for the Admin Specials by Categories for SPPC contribution. The original contribution is Admin Specials by Categories by Carine Bruyndoncx. Since Separate Pricing Per Customer adds customer groups in the mix, it needed some changes to work with SPPC.

 

Version 1.0 is based on version 1.4 of Carine (the version to which selection based on manufacturer was added). The SPPC version has pagination added, just in case somebody has a large number of products.

Share this post


Link to post
Share on other sites

I just finished installing this contribution. I am now getting an error anytime I add to cart.

 

Fatal error: Call to undefined function: get_products() in /home/aaasling/public_html/osCommerce2/catalog/shopping_cart.php on line 76

 

This is what the lines look like:

<--- Lines 75-78 in catalog/shopping_cart.php

 

$any_out_of_stock = 0;

$products = $cart->get_products();

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

// Push all attributes information in an array

 

Any info on what would have caused this? I didn't even change this file. I changed the one in the read me file.

Share this post


Link to post
Share on other sites
I just finished installing this contribution. I am now getting an error anytime I add to cart.

 

Any info on what would have caused this? I didn't even change this file. I changed the one in the read me file.

I have no clue, but it can't be this contribution because it is all on the admin side. It is a very strange error, since that function is a class function in includes/classes/shopping_cart.php. This class/file is 'required' by application_top.php which in turn is 'required' in catalog/shopping_cart.php (line 13). Not being able to load those files would have resulted in a fatal PHP error, so I don't see what is causing this error unless you made some unfortunate changes in includes/classes/shopping_cart.php ...

Share this post


Link to post
Share on other sites

I am using dreamweaver and it looks like in classes/shopping_cart.php it is quoting a BUNCH of code.

 

All of the following is yellow(quote) and seems to be triggered by the /* at the beginning. Can you tell me if ALL of this code is to be quoted and unused or is something wrong?

 

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

}

 

$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);

}

}

}

}

}

 

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)) {

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

if ($products = tep_db_fetch_array($products_query)) {

$prid = $products['products_id'];

$products_price = $products['products_price'];// BOF Separate Pricing Per Customer

 

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

 

} */

Share this post


Link to post
Share on other sites

I changed the first /* to // and now am getting this error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/aaasling/public_html/osCommerce2/catalog/includes/functions/database.php on line 104

 

Confused? I am. It seems like that is a valid part in the database.php as only stuff below this line (139 is where it starts the BOF) is changed for the SPPC.

Share this post


Link to post
Share on other sites
Confused? I am.
Me too. First of all you seem to have a problem with Separate Pricing Per Customer (SPPC) instead of Admin Specials by Categories for SPPC. SPPC has its own support thread.

 

Secondly, you post code that resembles code of SPPC in catalog/includes/classes/shopping_cart.php but which is missing pieces and also end tags for comments.

It is therefore not a miracle that you are getting these errors.

 

Can't you use the file that came with the contribution? Or do you use other contributions that make changes to that file?

Share this post


Link to post
Share on other sites

my read me file must be missing stuff. I am using other contributiions and haha...uhm... not sure which files I edited for the others. This one has a "title" so to speak. "After line 4 Add blah blah SPPC" which makes it easy to know that I edited that file for that contribution. I will look at the supplied files and see if there are major differences. Thanks for your help.

Share this post


Link to post
Share on other sites

That's what it was. My read-me file instructions were missing brackets and other important end tags. I have it all fixed to where there are no errors. Now, if this is the right forum to be posting on for customer groups files, when I add something to my cart under a customer group, the price is still the same. Ex. I have changed the price of an item from 518.00 to 500.00. When I add to cart it shows 500.00 after the product, good, but in my subtotal it is still showing 518.00. First, is this the right forum dealing with customer groups and if so how do I fix this.

Share this post


Link to post
Share on other sites
When I add to cart it shows 500.00 after the product, good, but in my subtotal it is still showing 518.00. First, is this the right forum dealing with customer groups and if so how do I fix this.
My guess is there is still something wrong with the file includes/classes/shopping_cart.php because there is where the prices are totalled. Perhaps replacing the prices with those of the group happens after the total has been calculated (then you would see a total of the regular price, but still see the correct group price, see the function calculate in that file.)

Share this post


Link to post
Share on other sites

i installed everthing and get the error

 

1146 - Table 'schreevedb2.TABLE_CUSTOMERS_GROUPS' doesn't exist

 

select customers_group_name, customers_group_id from TABLE_CUSTOMERS_GROUPS order by customers_group_id

 

[TEP STOP]

 

what does this mean?

 

 

PLease help :thumbsup:

Share this post


Link to post
Share on other sites
i installed everthing and get the error

 

1146 - Table 'schreevedb2.TABLE_CUSTOMERS_GROUPS' doesn't exist

Are you sure you installed Separate Pricing Per Customer? Because TABLE_CUSTOMERS_GROUPS is in that contribution. You would have noticed that error much earlier then.

 

Perhaps you need the original contribution by Carine Bruyndoncx (see post #1) instead of this one (this one is adapted for SPPC).

Share this post


Link to post
Share on other sites

JanZ:

 

What a great contrib! I just installed it and it works superbly. The GUI is top notch.

 

Can this be modified, or have you already modified it, to handle *all* pricing, not just for specials?

 

I was looking at the code and it looks like that by adding new column headers("Cost", "% Markup"), the add'l code to pull the product "cost" from the products table (which I have in place already) and the add'l code to calculate markups, and a "markup" input box, this contrib could easily be made to handle all mark-up-based price changes, not just for discounts for specials.

 

Any thoughts? :D


osCommerce MS2

SPPC incl. Specials By Category, Prices By Category

Vendors, Easy Populate, UPS XML, USPS Methods

Share this post


Link to post
Share on other sites
What a great contrib! I just installed it and it works superbly. The GUI is top notch.
Those compliment should be directed to Carine Bruyndonck. I just adapted it for SPPC...
Can this be modified, or have you already modified it, to handle *all* pricing, not just for specials?
Haven't looked at it, since I believe there is already something like that: Quick Price Updates. It "just" hasn't been adapted to SPPC yet.

Share this post


Link to post
Share on other sites

Hello,

 

I just completed installation of the Admin Specials by Categories for SPPC.

 

Alongside SPPC, I also have Price Break for SPPC. When I try to apply a percentage discount on the admin screen I am shown the following error message.

 

 

1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

 

select p.products_id, p.products_price from products p where

 

[TEP STOP]

 

I have also attached a screenshot of this error.

 

specialserror1ac.th.jpg

 

Please could someone give me some help on this!!

 

Regards

 

M Parmar

Share this post


Link to post
Share on other sites
When I try to apply a percentage discount on the admin screen I am shown the following error message.
You can apply a percentage discount on a category but not on "Top", "Top" is not a category.

Share this post


Link to post
Share on other sites
You can apply a percentage discount on a category but not on "Top", "Top" is not a category.

 

 

My bad, thanks a lot :)

 

Nice contribution :D

Share this post


Link to post
Share on other sites

When I apply a percentage discount its only applied for the main price, but not for the attributes. Is their any possibility to change that? Or did I just missed something or did it wrong?

Its a great contribution, thx a lot.

Share this post


Link to post
Share on other sites
When I apply a percentage discount its only applied for the main price, but not for the attributes. Is their any possibility to change that? Or did I just missed something or did it wrong?
No, you didn't miss anything. Attributes are not in the original Admin Specials by Categories contribution, and even attribute prices for groups hasn't been finished. Including attributes in the specials... never thought of that really.

Share this post


Link to post
Share on other sites

Hello,

 

That is something that would be highly useful, especially for sppc users who are already dealing with seperate group pricing. Attribute additions and subtractions to prices really screw up the totals, and I have been unable to find a modification that will handle this very well.

 

Just my 2 cents worth :) Keep up the good work.

 

Chris

Share this post


Link to post
Share on other sites

Wouldnt it be useful to:

 

1. get an overview over all specials just by selecting a customergroup and top?

and

2. to make a discount for ALL products. (cause I have customers who get 10% discount on everything)

 

Or is their any other contribution which solvey my problem?

Share this post


Link to post
Share on other sites
Wouldnt it be useful to:

 

1. get an overview over all specials just by selecting a customergroup and top?

and

2. to make a discount for ALL products. (cause I have customers who get 10% discount on everything)

 

Or is their any other contribution which solvey my problem?

There are all kinds of solutions, like Select Specials adapted for SPPC (haven't tried it myself yet), Quick Price Updates for SPPC and of course you can do straight sql in phpMyAdmin to add all products with a 10% discount for a specific group:

insert into products_groups select '1' AS customers_group_id, (0.9 * p.products_price) AS customers_group_price, p.products_id FROM products p;

Share this post


Link to post
Share on other sites

Hello

Where i define Y or N ?

snap2hm7.th.jpg

 

 

all my prices are specials for visitors and not for a group.

 

Has what that serves because I put a discount(delivery) has a group and because I can leave the complete price(prize) for a product préçis?

Share this post


Link to post
Share on other sites

Hi Jan,

 

Just a small FYI. There is a short tag on line 177 in admin/specialsbycategory.php.

 

For anyone who has the php code printing to the browser, change line 177 from <? to <?php To avoid conflict with the xml open tag <?xml, I guess everyone should change it anyway.

 

SPPC is great - thanks for all your hard work.

Share this post


Link to post
Share on other sites

Hello

This contribution looks like what I was looking for. But I have a lot of specials and I d like to keep/put them in sub categories on the catalog side. Is there a way to put sub categories in the specials section? I looked around but I am not quit sure which contribution to use. Especially since I am using SPPC.

 

Thancks a lot for your help

 

Badou

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

×