Jump to content
Skittles

Optional Related Products, Version 4.0

Recommended Posts

Basically i would like for the related products to show after adding the item to your cart. So in my case you would add the product (flooring) to your cart and at that point it would show what products (trim) are avilable for that product. Hope you understand. Thanks

tpboles,

 

Yes, I understand what you are looking for.

 

The problem that arises from putting Related Products on the cart page comes when there are multiple items in the cart. Which product_id do you use for the module? If it's always the last one, how do you make sure the last item added is the item used for the module? What happens if they add one of the Related Products? Will the module then display Related Products for, in your case, the selected trim?

 

Okay, none of that means it isn't possible, just that there are a lot of variables that come into play. Which means there is a lot of coding involved over and above just adding the contribution.

 

One possibility that would be fairly easy to implement would be to create a separate page to display all the Related Products of any given product_id, (like Whitespliff was looking for,) then add code to the cart page that includes a link to that page for each product. The link would pass the product_id to the new page. If the customer was interested, they would click on the link.

 

The code on the cart page could look for any related products for each item in the cart and if there weren't any, just not add the link...

 

Another possibility would be to create an "interim" cart page. When the customer adds a product to the cart, have them sent to a page which indicates the item has been added to the cart, with the related products below the item. Give the customer the opportunity to then continue to the complete cart, select a related product, or continue shopping to return to the previous page. This solution would entail a lot more programming changes than the previous one.

 

So I guess the real question is, how good are your php skills? If this isn't something you can do on your own, you will need to hire someone to do it for you.

 

