Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

i have 2 groups "CONSUMER, MERCHANT",

what i want to do is after loging-in redirect the consumer to FILENAME_CONSUMER and if merchant to FILENAME_MERCHANT.

 

in login.php i found

....

but im not even sure if thats the right line to alter.

I think think should work in login.php:

// restore cart contents
       $cart->restore_contents();

       if (sizeof($navigation->snapshot) > 0) {
         $origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);
         $navigation->clear_snapshot();
         tep_redirect($origin_href);
       } else {
      if ($sppc_customer_group_id != '0') { // retail is always '0'
           tep_redirect(tep_href_link(FILENAME_MERCHANT));
        } else {
           tep_redirect(tep_href_link(FILENAME_CONSUMER));
        }
         // tep_redirect(tep_href_link(FILENAME_DEFAULT));
       } // end else / if (sizeof($navigation->snapshot) > 0)
     }
   }
 }

 if ($error == true) {

Link to comment
Share on other sites

i have anohter problem

 

im trying to insert this code in product_info.php

 

        <?php
              if ($sppc_customer_group_id != '0') { // retail is always '0'
                echo '<a href="' . tep_href_link(FILENAME_MERCHANT) . '">' . 'CLICK HERE' . '</a>';
              } else {
                echo '<a href="' . tep_href_link(FILENAME_CONSUMER) . '">' . 'CLICK HERE' . '</a>';
              }
              ?>

 

but i cant make it to work.

 

the link to FILENAME_MERCHANT shows even if the customer_group_id is 0

 

help pls

 

Edit: i forgot to tell that i am trying to make a link, difrent for each groups. pls tell me if this is nt the best way to do it

Edited by technoboy
Link to comment
Share on other sites

Hey!

 

Can anyone show me how to make the created specials in the includes/modules/new_products.php file - display with a strike through (<s></s>) for the regular price, and in red (<span class="productSpecialPrice"></span>) for the specials price, just like it displays in the includes/boxes/whats_new.php file.

 

I'm guessing it has to be done somewhere in the following code from the includes/modules/new_products.php file:

 

// an extra query is needed for all the specials
$specials_query = tep_db_query("select products_id, specials_new_products_price from specials where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "' ");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'specials_new_products_price' => $specials_array['specials_new_products_price']);
}

// replace products_price with the correct specials_new_products_price
if(!empty($new_s_prices)) {
for ($x = 0; $x < $no_of_new_products; $x++) { 
    for ($i = 0; $i < count($new_s_prices); $i++) {
     if( $new_products[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
	 $new_products[$x]['products_price'] = $new_s_prices[$i]['specials_new_products_price'];

     }
       }
      } 
     }

Thanks in advance.

 

Carlos

Link to comment
Share on other sites

im trying to insert this code in product_info.php

<?php
? ? ? ? ? ? ? if ($sppc_customer_group_id != '0') { // retail is always '0'

but i cant make it to work.

 

the link to FILENAME_MERCHANT shows even if the customer_group_id is 0

$sppc_customer_group_id is only used in login.php. In this page the variable is called $customer_group_id but if you need it earlier then before it is determined from the session variables you would have to move that piece of code higher or alternatively use the session variable directly:

<?php
? ? ? ? ? ? ? if ($_SESSION['sppc_customer_group_id'] != '0') { // retail is always '0'

Link to comment
Share on other sites

$sppc_customer_group_id is only used in login.php. In this page the variable is called $customer_group_id but if you need it earlier then before it is determined from the session variables you would have to move that piece of code higher or alternatively use the session variable directly:

<?php
              if ($_SESSION['sppc_customer_group_id'] != '0') { // retail is always '0'

 

 

now i get it! it will go alongway to my learing experience! thanks thanks

Link to comment
Share on other sites

I am using SPPC 4.0 (upgrading to 4.1 tomorrow)

 

I have searched the topic concerning the percentage hack(s), and haven't found a solution to my problem:

 

I would like to be able to apply a percentage discount across the board for all products. I have 6000 products in my database, so adding a custom price for every single product for 1000 customers is not do-able.

 

Anyone have a suggestion?

osCommerce MS2

SPPC incl. Specials By Category, Prices By Category

Vendors, Easy Populate, UPS XML, USPS Methods

Link to comment
Share on other sites

I would like to be able to apply a percentage discount across the board for all products.  I have 6000 products in my database, so adding a custom price for every single product for 1000 customers is not do-able.

 

Anyone have a suggestion?

SQL commands should come to the rescue then. First make sure there are no prices for the particular customer group in the database (say 1):

delete from products_groups where customers_group_id = '1';

Then:

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;

I tested this only on test shops and that worked. Backup, backup, backup as always ;)

 

I hope you are not going to insert 1000 different customer goups :'(

Link to comment
Share on other sites

Thanks for the reply JanZ.

 

Yes, I do plan to add the existing customer base this weekend, all 1026 of them. :'(

 

Some customers have a flat discount across the board for all products. I have to come up with a way to handle this.

 

I thought that if a special product ID, such as "*", was inserted into the product ID field and a discount of 20% for example was in the price field, the special product ID could be tested for this character and the code would assume a product ID match.

 

Your suggestion is great for a small number of products/few customers, but I don't want to have to run a script and change it for each customer's/group's price updates.

 

Any ideas? :(

 

 

SQL commands should come to the rescue then. First make sure there are no prices for the particular customer group in the database (say 1):

delete from products_groups where customers_group_id = '1';

Then:

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;

I tested this only on test shops and that worked. Backup, backup, backup as always ;)

 

I hope you are not going to insert 1000 different customer goups :'(

osCommerce MS2

SPPC incl. Specials By Category, Prices By Category

Vendors, Easy Populate, UPS XML, USPS Methods

Link to comment
Share on other sites

Yes, I do plan to add the existing customer base this weekend, all 1026 of them.  :'(

 

Some customers have a flat discount across the board for all products.  I have to come up with a way to handle this.

Perhaps the name of the contribution has made you believe that every customers gets his own pricing. In principle that is possible, but it makes the database very big and don't even think about how the admin pages will become unwieldy.

 

The way this contribution is normally used is that you have certain groups of customers, like retail and wholesale and that each group has its own pricing. What is lacking in SPPC is a way to add a special price for a product or several products for a particular customer (like a contract price for certain items).

 

This could be added by adding an extra table that has a products_id, customers_id and products_price and that could be left joined in a number of queries to get the price correct for this customer in product_info, shopping cart etc.. Getting it right in all specials, new product etc. boxes might be a bit overwhelming.

 

As usual, making the admin pages to add this feature is the hard part.

 

I thought that if a special product ID, such as "*",  was inserted into the product ID field and a discount of 20% for example was in the price field, the special product ID could be tested for this character and the code would assume a product ID match.
I'm afraid I don't follow you here.
Your suggestion is great for a small number of products/few customers, but I don't want to have to run a script and change it for each customer's/group's price updates.
The number of products won't be much of a problem. SQL will be ready with that in seconds.
Link to comment
Share on other sites

I've installed this contribution and it works great. Now I would like to change the navbar to reflect the status of the current user.

 

I have 3 customer groups

1) Retail (if they are not logged in or if they are only a retail customer)

2) Wholesale

3) Authorized Dealers

 

I would like the navbar to display which group the current user is logged in as.

 

So if a retail customer was logged in or if it was a guest, the navbar would display:

Retail | My Account | Cart Contents | Checkout

 

If a wholesale customer was logged in, the navbar would display:

Logged in Wholesale | My Account | Cart Contents | Checkout

 

And, of course an Authorized Dealer would be displayed as:

Logged in Auth Dealer | My Account | Cart Contents | Checkout

 

Can someone help with the code that I need to change the navbar?

 

Thanks in advance for your help.

Link to comment
Share on other sites

Which contribution is the most up to date for this?  I found about 6 in the contribution section and they all seem to be updated at different times.

There is only one SPPC "main" contribution there. Version 4.1.1 with a few bugs still in there is the latest version. The ACA Module that was uploaded last might be interesting for the admin part (haven't checkout out myself, shame on me).

 

There are other contributions that mention SPPC in the name, but those are enhancements/add-ons for this one (like Price Break, show list price, hide products from customer groups, etc.)

Link to comment
Share on other sites

Hello,

 

first off, thanks for this great contribution, which I am just trying to implement for a webshop.

 

I am having some issues though and hope someone can help me out.

 

I am working with a completely clean and new installation of oscommerce. I have installed Seperate Pricing per Customer 4.11 as described in the readme file.

 

When I try to login with a user, that I have created, I get the following error message on a white screen:

 

 

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

 

select customers_group_show_tax, customers_group_tax_exempt from TABLE_CUSTOMERS_GROUPS where customers_group_id = '0'

 

[TEP STOP]

 

When I look at the database itself, I see that table_customers_groups exists.

 

 

 

Second problem is: when I create a new product in the database I am getting the following error when I try to access this product in the oscommerce frontend:

 

Fatal error: Call to undefined function: tep_db_check_age_specials_retail_table() in /home/ur003ned/www/home/shop/index.php on line 155

 

 

Anyone have any ideas, what I am doing wrong?

 

Thanks in advance,

 

:: marcus

Link to comment
Share on other sites

Hi,

 

I am installing version 4.0 and know I have missed one thing, but can not find it..... any help greatly accepted.

 

I have the package installed and It appears to work, I created a friends group and set a new price for 1 item. I then assigned myself to that group and then the product listing is showing the discounted price :-) Problem I have is when I click into the item, product_info.php, is shows the retail price not the dicounted price. If I add it to the cart, the correct price is shown again.

 

What have I missed in the product_Info fine to fix this, I have Diffed between teh supplied and original one and can not see any difference.

 

Thanks in advance.

Link to comment
Share on other sites

I am installing version 4.0
What's wrong with the latest 4.1.1 version?
Problem I have is when I click into the item, product_info.php, is shows the retail price not the dicounted price. If I add it to the cart, the correct price is shown again.

 

What have I missed in the product_Info fine to fix this, I have Diffed between teh supplied and original one and can not see any difference.

Hard to say. If you don't see any difference between the supplied one and your's, why don't you try the supplied one and see if that one work?

 

Otherwise post the first, say 150, lines of that file.

Link to comment
Share on other sites

No, but there is a contribution called Minimum Order Amount that should be easily adaptable to what you want.

 

For example just add some constraint using the customer_group_id:

<?php
// minimum order total
? ?if ($cart->show_total() <= MIN_ORDER_AMOUNT && $customer_group_id != '0' ) {
?>
? ? ?<tr>
? ? ? ?<td class="stockWarning" align="center"><br><?php echo sprintf(TEXT_ORDER_UNDER_MIN_AMOUNT, $currencies->format(MIN_ORDER_AMOUNT)); ?></td>
? ? ?</tr>

 

 

I tried implementing the minimum order quantity like suggested above and it works... almost. Something very odd is happening. The customer ID's seem to be "inverted" the way I implented it. Here is my code: I had to modify it a bit since I am dealing with 2 different minimum order amounts for consumers and retailers.

 

<?php

// minimum order total

if ($cart->show_total() < 1000 && $customer_group_id != '0' ) {

?>

<tr>

<td class="stockWarning" align="center"><br><?php echo sprintf(TEXT_ORDER_UNDER_MIN_AMOUNT, $currencies->format(1000)); ?></td>

</tr>

<?php

}

?>

<?php

// minimum order total

if ($cart->show_total() < 2000 && $customer_group_id != '1' ) {

?>

<tr>

<td class="stockWarning" align="center"><br><?php echo sprintf(TEXT_ORDER_UNDER_MIN_AMOUNT, $currencies->format(2000)); ?></td>

</tr>

<?php

}

?>

 

Retail is 0 in my database, Wholeseller is 1. The minimum amount for Retail is 1000, for Wholeseller it's 2000. The odd thing is that in the shopping cart it's exactly reverse. When I log in as a Retail customer, I get the message that 2000 is the minimum amount, when I log in as a Wholeseller I get 1000 as a minimun. When I switch 0 and 1 in the above code, it is correct.

 

I am not a PHP programmer, I can't explain why this is happening - makes no sense to me and I am worried to just "hack" this so that it works.

 

Any help would be appreciated.

 

Thanks

Link to comment
Share on other sites

I tried implementing the minimum order quantity like suggested above and it works... almost. Something very odd is happening. The customer ID's seem to be "inverted" the way I implented it.

No this is correct since if ($cart->show_total() < 1000 && $customer_group_id != '0' means in plain english: if the total is less than one thousand and the customer group is not equal to 0 (so is 1 if there is only 0 and 1) then ...

 

To make it work like you want you should have used == (means equal in PHP).

<?php
// minimum order total
if ($cart->show_total() < 1000 && $customer_group_id != '0' ) {
?>

Link to comment
Share on other sites

What's wrong with the latest 4.1.1 version?

 

Ummm... Good question. I was hoping that I would get this one working and then look at upgrading to the 4.1.1 version. thinking back not sure if that was sound, but it was very late at night that I was working on this...... :-"

 

Otherwise post the first, say 150, lines of that file.

 

Here is the area of the Products_Info file that I think is causing the issues...... It is the section that queries the DB for the prices and then displays it.

  } else {
$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
$product_info = tep_db_fetch_array($product_info_query);

tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
// BOF Separate Price per Customer

	$scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id =  '" . $customer_group_id . "'");
	if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
	$product_info['products_price']= $scustomer_group_price['customers_group_price'];
}
// EOF Separate Price per Customer

  $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
} else {
// BOF Separate Price per Customer
	$scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id =  '" . $customer_group_id . "'");
	if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
	$product_info['products_price']= $scustomer_group_price['customers_group_price'];
}
// EOF Separate Price per Customer

  $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
}

if (tep_not_null($product_info['products_model'])) {
  $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
} else {
  $products_name = $product_info['products_name'];
}
?>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading" valign="top"><?php echo $products_name; ?></td>
		<td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td>
	  </tr>
	</table></td>
  </tr>

Edited by Gibbo
Link to comment
Share on other sites

Hello, I have installed SSPC 4 to my shopping cart. However, I found the wholesale price is added to cart even though the buyer does not login. It displays the correct retail price on the product info. page. Is there anyone knows which file should I look into to get this solved?! Any somebody can kindly help me out please?! Thanks in advance.

Link to comment
Share on other sites

Here is the area of the Products_Info file that I think is causing the issues...... It is the section that queries the DB for the prices and then displays it.
Looks fine to me. I assume the piece of code that determines the variable $customer_group_id is in the beginning of the file (just above <!doctype htm public etc.)? See below:

	 // BOF Separate Price per Customer
 if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }
  // EOF Separate Price per Customer

