Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Hi there,

Everything is working great... except for the fact that I am not getting Store Owner notifications when someone populates the "tax id" field when creating their account. Nothing is sent to the Store Owner (me) letting me know someone has signed up with a "tax id".

 

I've read back to page 60 and haven't found an answer... can anyone tell me where to look to correct this (and get the notification sent)?

 

Thank you,

BD

Link to comment
Share on other sites

Everything is working great... except for the fact that I am not getting Store Owner notifications when someone populates the "tax id" field when creating their account. Nothing is sent to the Store Owner (me) letting me know someone has signed up with a "tax id".
Should work, this is the code that does that (a little before halfway down the file create_account.php):

	 $email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING;
  tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

// BOF Separate Pricing Per Customer: alert shop owner of account created by a company
  // if you would like to have an email when either a company name has been entered in
  // the appropriate field or a tax id number, or both then uncomment the next line and comment the default
  // setting: only email when a tax_id number has been given
 //	if ( (ACCOUNT_COMPANY == 'true' && tep_not_null($company) ) || (ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) ) ) { 
  if ( ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) ) { 
  $alert_email_text = "Please note that " . $firstname . " " . $lastname . " of the company: " . $company . " has created an account.";
  tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, 'Company account created', $alert_email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
  }
// EOF Separate Pricing Per Customer: alert shop owner of account created by a company

  tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));
}
 }

 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

If ACCOUNT_COMPANY is set to false (admin setting) it wouldn't be sent, but then the box where to enter the tax id wouldn't be visible either. So, no clue why it doesn't work for you.

Link to comment
Share on other sites

tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, 'Company account created', $alert_email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

Hmm,

When I change the above code and hardcode the values instead, i.e.:

 

tep_mail('Me', '[email protected]', 'Company account created', $alert_email_text, 'Me', '[email protected]');

 

It works. I wonder what's causing it to not work when it's not hardcoded. I won't lose too much sleep though, since this workaround "works."

 

Thanks JZ!

BD

Link to comment
Share on other sites

Hmmm.... I'm stumped.

 

Can anyone have a look at a little challenge I have found with the products_new.php in the latest few version of this package.

 

When run I get the following error message :huh:

 

Parse error: parse error, unexpected T_ELSE in /var/users/globalit/globalcoffee.co.nz/htdocs/products_new.php on line 171

 

I have checked and the products_new.php is the same as in the packages and has not been modified by any other contribution. Has anyone seen this problem before?

 

Currently running 4.0, but I note that the products_new.php has the following header as it has not changed with the version increments.

 

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

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

Link to comment
Share on other sites

JanZ THANX and a tip o' the hat. I appreciate how active you are on these boards, I see your name a lot with targeted input.

 

bundled products I think will work out OK as it pulls product info from the original catalog database record to use for product_info.php, but each bundle has its own product_id and price, thereby making it "just another product".

 

The infinite loop possibility would be tricky, but I thought to make it a conditional test statement that would test what the order value would be before applying the discount, and then update the customer's group to give the best deal.Especially because when a bundled product is unbundled, the retail price will be higher, but the net after discount may be lower than the total using the value-priced bundle. The bundled product MOD already has code in it to fetch all the included products, their price, and their total. On the next attempted iteration, it wouldn't, as the customer group would be different now. They do get the permanent upgrade upon reaching min order level once.

 

Dangling Carrot appears to place a note in the shopping cart box of "order $X more and get Y free". and then presto, upon achieving $X, Y appears in the cart.

 

After reading your comments, this sounds like a big job to modify for my needs, but I think combining CCGV, SPPC or other customer grouping & hiding MOD, and an order total MOD will put it right, with a healthy dose of custom code here & there. oh and a price break per product. I'll set this on the back burner for now and keep perusing the extensive selection of MODS!

Toward Continued Success - - > Carol Hawkey - - > KidsLearnToSew.com - - > Wyoming, USA

Mods Installed - - > Authnet AIM2 - Bundled Products 1.4 - Fancier Invoice 6.1 - Email_HTML_Order_Link_Fixed - Header Tags Controller - Login aLa Amazon - JustOneAttribute - Article Manager - SPPC w/PB - spiders.txt - Dangling Carrot/Olive - Printable Catalog - CCGV(trad)

Planned Mods - - > Purchase Without Account - USPS Label - Ultimate SEO

Link to comment
Share on other sites

Speaking of Quantity Price Break Per Product for SPPC...