I doubt that is something you want to hear, but any solution requires way too much work for me to put paying clients on hold while I add new and significant functionality to a free contribution. (If you'd like me to quote a price, send me a PM...)

 

On the other hand, if you decide to tackle this yourself, I'll be happy to be a resource for you.

 

Good luck,

-Skittles

Share this post


Link to post
Share on other sites
Basically i would like for the related products to show after adding the item to your cart. So in my case you would add the product (flooring) to your cart and at that point it would show what products (trim) are avilable for that product. Hope you understand. Thanks

 

I think I've got what you are looking for.

 

Add this item to the cart:

 

http://www.printzone.com.au/product_info.p...roducts_id=3773 (should go straight to shopping cart after clicking 'Add to Cart' button)

 

Look underneath the delivery car graphic.

 

You can add some of the related items, and then they disappear from the related items list. Remove them from the shopping cart and they go back on the list.

 

Try adding another product to your shopping cart (like http://www.printzone.com.au/product_info.p...oducts_id=1813), and then there are related items for that item too.

 

I think I can package it up and add it to the contribution.


Let's make things easier for new osCommerce users http://forums.oscommerce.com/topic/402638-discussion-about-hard-coded-database-tables/?p=1718900  Getting there with osCommerce 2.4! :thumbsup:

Share this post


Link to post
Share on other sites
I think I've got what you are looking for.

 

Add this item to the cart:

 

http://www.printzone.com.au/product_info.p...roducts_id=3773 (should go straight to shopping cart after clicking 'Add to Cart' button)

 

Look underneath the delivery car graphic.

 

You can add some of the related items, and then they disappear from the related items list. Remove them from the shopping cart and they go back on the list.

 

Try adding another product to your shopping cart (like http://www.printzone.com.au/product_info.p...oducts_id=1813), and then there are related items for that item too.

 

I think I can package it up and add it to the contribution.

 

Hey Frankl

 

That is exactly what I am looking for except I would rather have a qty box for each related product and one add to cart button at the bottom of the related products. I currently have some guys working on this for me (sorry skittles - didn't see your post till after i hired them). Thanks for the info frankl!

Edited by tpboles

Share this post


Link to post
Share on other sites

tpboles,

 

I'm happy to see you hired some coders. I'm available to you and your coders as a resource, if you need me.

 

 

frankl,

 

That is a very interesting variation! I think it is a wonderful idea to add it to the contribution. Would it be possible to set up like the Graphical Borders option? Where the user installs the base contribution, then finds everything s/he needs for the variation in a separate folder?

 

Or is this something that should be uploaded as a separate contribution?

 

I'd love to see the code.

 

Kudos to you both,

-Skittles

Share this post


Link to post
Share on other sites
tpboles,

 

I'm happy to see you hired some coders. I'm available to you and your coders as a resource, if you need me.

 

 

frankl,

 

That is a very interesting variation! I think it is a wonderful idea to add it to the contribution. Would it be possible to set up like the Graphical Borders option? Where the user installs the base contribution, then finds everything s/he needs for the variation in a separate folder?

 

Or is this something that should be uploaded as a separate contribution?

 

I'd love to see the code.

 

Kudos to you both,

-Skittles

 

I would be very interested to see this too. Skittles for your reference here is where we are right now (test server- so some of the pics are missing) houseracket.com/floor/catalog/product_info.php?products_id=2231 this product has related products. As you can see the related products do not show on the products page, but if you add the product to the cart it shows the related products in the cart. We are now fixing the related products so you can add several with one add to cart button. On a side note, sortof got a one page checkout working using the checkout_alternative contrib (the contrib doesnt functions as is we had to modify it). You are welcome to try the checkout (as I said it is a test server). Thanks again for the info

Share this post


Link to post
Share on other sites
tpboles,

 

I'm happy to see you hired some coders. I'm available to you and your coders as a resource, if you need me.

 

 

frankl,

 

That is a very interesting variation! I think it is a wonderful idea to add it to the contribution. Would it be possible to set up like the Graphical Borders option? Where the user installs the base contribution, then finds everything s/he needs for the variation in a separate folder?

 

Or is this something that should be uploaded as a separate contribution?

 

I'd love to see the code.

 

Kudos to you both,

-Skittles

 

Hi Anita, this is something based entirely on your code, so really full credit is yours :rolleyes: . I just added a few lines!! It is quite simple, just cycles through products in the cart to see if there are any related items (and checks to see if they are already in the cart or not), if there is something to display, it does. I saved this file as related_products_cart.php in the ../includes/modules/ folder and called it in shopping_cart.php with include(DIR_WS_MODULES . 'related_products_cart.php');.

 

This needs your contrib istalled first, so it would be best as an addon.

 

<?php

/*
 $Id: optional_related_cart.php, ver 1.0 02/05/2007 Exp $

 Based on code from Contribution: Optional Related Products Ver 4.0
 Copyright © 2007 Anita Cross (http://www.callofthewildphoto.com/)

 Based on code from Optional Relate Products, ver 2.0 05/01/2005
 Copyright © 2004-2005 Daniel Bahna (daniel.bahna@gmail.com)

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

 Released under the GNU General Public License
*/
?>
<?php
//first see if there are any related products to display, if not - show nothing
$productid_array = array();
for ($i=0, $n=sizeof($products);$i<$n; $i++) {
 $productid_array[$i] = $products[$i]['id'];
}

 $orderBy = 'ORDER BY ';
 //$orderBy .= (RELATED_PRODUCTS_RANDOMIZE)?'rand()':'pop_order_id, pop_id';
 $orderBy .= (false)?'rand()':'pop_order_id, pop_id';
 $orderBy .= (RELATED_PRODUCTS_MAX_DISP)?' limit ' . RELATED_PRODUCTS_MAX_DISP:'';

for ($i=0; $i<$n; $i++) {

 $attributes = "
        SELECT
        pop_products_id_slave,
        products_name,
        products_model,
        products_price,
        products_quantity,
        products_tax_class_id,
        products_image
        FROM " .
        TABLE_PRODUCTS_RELATED_PRODUCTS . ", " .
        TABLE_PRODUCTS_DESCRIPTION . " pa, ".
        TABLE_PRODUCTS . " pb
        WHERE pop_products_id_slave = pa.products_id
        AND pa.products_id = pb.products_id
        AND language_id = '" . (int)$languages_id . "'
        AND pop_products_id_master = '". $products[$i]['id'] ."'
        AND products_status='1' " . $orderBy;
 $attribute_query = tep_db_query($attributes);

 if (mysql_num_rows($attribute_query)==0) {
?>

<?php
 } else {
 //if there are related products, let's show the header
 ?>
<tr>
 <td>
   <table class="productlisting" border="0" cellspacing="0" cellpadding="2" width="100%">
   <tr>
     <td align="left" class="xsellcart"> <?php echo tep_image(DIR_WS_ICONS . 'success.gif', HEADING_TITLE, '10','10' ); ?> <?php echo TEXT_RELATED_PRODUCTS ?> </td>
   </tr>
<?php
//now we'll get a list of the products in the cart
$productid_array = array();
for ($i=0, $n=sizeof($products);$i<$n; $i++) {
 $productid_array[$i] = $products[$i]['id'];
}

 $orderBy = 'ORDER BY ';
 //$orderBy .= (RELATED_PRODUCTS_RANDOMIZE)?'rand()':'pop_order_id, pop_id';
 $orderBy .= (false)?'rand()':'pop_order_id, pop_id';
 $orderBy .= (RELATED_PRODUCTS_MAX_DISP)?' limit ' . RELATED_PRODUCTS_MAX_DISP:'';
//now we'll cycle through the list of products in the cart
for ($i=0; $i<$n; $i++) {

//this is the query 
 $attributes = "
        SELECT
        pop_products_id_slave,
        products_name,
        products_model,
        products_price,
        products_quantity,
        products_tax_class_id,
        products_image
        FROM " .
        TABLE_PRODUCTS_RELATED_PRODUCTS . ", " .
        TABLE_PRODUCTS_DESCRIPTION . " pa, ".
        TABLE_PRODUCTS . " pb
        WHERE pop_products_id_slave = pa.products_id
        AND pa.products_id = pb.products_id
        AND language_id = '" . (int)$languages_id . "'
        AND pop_products_id_master = '". $products[$i]['id'] ."'
        AND products_status='1' " . $orderBy;
 $attribute_query = tep_db_query($attributes);

 if (mysql_num_rows($attribute_query)>0) {
 $count = 0;
}
?>
<tr>
     <td align="left" class="productListing-data">
       <table border="0" cellspacing="0" cellpadding="2" width="100%" align="center">

<?php
   while ($attributes_values = tep_db_fetch_array($attribute_query)) {
//if it's already in the cart, there is no need to display it, right?
	if (!in_array($attributes_values['pop_products_id_slave'], $productid_array)) {
array_push($productid_array, $attributes_values['pop_products_id_slave']);
//make a list of related products	
     $products_name_slave = ($attributes_values['products_name']);
     $products_model_slave = ($attributes_values['products_model']);
     $products_qty_slave = ($attributes_values['products_quantity']);
     $products_id_slave = ($attributes_values['pop_products_id_slave']);
     if ($new_price = tep_get_products_special_price($products_id_slave)) {
       $products_price_slave = $currencies->display_price($new_price, tep_get_tax_rate($attributes_values['products_tax_class_id']));
     } else {
       $products_price_slave = $currencies->display_price($attributes_values['products_price'], tep_get_tax_rate($attributes_values['products_tax_class_id']));
     }
     echo '' . "\n";
     // show thumb image if Enabled
     if (RELATED_PRODUCTS_SHOW_THUMBS == 'True') {
       echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">' . "\n"
            . tep_image(DIR_WS_IMAGES . $attributes_values['products_image'], $attributes_values['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"').'</a> ' . "\n";
     }
     $caption = '';
     if (RELATED_PRODUCTS_SHOW_NAME == 'True') {
       $caption .= '<tr><td class="productListing-data" align="left"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '" title="Click for more info">' .  $products_name_slave . '</a>';
       if (RELATED_PRODUCTS_SHOW_MODEL == 'True') {
         $caption .= sprintf(RELATED_PRODUCTS_MODEL_COMBO, $products_model_slave);
       }
       $caption .= '</td>' . "\n";
     } elseif (RELATED_PRODUCTS_SHOW_MODEL == 'True') {
       $caption .=  '<p>' . $products_model_slave . '</p>' . "\n";
     }
     if (RELATED_PRODUCTS_SHOW_PRICE == 'True') {
       $caption .= '<td class="productListing-data" align="right"> ' . sprintf(RELATED_PRODUCTS_PRICE_TEXT, $products_price_slave) . '</td>' . "\n";
     }
     if (RELATED_PRODUCTS_SHOW_QUANTITY == 'True') {
       $caption .= '<p>' . sprintf(RELATED_PRODUCTS_QUANTITY_TEXT, $products_qty_slave) . '</p>' . "\n";
     }
     echo '<a href="'
					. tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">'
					. $caption . '</a>' . "\n";
     if (RELATED_PRODUCTS_SHOW_BUY_NOW== 'True') {
       echo '<td class="productListing-data" align="left" width="15%">  <a href="'
					. tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))
					. 'action=rp_buy_now&rp_products_id=' . $products_id_slave) . '" title="Add to cart">'
					. RELATED_PRODUCTS_BUY_NOW_TEXT . '</a></td>';
     }
     echo '</tr>' . "\n";
     $count++;
     if ((RELATED_PRODUCTS_USE_ROWS == 'True') && ($count%RELATED_PRODUCTS_PER_ROW == 0)) {
       echo '</tr>' . "\n";
     }
   }
}

?>
       </tr></table>
		<?php
}
//}
?>
     </td>
   </tr></table>
 </td>

</tr>
<?php
}
}
?>

 

If anyone can see any improvements which can be made before adding it to the contrib, please show them below!


Let's make things easier for new osCommerce users http://forums.oscommerce.com/topic/402638-discussion-about-hard-coded-database-tables/?p=1718900  Getting there with osCommerce 2.4! :thumbsup:

Share this post


Link to post
Share on other sites

Where in shopping_cart.php did you insert include(DIR_WS_MODULES . 'related_products_cart.php'); ?

Share this post


Link to post
Share on other sites

Don't forget to include instructions on updating the defines in the shopping cart language file. This is a great addition. I kinda wish the "also purchased" routine would run on the shopping cart page as well (I'm sure it could be made to run on that page but coding it is beyond me).

Share this post


Link to post
Share on other sites
Don't forget to include instructions on updating the defines in the shopping cart language file. This is a great addition. I kinda wish the "also purchased" routine would run on the shopping cart page as well (I'm sure it could be made to run on that page but coding it is beyond me).

 