Link to comment
Share on other sites

Well, I thought I had this figured out.... :blush:

 

In shopping_cart.php I am distinguishing Retail and Wholesaler customers with this code

 

<?php
// minimum order total
if ($cart->show_total() < 1000 && $customer_group_id == '0') {
?>
  <tr>
	<td class="stockWarning" align="center"><br><?php echo sprintf(TEXT_ORDER_UNDER_MIN_AMOUNT, $currencies->format(1000)); ?></td>
  </tr>
<?php
}
?>

<?php// minimum order total
if ($cart->show_total() < 2000 && $customer_group_id == '1') {
?>
  <tr>
	<td class="stockWarning" align="center"><br><?php echo sprintf(TEXT_ORDER_UNDER_MIN_AMOUNT, $currencies->format(2000)); ?></td>
  </tr>
<?php
}
?>

According to the instructions of the contrib Minimum Price Order you also have to adjust the code in the checkout_confirmation.php, checkout_payment.php, checkout_shipping.php and checkout_process.php files. The code suggested is:

 

// check order total minimum
 if ($order->info['subtotal'] < 1000 ) {
tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'));
 }

Since I also need to check for customer_group_id and have 2 customer groups, I changed it to:

 

// check order total minimum retail
 if ($order->info['subtotal'] < 1000 && $customer_group_id == '0') {
tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'));
 }

// check order total minimum wholesale
 if ($order->info['subtotal'] < 2000 && $customer_group_id == '1') {
tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'));
 }

Well the thing is, that even though the user has not reached the order minimum, he can checkout, i.e. move to the shipping page. If I take out the $customer_group_id == '0' part, the user is prevented from continuing the checkout process.

 

It seems to me as if the $customer_group_id == '0' part gets ignored in the function.

 

What am I missing here? I can't get this to work :(

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