I have this running with price break per category and everything works great.

Is it possible to give a quantity break on an item without calculating the product category quantity "also". I guess is there a way to use it both ways where some products price breaks come from product category counts and some come from only the product getting the price break?

Link to comment
Share on other sites

I have this running with price break per category and everything works great.

Is it possible to give a quantity break on an item without calculating the product category quantity "also". I guess is there a way to use it both ways where some products price breaks come from product category counts and some come from only the product getting the price break?

I haven't tried this but it should work in principle. Say you make a comma separated list of the products_id's you want to have "on their own" and put this in a file, let's call it list_prdcts_numbers_not_in_category_count.txt and save it in the directory modules.

Now on the moments the category is determined in the class shopping_cart.php and PriceFormatter you read this file in, do an explode using the comma's and read all the products_id's in an array. Depending on the way you implement it you can exchange the category for the products_id when it is in that array or use a different sql in an if else scenario. Products_id is always unique, so has it's category to its own.

 

Here is some sample code for reading the file into an array, the function remove_white_space could be added to general.php.

	$file_with_prdct_nos = DIR_FS_CATALOG . DIR_WS_MODULES .'list_prdcts_numbers_not_in_category_count.txt';
$fp = fopen($file_with_prdct_nos, "r") or die("Cannot open file with list of products that need to be excluded from category count");
$filesize_fp = filesize($file_with_prdct_nos);
$f_contents = fread($fp, $filesize_fp);
@fclose($fp);
$products_exclude = explode(",", $f_contents);
array_walk($products_exclude, "remove_white_space"); // remove spaces and line endings to get "clean" product id's

function remove_white_space(&$val, $key) {
$val = trim($val);
$val = (int)$val;
}

Link to comment
Share on other sites

Curt: so like, the way PB/SPPC is now, a category price break at qty=5. buy 3 of A, 2 of B, get price break, but you don't want that! they have to buy either 5 of A or 5 of B to get the price break. But then maybe it would be OK to combine C and D and E, 2 each, and get the price break, but not on A or B. Yes, I would like this too. more flexible. Maybe A, B could be in a sub-category, and C, D, E in another, and get the same effect?

TIA for all input,

I like reading the last 6 months worth of forum before adding a MOD, it helps me a lot in installation and understanding what it going on before beginning.

Toward Continued Success - - > Carol Hawkey - - > KidsLearnToSew.com - - > Wyoming, USA

Mods Installed - - > Authnet AIM2 - Bundled Products 1.4 - Fancier Invoice 6.1 - Email_HTML_Order_Link_Fixed - Header Tags Controller - Login aLa Amazon - JustOneAttribute - Article Manager - SPPC w/PB - spiders.txt - Dangling Carrot/Olive - Printable Catalog - CCGV(trad)

Planned Mods - - > Purchase Without Account - USPS Label - Ultimate SEO

Link to comment
Share on other sites

Jan,

I was thinking of if/else'ing the per catagory mods and say add a on/off column to the database. I need to think about this more, but maybe it might be easier to have a fake catagory with the product in it kind of like discount_categories only discount_categories_to_products.

Link to comment
Share on other sites

Jan,

I hate to double post but I found the answer in another post of yours:

Quanity Discount w/Exclusions

Using the last option and building a new table products_to_discount_categories allows you do define all your discount groups, and that is the main function of the mod anyway.

 

One way of doing that would be to set up a table as discount_categories but then TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES (similar to and instead of TABLE_PRODUCTS_TO_CATEGORIES):

 

CREATE TABLE products_to_discount_categories (
products_id int NOT NULL,
categories_id int NOT NULL,
PRIMARY KEY (products_id,categories_id)
);

Then don't use the mod/adapted mod for top level category, but the mod for category using the new table in the sql instead of products_to_categories. Fill the TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES with products_id and categories_id, but for the products you want to exclude from being counted use both the products_id in the fields products_id and categories_id. That way they will be in a category of their own. This is quite a bit of manual editing of the tables of course.

You should note that if you are reading this and you are not JanZ, you will also have to make a few changes to classes PriceFormatter.php and shopping_cart.php and add a define to database_tables.php for products_to_discount_categories as outlined in the full original post by JanZ.

 

Side note: What if... you wanted a product in more than one category. Primary keys aside, I don't really have the need, it just crossed my mind, and no you don't have to figure this one out too...

Thanks again for all your time <Curt

