Contributions
Prices for Logged-In Users Only
Provide a new configuration variable: "Allow Guests to See Prices". When 'false', all prices and methods of ordering a disabled unless the user is logged in.
Expand All / Collapse All
Thanks Gosub for a super-simple solution! This is Gosub's excellent "compiled" contribution, all I did was repackage it.
1) Created full package with edited 2.2 RC2a files so all you have to do is copy over your existing files on a fresh OSC install, or use a file compare program (Winmerge, KDiff3, etc) to make edits on a modified installation.
2) Created SQL file that you can import to your database with phpMyAdmin or similar.
3) Updated Install.txt with "Start / End" comments.
Here is a compiled version. Thanks go to original hakers.
This version has only 3 install steps and gives you admin on/off function.
Regards
Gosub
where it says
Upload currencies.php ---> catalog/admin/currecies.php .. ovewrite
it means
Upload currencies.php --->
catalog/includes/classes/currecies.php .. ovewrite
just thought it might help :) as it doesnt work without.
also the english.php is missing but just add
// Login for price
define('LOGIN_FOR_PRICE','Wholsale site Please login for prices'); // login for price
after the
// charset for web pages and emails
define('CHARSET', 'iso-8859-1');
Dont script ur self!!!!
I already dit for u, Download the package and upload the files and Ur Done
:::::::::::::::::::::::::
:: Greetzz Dj IceN::
::::::::::::::::::::::::
I found this problem in the forum:
"after adding the "Prices for Logged-In Users Only" and "restricted_website" contribs, the add to cart button now does not work in the products listing page when a customer is logged in. The customer would need to go into the product information page in order to add the item into the cart. Does have a SSL cert cause this problem? Any suggestions? Which codes do you need to see in order to help me? Thanks in advance."
THE SOLUTION
The problem is that the modifcation made in file APPLICATION_TOP.PHP is incorrect.
FIND THIS CODE:
// customer adds a product from the products page
case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
// performed by the 'buy now' button in product listings and review page
case 'buy_now' : if (isset($HTTP_GET_VARS['products_id'])) {
if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
} else {
$cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
}
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
and REPLACE WITH
// customer adds a product from the products page
case 'add_product' : if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
}
else {
if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
}
break;
// performed by the 'buy now' button in product listings and review page
case 'buy_now' :
if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
}
else {
if (isset($HTTP_GET_VARS['products_id'])) {
if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
} else {
$cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
}
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
}
break;
It should work now (see attachment for full install)
In the shopping cart to the customers not logged appears the price, in order to resolve this bag go to file catalog/includes/classes/shopping_cart.php
FIND THIS CODE:
function show_total() {
$this->calculate();
return $this->total;
}
AND REPLACE WITH THIS CODE:
function show_total($total) {
if (!tep_session_is_registered('customer_id')) {
return '<a href="' . tep_href_link(FILENAME_LOGIN, '', 'SSL') . '">' . LOGIN_FOR_PRICE . '</a>';
} else {
$this->calculate();
return $this->total;
}
}
I have a small bug in the previous file addition.
(This is besides the assumption on my part that the coment field wasn't preformatted.)
It should be checking to see if 'customer_id' is registered in the session, but it checks for 'customers_id' instead.
The attached file is corrected.
Also, I should point out that this obviously only affects price display. It doesn't do the extra stuff with redirecting people to log in -- it just lets them add to the cart and displays the "Please log in to see prices." string there, too.
<p>The shopping cart calls the format() method of the currencies class. The display_price() and display_price2() functions both call it internally.
</p>
<p>
I added this to the top of currencies->format, and it took care of everything:
</p>
<code>
if ( defined( STORE_SHOW_GUESTS_PRICES ) && ( STORE_SHOW_GUESTS_PRICES == 'false' ) && (! tep_session_is_registered('customers_id') ) ) {
return "Please log in to see prices.";
}
</code>
<p>
I should be using a DB config through the admin interface instead of a define()'ed constant. I should also be using a language define instead of a literal string in the code. It's much easier than making a bunch of changes in a bunch of places.
</p>
<p>
The attached file is simply the full code of my version of currency->format().
</p>
EN: By a reference of Simon (thank you for this), I extended the Contrib.
Thus the customer is steered now also with the Button to buy to the Login/for registration.
Search at catalog/includes/application_top.php on Line 354:
// customer adds a product from the products page
case 'add_product' :
// if the customer is not logged on, redirect them to the login page
if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
}
And add afterwards:
// Neu hinzugefügt
case 'buy_now' :
// if the customer is not logged on, redirect them to the login page
if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
}
------------------------------------------
DE: Durch einen Hinweis von Simon (vielen Dank hierfür), habe ich die Contrib erweitert.
Dadurch wird der Kunde auch beim Button Jetzt kaufen zum Login / zur Anmeldung gelenkt.
Suche in catalog/includes/application_top.php ca. Zeile 354:
// customer adds a product from the products page
case 'add_product' :
// if the customer is not logged on, redirect them to the login page
if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
}
Füge nachfolgendes hinzu:
// Neu hinzugefügt
case 'buy_now' :
// if the customer is not logged on, redirect them to the login page
if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
}
EN: I functioned the Contribution Price for Logged In Users Only v4.3 accordingly adapted thereby in connection with Tax info 1.5.2.
At my Shop it works correctly.
DE: Ich habe die Contribution Price for Logged in Users Only v4.3 entsprechend angepasst damit in Verbindung mit Tax Info 1.5.2 diese funktioniert.
Bei mir läuft diese einwandfrei.
just added an official forum adress:
http://forums.oscommerce.com/index.php?showtopic=195046
2.3 : full package added variables utilisation for multilanguage by azer ( azerosc @ gmail.com)
Fixed bug in creation of the login script. Now uses tep_href_link.
Fixed options dropdown. Price for additional options is not displayed unless the user is logged in.
Full package (only one file)
"Login for Price" text is now a link to the store login page.
Full package (which is just one text file anyway).
Ok here it is...
A VERY SIMPLE TWO STEP ONLY SOULTION THAT WORKS FOR oscommerce-2.2ms2!!!
Prices for Logged-In Users Only - Login view price 4.0
All credit goes to the original two authors; I take no credit for whatsoever for this.
All I did was find their listings, combine the two hacks, and compile it here
in the instructions!
~SteelShadow~
RebelStyle.com
I found the first part, Step One of this in the forums posted by Johnson/Matti
This is to return "Login for prices" instead of the amount. This was great but it would
display the products price if you dropped the item into the shopping cart.
I am not sure where I found the second part, Step Two (My apologies to the author) it was
either on the contrib site or the Forums I tried to find it again but had not luck. This
disables the shopping cart if the customer is not logged in by redirecting them to the
login screen if they try to drop something into the shopping cart.
By combining these two simple steps it makes Login view price 4.0 the best solution!
Rewritten for 2.2ms2.
(The Johnson/Matti hack is an elegant solution works well except it does not hide the price when a guest drops a product into their shopping cart)
VERY SIMPLE SOULTION THAT WORKS FOR oscommerce-2.2ms2!!!
Hack the currencies->display_price function to return nothing when the customer_id is not registered i.e. he is not logged on.
This is to the end of catalog/includes/classes/currencies.php:
CODE:
function display_price($products_price, $products_tax, $quantity = 1) {
if (!tep_session_is_registered('customer_id')) {
return "Login For Price";
} else {
return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
}
}
}
?>
THATS ALL!!!
Thanks to Johnson/Matti, this works great and you listed it in the forums so I put it here under your name.
None@none.com
Note:
******This contribution DOES NOT WORK FOR oscommerce-2.2ms2*******
2/13/04 Removed "product quantity" additon from contribution, added all fixes and
EXTREMLY CLEANED UP install instructions for this version
by None <none@none.com>
This fixes four holes in the previous file.
Here we go again. Misunderstood "file title" :o/ Sorry.
Error corrected in description for: catalog/includes/modules/product_listings.php. (missing "}") Gave error in line 150.
This is a modification of Guest_Prices by Gunnar Hellekson, it has been updated to work with
newer version of osc. It hides prices, "Buy now" and "In cart" buttons from customers unless
they are logged in. It also hides any price increase or decrease for options. It is turned on
and off from with in the admin portion of OSC.
This contribution also adds a product quantity field to customer can buy more then one item with out
having to go to the cart to add more then one items. There are some notes on how to remove it in
two place if you do not want this feature.
Provide a new configuration variable: "Allow Guests to See Prices". When 'false', all prices and methods of ordering a disabled unless the user is logged in.
Note: Contributions are used at own risk.