Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Sorry about the double post, but that TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES was from something else and should be TABLE_PRODUCTS_TO_CATEGORIES and should look something more like this:

$products_query = tep_db_query("select cb.products_id, pc.categories_id, cb.customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " cb LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " pc on cb.products_id=pc.products_id where cb.customers_id = '" . (int)$customer_id . "'");

<Curt

Link to comment
Share on other sites

I think that this database query (around line 51):

	  $products_query = tep_db_query("select product_to_categories.products_id, categories_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " using(products_id) where customers_id = '" . (int)$customer_id . "'");

should look like this (or similar):

	  $products_query = tep_db_query("select cb.products_id, pdc.categories_id, cb.customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " cb LEFT JOIN " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " pdc on cb.products_id=pdc.products_id where cb.customers_id = '" . (int)$customer_id . "'");

Did I get that right?

Apart from the TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES which you spotted already I do think you found the problem spot. I sure made a big mistake there, since in the table customers_basket the products_id is not an integer but tiny text (so with the attributes) and that doesn't work well when joining those two tables (and losing the attributes because I used the products_to_categories.products_id instead of the correct one).

 

Also using the ptc is more correct.

 

For the correct joining of the tables and not losing attributes this looks more promising (includes/classes/shopping_cart.php around line 50):

// BOF Price Break for SPPC mod, price break per category
  $products_query = tep_db_query("select cb.products_id, categories_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " cb LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc on cb." .(int)products_id. " = ptc.products_id 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'], 'category' => $products['categories_id']);
// EOF Price Break for SPPC mod, price break per category

 

As an aside, you were aware of the error in PriceFormatter.php for this modification?

Link to comment
Share on other sites

Actually, it looks like MySQL does it own conversion to integer so the above doesn't look good either (although it seems to work fine). What you proposed looks good:

// BOF Price Break for SPPC mod, price break per category
  $products_query = tep_db_query("select cb.products_id, categories_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " cb LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc on cb.products_id = ptc.products_id 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'], 'category' => $products['categories_id']);
// EOF Price Break for SPPC mod, price break per category

Link to comment
Share on other sites

I did have the PriceFormatter.php mod, I don't remember when I added it but it is there.

Thanks for all your help again. I was a bit sceptical of myself and it is nice to be confirmed...

Time for a 1.3 pb for sppc?

<Curt

Link to comment
Share on other sites

Mike,

Bizar, the error seems to popup everywhere, also on places that are not even touched by SPPC (like boxes/shopping_cart) or shopping_cart.php itself. Since you seem to have lots of mods added, it is hard to even start to guess where the errors comes from. Perhaps you can paste the code for say boxes/shopping_cart.php here and then perhaps we can see where it could possibly come from. I mean: add one product to the shopping cart and generate three errors like that :blink:

 

Jan - thanks for the reply - I agree it is bizar!

 

So rather than use your time to pursue this, I am going to reinstall and see if I can make a better job of it - or to see if I get the same errors - I will aim to do this weekend when its quiet!

 

I notice that version 4.11 now exists - would you suggest I install version 4 or 4.11?

 

Many thanks for your assistance,

 

Regards

 

Mike

Link to comment
Share on other sites

I have 2 tax zones, but the contrib seems to calculate both the zones into the final VAT, how come that happens?

 

I could always delete the zones but then that means I would have to have the same VAT to everyone, and that isnt really ok....

 

A better description would be:

Zones:

EU (vat 22%)

Finland (vat 22%)

 

Product:

Glass (price with no vat = 100)

 

Buy:

Glass: 100 ?

Shipping: 5 ?

Vat: 44 ?

Subtotal: 149 ?

 

I wonder what is going wrong =/

Link to comment
Share on other sites

This is 'kinda' related to the Show Price list for SPPC contrib:

 

Id like to do something and wondered is somebody in here could help. On the product info page(product_info.php) I would like to add a line of HTML right below the PRICE. I would like it to show when the customer either isnt logged in or is logged in and in the retail/default group. If the customer is in any other group I dont want it to show.

 

Any ideas? :blink: Much thanks in advance!

Link to comment
Share on other sites

I have 2 tax zones, but the contrib seems to calculate both the zones into the final VAT, how come that happens?
I have a hard time believing SPPC has anything to do with this, I wouldn't know how. Don't you think it might have something to do with the fact that Finland is in the EU and so the tax rates are added? I'm not very familiar with the zones part of osC, so better check the knowledge base on this.
Link to comment
Share on other sites

could anyone help me with this:

 

- i want to create a "members only" area of my site. i want to use all existing pages in account.php, except i want to create a link called "advanced members only stuff"

 

would it be as easy as loading the customers_group_id & customers_group_ra tables to my database?

 

how could i keep regular members from seeing the advanced members link in account.php?

 

 

if it matters: i don't need any special pricing or any stuff like that. i just want to create an advanced members only section

Edited by eww
Link to comment
Share on other sites

I would like to add a line of HTML right below the PRICE. I would like it to show when the customer either isnt logged in or is logged in and in the retail/default group. If the customer is in any other group I dont want it to show.
What about:

<?php 
if (!isset($_SESSION['sppc_customer_group_id']) || (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] == '0' ) {
echo '<p>Whatever you like</p>';
}
?>

Link to comment
Share on other sites

What about:

<?php 
if (!isset($_SESSION['sppc_customer_group_id']) || (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] == '0' ) {
echo '<p>Whatever you like</p>';
}
?>

 

Tried that(in a handful of places)....keeps giving me errors. Unexpected '<' or unexpected '{' depending where its at. Maybe im way off base in my placement, not sure.

 

I also tried defining what I want to place there in teh english.php file and adding another:

$products_price .= SHOW_TEST_TEXT;

I have a small insite as to how this is working, but dont understand exactly why it displays only the one price when not logged in(or logged in as default group member) and not both prices.

 

Either way, im stuck :-"

Link to comment
Share on other sites

- i want to create a "members only" area of my site. i want to use all existing pages in account.php, except i want to create a link called "advanced members only stuff"

 

would it be as easy as loading the customers_group_id & customers_group_ra tables to my database?

I think you could do that yes. The sql you would need is IMHO:

ALTER TABLE customers
ADD customers_group_id smallint UNSIGNED NOT NULL default '0',
ADD customers_group_ra enum('0','1') NOT NULL;

DROP TABLE IF EXISTS customers_groups;
CREATE TABLE customers_groups (
customers_group_id smallint UNSIGNED NOT NULL,
customers_group_name varchar(32) NOT NULL default '',
customers_group_show_tax enum('1','0') NOT NULL,
customers_group_tax_exempt enum('0','1') NOT NULL,
group_payment_allowed varchar(255) NOT NULL default '',
group_shipment_allowed varchar(255) NOT NULL default '',
PRIMARY KEY (customers_group_id)
);

INSERT INTO customers_groups VALUES('0','Retail','1','0','','');

ALTER TABLE address_book 
ADD entry_company_tax_id VARCHAR(32) DEFAULT NULL AFTER entry_company;

Then only do the changes to create_account.php, login.php, logoff.php (and any respective language files), includes/database_tables for any new tables (also on the admin side). On the admin side you only would need to add customers_groups.php and change customers.php.

 

how could i keep regular members from seeing the advanced members link in account.php?
See the above answer for Sid04. Simplify it to only lookif the session variable is set and if it is the group of the advanced members.

 

To keep regular customers out if they hear about this and type in the url manually you will need to add some code to those "advanced members" files: look for the session variable (see above) and if that is not OK do a:

header("Location: http://whatever_your_site_is/index.php");
exit;

That will redirect the browsers of the not allowed customers to your index page and hackers will not get the page either because you do an exit. See the PHP website.

Link to comment
Share on other sites

Tried that(in a handful of places)....keeps giving me errors. Unexpected '<' or unexpected '{' depending where its at. Maybe im way off base in my placement, not sure.
Yes, it is missing a ")" at the end of the line that starts with if:

if (!isset($_SESSION['sppc_customer_group_id']) || (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] == '0' )) {
echo '<p>Whatever you like</p>';
}

If it is inside a block of PHP code, you don't need the opening and closing php tag of course.

 

I tried it, and it works for me :D

Link to comment
Share on other sites

JanZ- Once again, you rule. I think I got it where I like it.....id just like you to check and make sure there are no problems where I put that code:

		<td class="main">
<?php
if (tep_not_null($product_info['products_image'])) {
?>
	  <table border="0" cellspacing="0" cellpadding="2" align="right">
		<tr>
		  <td align="center" class="smallText">
<?php 
if (!isset($_SESSION['sppc_customer_group_id']) || (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] == '0' )) {
echo '<p>Whatever you like</p>';
}
?>
<script language="javascript"><!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>
</noscript>
		  </td>
		</tr>
	  </table>

 

Thanks!

Link to comment
Share on other sites

<?php 
if (!isset($_SESSION['sppc_customer_group_id']) || (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] == '0' )) {
echo '<p>Jan saved the day, again! Thanks!</p>';
}
?>

 

better? :thumbsup:

Link to comment
Share on other sites

can this mod be added without installing ACA2.0?
Of course, but the idea of not having to manually add code to the page admin/categories.php is nice, especially for beginners.

 

If you don't have any contributions added to that page yet, use the file from the package. That is the best thing to do for any page, least chance of install problems.

Link to comment
Share on other sites

I have a hard time believing SPPC has anything to do with this, I wouldn't know how. Don't you think it might have something to do with the fact that Finland is in the EU and so the tax rates are added? I'm not very familiar with the zones part of osC, so better check the knowledge base on this.

 

Yeah, but the zone that I have the eu in, I dont have finland added to that zone, it has a separate zone...

It has something to do with the wholesale thingie I think...

Link to comment
Share on other sites

I am looking to install a contribution like this into my website (www.deviltronics.com).

 

I only have one problem with this contribution.This is:

 

The way the selection is made for wholesale (or whatever) customers. Looking at the initial introduction to this contribution on release 4.0 a few pages back it shows that the wholesale/trade customers are selected when they put a company tax number in.

 

I don't want this as I am not bothered if they have a tax number or not as all my taxes will stay the same for both the retail and trade customers.

 

What i am looking for is a manual option where i can switch on/off a particular user for wholesale or retail prices. This could be done in the admin panel by checking boxes or selecting from a drop down menu.

 

Is this possible with this contribution.?

 

Apart from that, the rest of the contribution looks like just what I need.

 

Just want this question answered before I progress and start modding all the files.

 

Thanks.

Link to comment
Share on other sites

Hi

 

Im needing help, i need the retail group to be on "pending for approval status" after creating an account, admin should activate their account first before being able to login, just like other sppc groups. How do i do this?

 

I apperaciate any input/help.

Link to comment
Share on other sites

Hi

 

Im needing help, i need the retail group to be on "pending for approval status" after creating an account, admin should activate their account first before being able to login, just like other sppc groups. How do i do this?

 

I apperaciate any input/help.

 

 

ok that might not be sufficient information.. i will explain my situation further so maybe you guys have other resort or idea for me.

 

i installed login obligator contrib because i want the store to be available only for groups other than retail group, but once the customer create account, they are automatically became retail group. now i dont want customer to be on retail group after creating an account i just want them to be on pending status and not be able to enter the restricted area until admin approve their account.

 

Please help. thank you in advance

 

eric

Link to comment
Share on other sites

The way the selection is made for wholesale (or whatever) customers. Looking at the initial introduction to this contribution on release 4.0 a few pages back it shows that the wholesale/trade customers are selected when they put a company tax number in.
No, when a customer creates an account nothing is set by SPPC for the customer_group_id, so the default of that database field (which happens to be 0, for retail) is entered when a record is inserted.

 

When a tax id number is entered by the new customer, you are only alerted in the admin (with a red dot in the row) that this is a customer who had a tax id number entered (so a likely candidate to put in another group). Transferring the customer to another group is done manually, although there were a few question in this thread on how to do that automatically when creating an account. It's not the default behaviour.

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...