Edited by curt
Link to comment
Share on other sites

Curt,

I hate to double post but I found the answer in another post of yours:

Quanity Discount w/Exclusions

Using the last option and building a new table products_to_discount_categories allows you do define all your discount groups, and that is the main function of the mod anyway.

You are right, this is the most flexible way to do it. The products_id is not always unique by the way (a few posts back) since the lower ones could be the same as a category.

 

Since there is no admin part for it, I thought a version that reads a file (is quicker than an sql query I understand) that is simple to maintain might be easier.

Side note: What if... you wanted a product in more than one category. Primary keys aside, I don't really have the need, it just crossed my mind, and no you don't have to figure this one out too...
Yes, you have me stumped there :)
Link to comment
Share on other sites

Curt,

Using the last option and building a new table products_to_discount_categories allows you do define all your discount groups, and that is the main function of the mod anyway.
On second thought I think it can be done even more simpler and easier to maintain. If you add to the table products_to_categories a new field, say discount_cat_id, non nullable, default 0, varchar 50, fill it with zero's (update products_to_categories set discount_cat_id = '0';) and change the sql to use:
....select .... IF(discount_cat_id = '0', categories_id, discount_cat_id) as categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . "....

it will use the category as default and if you have changed it, it will use that (another category, or add something like "pid". $products_id if you want a unique category that will not "add to the category count"). That way you could become very specific to what products you want to "add up" in your price break per category.

Link to comment
Share on other sites

Jan,

That would be a very easy way to remove products from counting towards the category discount and would be very easy on the admin side. I have a coulpe of main categories that that are combined to get the discounts. I don't sell wine but say category white wine also has subcategories dry and sweet and category red wine also has dry and sweet and you want all red and white wine to get a discount based on the total bottles of wine.

 

Side note: what if... (hehe) you wanted to give a discount on tier one and tier two base on the single products count only and then wanted to combine the rest of the category for counts for the remaining tiers of discounts. buy 5 of one variety, or buy 10 of one variety but buy 50 or more mix match, buy 100 or more mix match.

 

btw, are you a night owl or in the UK?

<Curt

Edited by curt
Link to comment
Share on other sites

Curt,

Side note: what if... (hehe) you wanted to give a discount on tier one and tier two base on the single products count only and then wanted to combine the rest of the category for counts for the remaining tiers of discounts. buy 5 of one variety, or buy 10 of one variety but buy 50 or more mix match, buy 100 or more mix match.
You could add another column with its own "category" and add that to the array also (so product['category'], product['tier_two_category']) and do something with that? Or perhaps (re)write an order_total module to give a discount in the checkout?
btw, are you a night owl or in the UK?
Close, I'm in the Netherlands.
Link to comment
Share on other sites

Jan,

Where are the prices rounded? They seem to be rounded at each then added for qty. This would negate having more than two decimals for products_price. They aren't needed unless you calculate products_price*qty and then round...

ie. currently 3 qty at 3.3333 = 9.99 and 3 qty at 3.3350 = 10.02

<Curt

Edited by curt
Link to comment
Share on other sites

Curt,

Where are the prices rounded? They seem to be rounded at each then added for qty. This would negate having more than two decimals for products_price. They aren't needed unless you calculate products_price*qty and then round...

ie. currently 3 qty at 3.3333 = 9.99 and 3 qty at 3.3350 = 10.02

True, at least one of the culprits is this line in the class shopping_cart, in the function calculate:

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

If you change it to:

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

you get a lot more accurate shopping cart. I don't know if there are more places where this goes wrong (checkout in particular)

Link to comment
Share on other sites

Jan,

A couple of other important changes needed for that

order.php around line 273

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

currencies.php around line 73

	/*return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);*/
  return $this->format(tep_add_tax($products_price* $quantity, $products_tax));

Plus your shopping_cart.php change

That takes care of the whole checkout process. account_history_info.php would still need a change and probably a couple of admin side files so viewing the orders from there would be correct.

I am done for the day and probably won't be back until after the holidays...

<Curt

Edited by curt
Link to comment
Share on other sites

:-"

Geez I feel like a street bum in a room full of proffessors on this forum :thumbsup:

 

anyway.. JanZ

 

I have 3 groups of customers I wish to cater for:-

 

Not including normal breeze in customers who are the default classification group..

 

Group 1 are to get 5% discount shown to them

Group 2 also get 5% but are sourced by a different criteria