Good points. success.gif normally lives in /admin/images/icons/ (I just copied it to /catalog/images/icons/)

 

Defines need to be added to /includes/languages/YOUR-LANGUAGE-FOLDER/shopping_cart.php:

 

/* Optional Related Products (ORP) */
define('TEXT_RELATED_PRODUCTS', 'You may also be interested in...');
define('RELATED_PRODUCTS_MODEL_COMBO', ' (%s)');
define('RELATED_PRODUCTS_PRICE_TEXT', '<font color="ff0000"><b> %s</b></font>');
define('RELATED_PRODUCTS_QUANTITY_TEXT', 'Only %s left!');
define('RELATED_PRODUCTS_BUY_NOW_TEXT', '    Add to Cart');

 

Anything else?


Let's make things easier for new osCommerce users http://forums.oscommerce.com/topic/402638-discussion-about-hard-coded-database-tables/?p=1718900  Getting there with osCommerce 2.4! :thumbsup:

Share this post


Link to post
Share on other sites

I eliminated the icon (success.gif) after trying the right arrow instead, but if I kept an image, I'd be inclined to use some text other than HEADING_TITLE (maybe create a text specific to that image).

 

I turned the buy now button on in admin and tested mine....it didn't work (add to cart showed but clicking it did not add it to the cart). I'll be troubleshooting it later (I mention it just in case somebody knows exactly what I need to do and can point me in the right direction).

