khoking Posted February 8, 2008 Posted February 8, 2008 Hi, My supplier has restriction that I cannot show very low price publicly to visitors of my shop. So, I must hide the price until the customer login. This is only for some selected products, not all products. I do not want to hide price of all my products. Is there such contribution? I know there is a "Prices for Logged-In Users Only": http://www.oscommerce.com/community/contributions,601 But that contribution hide all products prices, which is no good for my shops. Please help... Quote Best regards, Koh Kho King
krnl Posted February 8, 2008 Posted February 8, 2008 (edited) Add a field to your database in the products table called 'products_price_hidden' by going into your database admin area (phpMyAdmin, etc). You can also run this command from the MySQL command line. ALTER TABLE products ADD COLUMN products_price_hidden tinyint(1) DEFAULT 0; The default value for new items added to your store will be "Do not hide" (default to '0'). You can change this to "Hide a new product when it is added" by changing the default value to '1' in the ALTER TABLE above Then in product_info.php find the following: $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_price1, p.products_price2, p.products_price3, p.products_price4, p.products_price1_qty, p.products_price2_qty, p.products_price3_qty, p.products_price4_qty, p.products_qty_blocks, 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 . "'"); replace with: $product_info_query = tep_db_query("select p.products_id, p.products_price_hidden, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_price1, p.products_price2, p.products_price3, p.products_price4, p.products_price1_qty, p.products_price2_qty, p.products_price3_qty, p.products_price4_qty, p.products_qty_blocks, 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 . "'"); Find: <?php echo $products_price; ?> Replace with: <?php if ($product_info['products_price_hidden'] == '1') { echo "Please login for pricing information on this item"; } else { echo $products_price; } ?> Perform similar replacements in index.php for category and manufacturer displays, then update each of the products that you want to hide in the database (let's say you want to hide the price for the product with model number 12345678) with something like: UPDATE products SET products_price_hidden = '1' WHERE products_model = '12345678'; I hope this helps. By the way, this is all off the top of my head with minimal looks at the code. So, this should be considered a starting point. Make sure to back up any files (and your database) before you edit them. I am not responsible for what this may do to your cart. Good luck! :) Edited February 8, 2008 by krnl Quote
c_engine Posted February 24, 2008 Posted February 24, 2008 The default value for new items added to your store will be "Do not hide" (default to '0'). You can change this to "Hide a new product when it is added" by changing the default value to '1' in the ALTER TABLE above Hi Rick. This is brilliant. Is there anyway to allow the admin to select which product to be hidden and which is not. using this method. ie. when they add a new product, a selection saying Tick if you want to hide this products price until login. So when the product is on dispay the price will be hidden. Many Many Thanks for this andi hope to hear from you. Quote
lthown Posted March 12, 2008 Posted March 12, 2008 check out http://addons.oscommerce.com/info/1719 - I just added it my site, works quite well Quote
donnalorr Posted June 27, 2008 Posted June 27, 2008 Hi..This solution is just what I've been looking for. I followed the instructions here to hide the price in terms of running the sql command to create the products_price_hidden column and edited the product_info.php page. So that works great on the Product Info page, however, prices still show up on the index.php page. I know the instructions here said to edit the index.php page similarly, but the code is completely different on this page, so it's not a 1 to 1 edit. Can anyone help me so that the pricing doesn't show up on the index page when the products_price_hidden is set to '1'? An example is shown on http://riverhillapothecary.com/store/index...facturers_id=30 -- the pricing shouldn't be showing up on this page. Thanks very much! Quote
donnalorr Posted June 27, 2008 Posted June 27, 2008 Also, the replace code that for <?php echo $products_price; ?> (the last instruction) returns the user to the login page, but upon login they will be in a loop as far as being able to see the price. So -- how would you make the price display upon login? (on the product info page)? I know the code presented here was "just a start" so if someone could help me in completing it, it would be much appreciated. I'm def not good enough at PHP to finish this up and my client is impatient! thanks! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.