Group 3 are memberes of both grp 1&2, therfore get a combined discount of 10%

 

In relation to your post a few pages back running this mysql patch will fix this??

--------------------------------------------------------------------------------------------------------------

insert into products_groups select '1' as customers_group_id, (0.95 * p.products_price) as customers_group_price, p.products_id from products p;

 

insert into products_groups select '2' as customers_group_id, (0.95 * p.products_price) as customers_group_price, p.products_id from products p;

 

insert into products_groups select '3' as customers_group_id, (0.9 * p.products_price) as customers_group_price, p.products_id from products p;

---------------------------------------------------------------------------------------------------------------

 

Adding customers to the group is no great problem , doing this by hand.

 

Is there any other changes required for the code to instigate this??

 

Cheers.. Mike.

Link to comment
Share on other sites

Mike,

Is there any other changes required for the code to instigate this??
That should do it, but make sure that you have entered the new groups with their description in admin/customers_groups.php. Probably it won't show any errors on the catalog side, but surely on the admin side and it will even delete the prices for that group if there are no entries done in admin/customers_groups.php.
Link to comment
Share on other sites

Thank you JanZ

 

it worked like a charm!!

 

all prices for each group are now functioning perfectly.

 

I do have one request... next time our CVS live feed is up dated, I will need to re-run a mysql script to configure these groups inline with the new data..

 

Obviously the script you gave me will not work due to the "insert fields" command..

 

Do I just remove the Insert command and run the rest as it stands??

 

Example :-

 

insert into products_groups select '1' as customers_group_id, (0.95 * p.products_price) as customers_group_price, p.products_id from products p;

 

and change this too:-

 

products_groups select '1' as customers_group_id, (0.95 * p.products_price) as customers_group_price, p.products_id from products p;

 

Or is it nessasary to "clear" the table first somehow and start again?

 

Regards.. Mike

Link to comment
Share on other sites

Mike,

I do have one request... next time our CVS live feed is up dated, I will need to re-run a mysql script to configure these groups inline with the new data..

 

Obviously the script you gave me will not work due to the "insert fields" command..

No it won't but if you put a delete command in front of it it should work. Then you "cleared" the table:

delete from products_groups where customers_group_id = '1';
insert into products_groups select '1' as customers_group_id, (0.95 * p.products_price) as customers_group_price, p.products_id from products p;

delete from products_groups where customers_group_id = '2';
insert into products_groups select '2' as customers_group_id, (0.95 * p.products_price) as customers_group_price, p.products_id from products p;

delete from products_groups where customers_group_id = '3';
insert into products_groups select '3' as customers_group_id, (0.9 * p.products_price) as customers_group_price, p.products_id from products p;

I think if you put this in an *.sql script and run it, it will only take a fraction of a second.

 

For versions of MySQL >= 4.1, I think you can do this (new) command (learned about that from Harald's blog):

insert into products_groups select '1' as customers_group_id, (0.95 * p.products_price) as customers_group_price, p.products_id from products p on duplicate key update;

I use an older version locally, so I haven't been able to check that.

Link to comment
Share on other sites

I have searched the thread and have not been able to find a solution.

 

I would like to have wholesale account automatically approved (like default new account) with having to go through the admin to assign to a group.

 

Is there a way to set it up so if there is info in tax account number, then wholesale would be approved automatically.

 

Thanks for any help.

Steven

Link to comment
Share on other sites

JanZ, it works perfectly, with that one simple script you have added a whole new dimension to the shop!!!!

 

Thanking you most kindly, both for your assistance and you patience in this matter...

 

We can still add people on a per singular basis , but now can also set prices per group, including when CVS updating has been done..

 

Again, thank you most humbly...

 

Mike

Link to comment
Share on other sites

Good Day.

 

I am trying to implement this contribution. I am getting the following errors.

 

1. Call to undefined function: shopping_cart.php

On trying to add product to shoping cart I get the following error. Fatal error: Call to undefined function: get_products() in /home/xxxxx/public_html/shop/catalog/shopping_cart.php on line 69.

 

2. SQL syntax Error products_new.php

 

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 ') and status = '1' and s.customers_group_id = '0'' at line 1

 

select s.products_id, specials_new_products_price from specials s where () and status = '1' and s.customers_group_id = '0'

 

[TEP STOP]

 

Cant figure out how to get around any of the problems above.

 

Thank you for your assistsnce

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...