Share this post


Link to post
Share on other sites
I turned the buy now button on in admin and tested mine....it didn't work (add to cart showed but clicking it did not add it to the cart). I'll be troubleshooting it later (I mention it just in case somebody knows exactly what I need to do and can point me in the right direction).

I didn't have the code in application_top. All better now.

Share this post


Link to post
Share on other sites

When I add a product (product 1) to my cart, the related product (product 2) shows up in the related product box. If I then add product 2 to my cart, the related product box (now empty except for the text) still shows.

Edited by baddog

Share this post


Link to post
Share on other sites

We are near completion on the realted products in cart mod. You can go here and add a product to the cart and see how we formatted it houseracket.com/floor/catalog/product_info.php?products_id=2231 (again this is a test server). I could not thank you enough for the original contribution for related products. Thanks again

Share this post


Link to post
Share on other sites

Great contribution.

 

Quick question -

 

I was wanting a Horizontal product layout. I have seen this on several sites

 

anyone know how to accomplish this with the latest version, or can point me in the right direction??

Share this post


Link to post
Share on other sites
Great contribution.

 

Quick question -

 

I was wanting a Horizontal product layout. I have seen this on several sites

 

anyone know how to accomplish this with the latest version, or can point me in the right direction??

jond,

 

The layout is essentially controlled by options in the Configuration: "Define Number of Items Per Row", "Define Number of Items to Display", and "Split Display Into Rows".

 

"Split Display Into Rows" should be set to 'true' for multiple rows.

 

Any number greater than 1 in the "Define Number of Items Per Row" will produce a Horizontal (left to right) display of products.

 

To get a Vertical (top to bottom) display, set the "Define Number of Items Per Row" to 1, then use the "Define Number of Items to Display" to set the total products displayed. For example, if you want 3 products showing, set the "Define Number of Items to Display" to 3.

 

