Geotex Posted June 21, 2009 Share Posted June 21, 2009 I should back up - the above is on the one that works - the install I'm having trouble with is on a piece of junk purchased template from template monster. I didn't realize how bad it was until I built my own! last problem I saw was Maybe I'm missing it, but when I hit add to cart with the quantity of each slave it correctly adds the slave but also adds the master! I don't want it to add the master!!! Is this the only problem, or just the current one to solve? You are looking at basically 4 files. Product_info.php, master_products.php, master_listing.php and a small section of application_top.php and maybe a couple of function calls in general.php The SPPC contribution will cause a lot of headaches because of all the convoluted loops the original author did, and was unfortunately kept by all who followed. George Quote GEOTEX from Houston, TX (George) Link to comment Share on other sites More sharing options...
Zappo Posted June 29, 2009 Share Posted June 29, 2009 After using the contribution "Master Products" for quite a while, I found "Master Products" to be overly complicated and very difficult to use or merge alongside other contributions. I wrote this new contribution: "Linked Products", (in combination with an other contribution: "Product Types") you'll get a lot of the same functionality as the "Master Products" contribution. Maybe worth a look? The Linked Products Contribution page can be found here: http://addons.oscommerce.com/info/6842 The support Thread can be found here: http://www.oscommerce.com/forums/index.php?showtopic=339538 Quote Like Eek said... It never hurts to help!---------------------------------------- Link to comment Share on other sites More sharing options...
Geotex Posted June 29, 2009 Share Posted June 29, 2009 After using the contribution "Master Products" for quite a while, I found "Master Products" to be overly complicated and very difficult to use or merge alongside other contributions.I wrote this new contribution: "Linked Products", (in combination with an other contribution: "Product Types") you'll get a lot of the same functionality as the "Master Products" contribution. Maybe worth a look? The Linked Products Contribution page can be found here: http://addons.oscommerce.com/info/6842 The support Thread can be found here: http://www.oscommerce.com/forums/index.php?showtopic=339538 Do you have any working examples of this contribution on line that one can see how the organization works? Quote GEOTEX from Houston, TX (George) Link to comment Share on other sites More sharing options...
Guest Posted July 2, 2009 Share Posted July 2, 2009 (edited) Here is where I'm at. In application_top if I run this code: //Master Products // customer adds multiple products from the master_listing page case 'add_slave' : reset($HTTP_POST_VARS); while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) { if (substr($key,0,11) == "Qty_ProdId_") { $prodId = substr($key,11); $qty = $val; if(isset($HTTP_POST_VARS["id_$prodId"]) && is_array($HTTP_POST_VARS["id_$prodId"])) { // We have attributes $cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId,$HTTP_POST_VARS["id_$prodId"]))+$qty, $HTTP_POST_VARS["id_$prodId"]); } else { // No attributes $cart->add_cart($prodId, $cart->get_quantity($prodId)+$qty); } } } 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; //Master Products EOF The master is added when the slave is. Adding standard products works correctly. If I take out this portion: 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']); } I can add slave products only with no master (so that is correct), but I can no longer add standard products from product_info.php - I can however add products with no attributes from the product listing page and new_products, etc... I don't really understand that bit of code, but the problem definitely seems to be related given the function with and without that bit. Any thoughts on that? Edited July 2, 2009 by desmoworks Quote Link to comment Share on other sites More sharing options...
Zappo Posted July 2, 2009 Share Posted July 2, 2009 Do you have any working examples of this contribution on line that one can see how the organization works? Nope, Sorry... There are however a descent number of screenshots included in the package. Quote Like Eek said... It never hurts to help!---------------------------------------- Link to comment Share on other sites More sharing options...
Geotex Posted July 2, 2009 Share Posted July 2, 2009 Here is where I'm at. In application_top if I run this code: //Master Products I can add slave products only with no master (so that is correct), but I can no longer add standard products from product_info.php - I can however add products with no attributes from the product listing page and new_products, etc... I don't really understand that bit of code, but the problem definitely seems to be related given the function with and without that bit. Any thoughts on that? Most of your code looks good. I am not sure where the lines you add/remove should go, if at all. Here is my complete Shopping Cart Actions in Application_top.php. remember that $_POST may need to be replaced with $HTTP_POST_VARS, etc. if your code overall has not bee updated to use super globals. This code is in use in at least 7 production sites, and works. If it does not work in yours, we may need to look elsewhere for problems. If the denuz txt sections cause a problem, remove them. // Shopping cart actions if (isset($_GET['action'])) { // redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled if ($session_started == false) { tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE)); } if ($_GET['products_set_only']) { tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO . '?products_id=' . $_GET['products_master'])); } if (DISPLAY_CART == 'true') { $goto = FILENAME_SHOPPING_CART; $parameters = array('action', 'cPath', 'products_id', 'pid'); } else { $goto = basename($PHP_SELF); if ($_GET['action'] == 'buy_now') { $parameters = array('action', 'pid', 'products_id'); } else { $parameters = array('action', 'pid'); } } switch ($_GET['action']) { // customer wants to update the product quantity in their shopping cart case 'update_product' : for ($i=0, $n=sizeof($_POST['products_id']); $i<$n; $i++) { if (in_array($_POST['products_id'][$i], (is_array($_POST['cart_delete']) ? $_POST['cart_delete'] : array()))) { $cart->remove($_POST['products_id'][$i]); // denuz text attr // tep_db_query("delete from customers_basket_text_attributes where products_id = " . tep_get_prid($_POST['products_id'][$i]) . " and session_id = '" . $osCsid . "'"); // eof denuz text attr } else { if (PHP_VERSION < 4) { // if PHP3, make correction for lack of multidimensional array. reset($_POST); while (list($key, $value) = each($_POST)) { if (is_array($value)) { while (list($key2, $value2) = each($value)) { if (ereg ("(.*)\]\[(.*)", $key2, $var)) { $id2[$var[1]][$var[2]] = $value2; } } } } $attributes = ($id2[$_POST['products_id'][$i]]) ? $id2[$_POST['products_id'][$i]] : ''; } else { $attributes = ($_POST['id'][$_POST['products_id'][$i]]) ? $_POST['id'][$_POST['products_id'][$i]] : ''; } $cart->add_cart($_POST['products_id'][$i], $_POST['cart_quantity'][$i], $attributes, false); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; // customer adds a product from the products page case 'add_product' : if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) { $cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+$quantity, $_POST['id']); // denuz text attr // tep_db_query("delete from customers_basket_text_attributes where products_id = " . $_POST['products_id'] . " and session_id = '" . $osCsid . "'"); // $attr_query = tep_db_query("select * from products_text_attributes_enabled where products_id = " . $_POST['products_id']); // while ($attr = tep_db_fetch_array($attr_query)) { // tep_db_query("insert into customers_basket_text_attributes values ('$osCsid', " . $_POST['products_id'] . ", " . $attr['products_text_attributes_id'] . ", '" . addslashes($_POST['products_text_attributes_' . $attr['products_text_attributes_id']]) . "');"); } // eof denuz text attr } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; //Master Products // customer adds multiple products from the master_listing page case 'add_slave' : reset($_POST); while ( list( $key, $val ) = each( $_POST ) ) { if (substr($key,0,11) == "Qty_ProdId_") { $prodId = substr($key,11); $qty = $val; if(isset($_POST["id_$prodId"]) && is_array($_POST["id_$prodId"])) { // We have attributes $cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId,$_POST["id_$prodId"]))+$qty, $_POST["id_$prodId"]); } else { // No attributes $cart->add_cart($prodId, $cart->get_quantity($prodId)+$qty); } } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; //Master Products EOF // performed by the 'buy now' button in product listings and review page case 'buy_now' : if (isset($_GET['products_id'])) { if (tep_has_product_attributes($_GET['products_id'], (int)$languages_id)) { tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['products_id'])); } else { $cart->add_cart($_GET['products_id'], $cart->get_quantity($_GET['products_id'])+1); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; case 'notify' : if (tep_session_is_registered('customer_id')) { if (isset($_GET['products_id'])) { $notify = $_GET['products_id']; } elseif (isset($_GET['notify'])) { $notify = $_GET['notify']; } elseif (isset($_POST['notify'])) { $notify = $_POST['notify']; } else { tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify')))); } if (!is_array($notify)) $notify = array($notify); for ($i=0, $n=sizeof($notify); $i<$n; $i++) { $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'"); $check = tep_db_fetch_array($check_query); if ($check['count'] < 1) { tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())"); } } tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify')))); } else { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } break; case 'notify_remove' : if (tep_session_is_registered('customer_id') && isset($_GET['products_id'])) { $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $_GET['products_id'] . "' and customers_id = '" . $customer_id . "'"); $check = tep_db_fetch_array($check_query); if ($check['count'] > 0) { tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $_GET['products_id'] . "' and customers_id = '" . $customer_id . "'"); } tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')))); } else { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } break; case 'cust_order' : if (tep_session_is_registered('customer_id') && isset($_GET['pid'])) { if (tep_has_product_attributes($_GET['pid'])) { tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['pid'])); } else { $cart->add_cart($_GET['pid'], $cart->get_quantity($_GET['pid'])+1); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; } } Quote GEOTEX from Houston, TX (George) Link to comment Share on other sites More sharing options...
jasonabc Posted July 10, 2009 Share Posted July 10, 2009 Hi guys - I have a scenario and am wondering if Master Products (or Linked Products) is the solution? I need to "attach" a product with another product when an item is purchased? Lets say, for example, that if you buy product A you would also need to buy product B. Is there any way to put both product A and product B into the cart when you click "buy me" on product A? thanks! Jason Quote Jason My Contributions: Paypal Payflow PRO | Rollover Category Images | Authorize.net Invoice Number Fix Link to comment Share on other sites More sharing options...
Geotex Posted July 10, 2009 Share Posted July 10, 2009 Hi guys - I have a scenario and am wondering if Master Products (or Linked Products) is the solution? I need to "attach" a product with another product when an item is purchased? Lets say, for example, that if you buy product A you would also need to buy product B. Is there any way to put both product A and product B into the cart when you click "buy me" on product A? thanks! Jason I am not familiar with linked products. It is too new, and appears to still be in Alpha stage. Master products can do the job, but not out of the box. Once you get it installed and working, you can mod it to sell sets only. I have done that, an example is on my live test site, www.designerdogregistry.com. You can see the options in Holly Cow category, standard - Master Test Cow, set only - Master Set of Cow Parts. Clicking on any individual part of either will take you to the appropriate Master. This is a test site, so any purchases made will not be processed. Quote GEOTEX from Houston, TX (George) Link to comment Share on other sites More sharing options...
Geotex Posted July 10, 2009 Share Posted July 10, 2009 update, I waited too long to edit. I am in the process of switching all http_*_vars to super globals, so some strange things occasionally happen until the transition is complete. Things do not always work the same on the web as they do on the local site. That is why I have a live test site. Quote GEOTEX from Houston, TX (George) Link to comment Share on other sites More sharing options...
concorde44 Posted August 18, 2009 Share Posted August 18, 2009 Hi everybody, I'm using this contrib for quite a while with success but I need a function I dont know how to do : to link a slave to many master products. I had to change the query from includes/modules/master_products.php . Original was : $master_query = tep_db_query("select products_master from " . TABLE_PRODUCTS . " where products_master LIKE '%" . $HTTP_GET_VARS['products_id'] . "%'"); with $master_query = tep_db_query("select products_master from " . TABLE_PRODUCTS . " where products_master = " . $HTTP_GET_VARS['products_id']); but with my change the salve product can not be linked to many master products. I did it because with the original query " LIKE %54% " (54 is an example) it will link the slave to any master with product id like 54 or 254 or 543 etc... Is there a way to add on the product info page the master products wished like 54, 213, 567 or only separate with space and then have a slave linked to many masters ? thanks. Seb Quote Osc 2.2 MS2 Link to comment Share on other sites More sharing options...
concorde44 Posted August 20, 2009 Share Posted August 20, 2009 Hi again! Found it! Solution is on the Contribution page of this mod. I added the fix by A4kquattro "Multiple Masters per Slave - Updated SQL" And works like a charm : multiple masters per slave, even with space separated value. Quote Osc 2.2 MS2 Link to comment Share on other sites More sharing options...
mongomike Posted September 17, 2009 Share Posted September 17, 2009 This is a great contribution. I am however experiencing one problem. If I have two Masters one with a Product ID of '12344' and another with the Product ID of '344' and then assign one of these masters with a slave for some reason both of these masters end up with this slave. It would seem that if 2 (or more) masters have the same sequence of numbers then this problem arises. The problem I have is that I have thousands of products in my store and obviously don't want master products ending up with slave products which have absolutely nothing to do with them. Apologies if this has been covered before... Anyone Any Ideas? Quote Link to comment Share on other sites More sharing options...
concorde44 Posted September 17, 2009 Share Posted September 17, 2009 Hi, I had the same problem. See the 2 above posts from me. I think the answer is here. Have you already tried to modifiy the $master_query ? Quote Osc 2.2 MS2 Link to comment Share on other sites More sharing options...
mongomike Posted September 18, 2009 Share Posted September 18, 2009 Hi, I had the same problem.See the 2 above posts from me. I think the answer is here. Have you already tried to modifiy the $master_query ? thanks alot seb works like a charm. Don't suppose you know how to set the masters to have unlimited slaves. I think they can only have 7-10 by default? Quote Link to comment Share on other sites More sharing options...
concorde44 Posted September 18, 2009 Share Posted September 18, 2009 Hi, I think it is a limitation in the SQL database. Got to Phpmyadmin : in the "products" table, modifiy the "products_master" type with more characters than 50 be sure to backup before. you can put VARCHAR 512 for example. Try it and let me know! Seb Quote Osc 2.2 MS2 Link to comment Share on other sites More sharing options...
mongomike Posted September 18, 2009 Share Posted September 18, 2009 Hi,I think it is a limitation in the SQL database. Got to Phpmyadmin : in the "products" table, modifiy the "products_master" type with more characters than 50 be sure to backup before. you can put VARCHAR 512 for example. Try it and let me know! Seb Seb, Again... Works like a charm.. I think the max is 255.. You just saved me hours of creating multiple masters! Many Thanks Quote Link to comment Share on other sites More sharing options...
concorde44 Posted September 18, 2009 Share Posted September 18, 2009 (edited) Happy for you. Not good at Sql ! But 255 is still low... may be changing the type VARCHAR by Text could be unlimited. Seb Edited September 18, 2009 by concorde44 Quote Osc 2.2 MS2 Link to comment Share on other sites More sharing options...
mongomike Posted September 22, 2009 Share Posted September 22, 2009 Happy for you. Not good at Sql ! But 255 is still low... may be changing the type VARCHAR by Text could be unlimited. Seb Hey Seb, Thanks for your help on this. I don't suppose you know how to hide slaves from search result page? I Can hide them on the category pages but they are still appearing in the the search results. Any Ideas? Quote Link to comment Share on other sites More sharing options...
Terry Mitchell Posted September 29, 2009 Share Posted September 29, 2009 Hi dickydixon, I am using digital music downloads for this example here. Actually it's not too difficult depending on how you have stuff set up. What I did is have 2 separate forms on the product_info.php page each with it's own add to cart button. One to post the Master Product (e.g. if you have an album and just want to add the album) The second to post the Slave Products (e.g if you want to select just a couple of tracks from the album) To allow only one Product to be bought. 1. The first form around the master product, I have the form pass the default post action of action=add_product (which is the default action in the unmodified Os commerce installation) and I uncomment the lines that draws the pull down menu which is ( tep_draw_pull_down_menu('Qty_ProdId_' . $product_info['products_id'], $qty_array) ; ) To add checkboxes to the Slave products instead of the pull down menu do this. Resources with information to do this tasks. 1.) The catalog/includes/modules/master_listing.php page builds the Slave Products layout. 2.) The catalog/includes/functions/html_output.php contains the functions to build various form elements from form fields to hidden fields etc. In the catalog/includes/modules/master_listing.php look for the switch statement with the case " case 'MASTER_LIST_BUY_NOW': " That switch statement builds the pull down menue of the slave listings. "Comment Out" or delete it and replace it with case 'MASTER_LIST_BUY_NOW': $lc_align = 'center'; $lc_valign = 'top'; $lc_text = tep_draw_checkbox_field('Qty_ProdId_' . $listing['products_id'], $value = (int)1); break; The important variable is the $lc_text which contains the call to the function located in the catalog/includes/functions/html_output.php page to output a checkbox field. That's it and you're doen . Have fun. Investigate the functions in the catalog/includes/functions/html_output.php for other variable you can pass to that function such as have the checkbox checked by default etc. Hope it helps. Hi All (particularly Top Rasta if you're still around as this seems to be your area of expertise) I've got Master Products up and running fine but it seems to be passing over my downloadable products (mp3's) as physical products and therefore the downloads are not available at the end of the process...And it adds shipping!! I'm a semi newbie at this and can't quite figure out where to look to fix this problem - does anyone have any advice as I'm pulling my hair out over this. Please, help before I lose what little hair I have left!! Thanks Terry Quote Link to comment Share on other sites More sharing options...
quattro80 Posted October 3, 2009 Share Posted October 3, 2009 hi guys... can somebody help me plz... i just followed the instructions and i have this fatal error... :( Fatal error: Cannot redeclare currencies::display_price() in /mnt/web3/41/72/52142672/htdocs/admin/includes/classes/currencies.php on line 83 Quote Link to comment Share on other sites More sharing options...
Terry Mitchell Posted October 5, 2009 Share Posted October 5, 2009 Hi Guys Big problem with Master Products returning product type as physical rather than virtual. Been working with oscommerce for some time now and have a vague idea of what's going on. I installed Master Products on my mp3 downloads site for the obvious reason of the option to sell lp's or individual tracks. The only problem is that all Master products are being sent to the shopping cart as physical rather than virtual product and therefore the download links aren't showing and shipping is being added. Does anybody have any idea on how to change the product type being sent to checkout?? I'm using Super Downloads Store too, I'm aware that this may present some problems. Please, if anyone could help me it would be much appreciated - I've spent days scouring this forum. Thanks in advance. Terry Quote Link to comment Share on other sites More sharing options...
Terry Mitchell Posted October 8, 2009 Share Posted October 8, 2009 Anybody??....Please?? Quote Link to comment Share on other sites More sharing options...
chipo Posted October 21, 2009 Share Posted October 21, 2009 Hi, I have now installed Master Products - MS2, and also find it quite good. However disturbs me that we as a slave assigned products only to buy under the master product and no-longer appears as a standalone product in the catalog. Although now have already get this done now, the slaves re-emerge in the categories, but with a click on the BuyNow button to return lands to the master product. Quote Link to comment Share on other sites More sharing options...
Terry Mitchell Posted October 25, 2009 Share Posted October 25, 2009 Hi, I have now installed Master Products - MS2, and also find it quite good. However disturbs me that we as a slave assigned products only to buy under the master product and no-longer appears as a standalone product in the catalog. Although now have already get this done now, the slaves re-emerge in the categories, but with a click on the BuyNow button to return lands to the master product. Hi Chipo I'm having the same problem I need the products to appear as a standalone product as well as a "Slave". Did you manage to fix this?? Does anybody else have any ideas how to work around this?? Thanks Terry Quote Link to comment Share on other sites More sharing options...
Guest Posted October 27, 2009 Share Posted October 27, 2009 Did anyone ever figure out how to display "from $X.XX" or "starting at $X.XX" on the master listing based on the lowest priced slave product? I've been playing around with currencies.php, but haven't had any luck yet. I tried to search, but with the new forum layout searching is ridiculously hard. Quote Link to comment Share on other sites More sharing options...
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.