Horizontal works well under the product listing, while vertical works well in the right or left column.

 

-Skittles

Share this post


Link to post
Share on other sites

thanks for the info.

 

I was looking for more of a Top to Bottom display like in products_new or the standard category pages, where the names of the product extends horizontally, Image is on left of text and Buy Now button is on the right of the product name, etc

 

Any ideas???

Share this post


Link to post
Share on other sites
thanks for the info.

 

I was looking for more of a Top to Bottom display like in products_new or the standard category pages, where the names of the product extends horizontally, Image is on left of text and Buy Now button is on the right of the product name, etc

 

Any ideas???

jond,

 

Try downloading Optional Related Products 3.0.1 from the contribution page. It looks like that was the last version before the layout was changed from a product listing type display. You will need to integrate the options from version 4 with the old layout.

 

Keep us posted as to how it's going, and ask questions here if you get stuck.

 

-Skittles

Share this post


Link to post
Share on other sites

Hello,

 

I'm stuck here...

 

open your Admin console and go to Catalog->Related Products. (In the left column navigation, click on Catalog. The navigation will change to display all the installed features available to maintain Catalog. Click on Related Products.)

 

Related Products Button

 

The SQL Setup Utility will open automatically the first time you open this page...

 

All I'm seeing is a blank page. I'm going cross-eyed trying to find my mistake. I've redone this twice. Any assist would be appreciated.

Share this post


Link to post
Share on other sites

For anyone following along with this thread, Kona Bean contacted me by PM and we discovered the source of his problem. Somehow, he managed to be working from version 3.3-c instead of 4.0. After jumping through a couple of hoops, he has it up and running.

 

-Skittles

Share this post


Link to post
Share on other sites

Hi, this looks like a great contribution. If my question is answered in your installation and other instructions then I missed it, apologies.

 

We sell cardboard boxes that can be screen printed in three colors if a customer so desires. We have two charges for that, a setup charge for each color and then a printing charge for each box.

 

Can this contribution link the number of boxes and printing charges so that if a customer buys 15 boxes and selects screen printing they then are charged printing x 15 without having to type in the number purchased again?

 

We found that if people have to type in the figure again then many forget to do so, selecting 15 boxes and just one printing charge!

 

Peter

Share this post


Link to post
Share on other sites
Hi,

 

I think you may also have to change the name of the table from products_options_products to products_related_products.

 

Hope that helps, it's just part of the sql_setup_related_products.php file.

 

Joseph

 

 

I have the same problem and can't sort it out, can anyone shed some light on how to set the permissions?

 

Thanks,

Share this post


Link to post
Share on other sites

Greetings,

 

Installed the Related Products contribution and logging into the Admin section and then Catalog, the 'Related Products' link is the only entry in the section. Is this correct?

 

grab_01.jpg

 

 

The only way to access the other menu items is to go back to the admin homepage and select them there.

 

Thanks, Penge

Share this post


Link to post
Share on other sites
My customer just found an error in the Module. When you open the product with the related products, click on "Buy Now" on any of those related products, it will send you to your basket. Press "Continue Shopping". It will send you back to the same product page with product, that you bought, is still in the related products area. Now try to buy any of other related products with their "buy now" button - it will add one more product to your basket, which will be the same as previous one. The problem is in module file, line 92:

. tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))

it should be

. tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'rp_products_id'))

 

because when you click "Continue Shopping", you are sent back to the same address _plus_ rp_products_id parameter. It might be problems because of this module mixed with SEO modules, I have no idea.

 

Have you find a solution for this Problem?

 

Andreas

Share this post


Link to post
Share on other sites

Great Contribution, no problems with the install for me.

 

The one thing I'd like to ask about/suggest is a way to have the lists display in Alphabetic/Numeric Order. When pairing products, they seem to display by the order of their record number which make finding the one item you want to relate to the master item kind of hard. I think this would be just a simple sort order in the display function, but I'm no SQL guru.

 

Edit: Oh--is there any way to mass-import/export related products via CSV files? That would make what I'm doing a snap.

 

Thanks for any help.

 

 

BTW--Skittles, I grew up just outside of Eugene, OR.

Edited by gearheadgary

Gary

Share this post


Link to post
Share on other sites

Great Contribution!!! Love It!!

 

I have seen on a few sites that the related products can be separated into rows with a quantity and checkbox included.. Does anyone have any idea what I need to modify to get this working?

 

Example : Quality Layout

 

Thanks.. And once again - Great Contribution

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×