Forums / General Questions / Cross Sell Module Mods

Cross Sell Module Mods

Locked
Results 1 to 20 of 42
This thread is locked. New replies are disabled.
11 Sep 2007, 12:52
#1
buyashed avatar

buyashed

New Zenner

Join Date:
May 2007
Posts:
36
Plugin Contributions:
0

Cross Sell Module Mods

Hi there,

I've currently got the Cross Sell module installed and i'm using the other module to get them to show up on the checkout page. I'm very happy with this and it's working well........

But at the moment the cross sell only shows the product image, product name and price. I'd like to get it to show an "add to cart" button as well.

If anyone can help me with how to do this i would be very thankful :D

Cheers, ToNy!
13 Sep 2007, 11:25
#2
buyashed avatar

buyashed

New Zenner

Join Date:
May 2007
Posts:
36
Plugin Contributions:
0

Re: Cross Sell Module Mods

Bump!!! Can anyone help out with this? Dr Byte?
13 Sep 2007, 12:13
#3
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Cross Sell Module Mods

You will have to dig in the code, and make changes: make changes in the module and template file (for the checkout page). This is not some thing extremely hard, but it's not something that can be done with a few lines of codes.
25 Sep 2007, 14:31
#4
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
3

Re: Cross Sell Module Mods

The code below is an example, it does work but please don't use it "out of the box" (a.o. because some texts are harcoded and it will mess up your current cross sell layout).

It includes:

- Buy Now buttons
- More Info links
- a quantity input field
- quantity in cart display (optional)

includes\modules\YOUR_TEMPLATE\xsell_products.php (it's an example of the the module file only):
<?php
/**
 * Cross Sell products
 *
 * Derived from:
 * Original Idea From Isaac Mualem [email protected] <mailto:[email protected]>
 * Portions Copyright (c) 2002 osCommerce
 * Complete Recoding From Stephen Walker [email protected]
 * Released under the GNU General Public License
 *
 * Adapted to Zen Cart by Merlin - Spring 2005
 * Reworked for Zen Cart v1.3.0  03-30-2006
 */

// in case admin switches aren't added properly, assume default settings:
if (!defined('MAX_DISPLAY_XSELL')) define('MAX_DISPLAY_XSELL',6);
if (!defined('MIN_DISPLAY_XSELL')) define('MIN_DISPLAY_XSELL',1);
if (!defined('XSELL_DISPLAY_PRICE')) define('XSELL_DISPLAY_PRICE','false');
if (!defined('SHOW_PRODUCT_INFO_COLUMNS_XSELL_PRODUCTS')) define('SHOW_PRODUCT_INFO_COLUMNS_XSELL_PRODUCTS',2);

// collect information on available cross-sell products for the current product-id
if (isset($_GET['products_id']) && SHOW_PRODUCT_INFO_COLUMNS_XSELL_PRODUCTS > 0 ) {
  $xsell_query = $db->Execute("select distinct p.products_id, p.products_image, pd.products_name
                                 from " . TABLE_PRODUCTS_XSELL . " xp, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                                 where xp.products_id = '" . $_GET['products_id'] . "'
                                  and xp.xsell_id = p.products_id
                                  and p.products_id = pd.products_id
                                  and pd.language_id = '" . $_SESSION['languages_id'] . "'
                                  and p.products_status = 1
                                 order by xp.sort_order asc limit " . MAX_DISPLAY_XSELL);
  $num_products_xsell = $xsell_query->RecordCount();

  // don't display if less than the minimum amount set in Admin->Config->Minimum Values->Cross-Sell
  if ($num_products_xsell >= MIN_DISPLAY_XSELL && $num_products_xsell > 0) {
?>
<!-- xsell_products //-->
<?php
$row = 0;
$col = 0;
$list_box_contents = array();
$title='';
if ($num_products_xsell < SHOW_PRODUCT_INFO_COLUMNS_XSELL_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_XSELL_PRODUCTS==0) {
  $col_width = floor(100/$num_products_xsell);
} else {
  $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_XSELL_PRODUCTS);
}
while (!$xsell_query->EOF) {
  $products_price = zen_get_products_display_price($xsell_query->fields['products_id']);
  $xsell_query->fields['products_name'] = zen_get_products_name($xsell_query->fields['products_id']);
  //$list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsCrossSell centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
  //'text' => '<a href="' . zen_href_link(zen_get_info_page($xsell_query->fields['products_id']), 'products_id=' . (int)$xsell_query->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $xsell_query->fields['products_image'], $xsell_query->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . zen_href_link(zen_get_info_page($xsell_query->fields['products_id']), 'products_id=' . $xsell_query->fields['products_id']) . '">' . $xsell_query->fields['products_name'] . '</a>' . (XSELL_DISPLAY_PRICE=='true'? '<br />'.zen_get_products_display_price($xsell_query->fields['products_id']):'') );

// bof buy now buttons 
$myBuyNow = '';
//$flag_show_product_info_in_cart_qty = 1;

$myBuyNow .= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($xsell_query->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product'), 'post', 'enctype="multipart/form-data"') . "\n";
$myBuyNow .= 'Aantal' . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($xsell_query->fields['products_id'])) . '" maxlength="6" size="4" />' . "\n";
//$myBuyNow .= zen_get_products_quantity_min_units_display($xsell_query->fields['products_id']) . "\n";
$myBuyNow .= zen_draw_hidden_field('products_id', $xsell_query->fields['products_id']);
//      '<img alt="Aan winkelwagen toevoegen" class="cart-add" src="' .  $template->get_template_dir('my_cart_add.png', DIR_WS_TEMPLATE, $current_page_base,'images') . '/cart-add.gif" />';
//$myBuyNow .= zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
$myBuyNow .= zen_image_submit('my_cart_add.png', 'Voeg toe aan winkelwagen.');
$myBuyNow .= '</form>';
//$myBuyNow .= (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($xsell_query->fields['products_id'])) ? '<p class="xsellProductsInCart">' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->get_quantity($xsell_query->fields['products_id']) . '</p>' : '');

// eof buy now buttons
     $list_box_contents[$row][$col] = array('params' =>'class="grid_layout"',
     'text' => '<a class="crossSellImageLink" href="' . zen_href_link(zen_get_info_page($xsell_query->fields['products_id']), 'products_id=' . $xsell_query->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $xsell_query->fields['products_image'], $xsell_query->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>' . "\n" . 
     '<h4><a href="' . zen_href_link(zen_get_info_page($xsell_query->fields['products_id']), 'products_id=' . $xsell_query->fields['products_id']) . '">' . $xsell_query->fields['products_name'] . '</a></h4>' . "\n" . 
     '<h3>' . $products_price . '</h3>' . "\n" .
     '<a class="crossSellLink" href="' . zen_href_link(zen_get_info_page($xsell_query->fields['products_id']), 'products_id=' . $xsell_query->fields['products_id']) . '">' . '[meer info]' . '</a>' . "\n" .          
     '<div class="crossSellBuyNow">' .
     $myBuyNow . '</div>' . "\n"
     );
  
  $col ++;
  if ($col > (SHOW_PRODUCT_INFO_COLUMNS_XSELL_PRODUCTS -1)) {
    $col = 0;
    $row ++;
  }
  $xsell_query->MoveNext();
}
// store data into array for display later where desired:
$xsell_data = $list_box_contents;
  }
}
?>

The changes are (partly?) commented by "// bof buy now buttons" and "// eof buy now buttons"
02 Nov 2007, 13:47
#5
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
3

Re: Cross Sell Module Mods

Bug fix:

This (code from my previous post)
$myBuyNow .= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($xsell_query->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product'), 'post', 'enctype="multipart/form-data"') . "\n";


Should be:
$myBuyNow .= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product'), 'post', 'enctype="multipart/form-data"') . "\n";


It's an issue only if an xsell master has another products type than it's xsell products.
08 Nov 2007, 10:13
#6
neojick avatar

neojick

New Zenner

Join Date:
Nov 2007
Posts:
4
Plugin Contributions:
0

Re: Cross Sell Module Mods

Hello, sorry for my english, i'm french.

I use zencart and cross sell to make link on a product to another product.
But I want to make another thing :

An exemple :

Supposing I cross sell product A with product B.
I want, when the customer buy product A AND product B, apply a reduction (like 10% for exemple). Is it possible with the basic version of cross sell, or had I to develop it ?


Thanks for your answers, Damien
08 Nov 2007, 11:21
#7
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Cross Sell Module Mods

I think you need to look at the Better Together mod.
08 Nov 2007, 13:01
#8
neojick avatar

neojick

New Zenner

Join Date:
Nov 2007
Posts:
4
Plugin Contributions:
0

Re: Cross Sell Module Mods

Yes, but my exemple is not good in fact... better together is to link two products, and me, I wan't like, two, three, four... products
08 Nov 2007, 13:23
#9
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Posts:
10,475
Plugin Contributions:
9

Re: Cross Sell Module Mods

Il n’y a pas de moyen en Zen Cart standard pour créer une liaison entre des produits multiples, ce que j’ai appelé d’ailleurs le « product bundle ». Cependant, si vous connaissez un peu de PHP, grâce à « extra_cart_actions», vous pouvez effectuer une remise sur une collection de produits qui sont déterminée en avance. Voyez ici plus d’informations.
08 Nov 2007, 13:36
#10
neojick avatar

neojick

New Zenner

Join Date:
Nov 2007
Posts:
4
Plugin Contributions:
0

Re: Cross Sell Module Mods

Merci beaucoup je file voir ça


<edit>

Très intéressant votre lien. Il faut que je trouve le moyen de passer par une page temporaire permettant le choix des attributs du produit. Je vais reflechir à ça

</edit>
22 Nov 2007, 19:38
#11
mydssbin avatar

mydssbin

New Zenner

Join Date:
Nov 2007
Posts:
13
Plugin Contributions:
0

Re: Cross Sell Module Mods

after installing xsell here is what the layout looks like and if someone can tell me how to fix it.



http://www.megafta.com/index.php?mai...&products_id=4
22 Nov 2007, 20:08
#12
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Posts:
10,475
Plugin Contributions:
9

Re: Cross Sell Module Mods

mydssbin:

after installing xsell here is what the layout looks like and if someone can tell me how to fix it.

http://www.megafta.com/index.php?mai...&products_id=4


Can't see (and wouldn't expect) any evidence of cross sell on the page to which you have linked. Could you re-link and/or explain what the problem is.
22 Nov 2007, 20:10
#13
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Posts:
10,475
Plugin Contributions:
9

Re: Cross Sell Module Mods

Ah. I think there was a problem with your link and you really meant this page.
22 Nov 2007, 21:40
#14
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Posts:
10,475
Plugin Contributions:
9

Re: Cross Sell Module Mods

I'm not currently seeing a way that the Cross Sell mod could have this effect. However, I am seeing lots of dodgy code hidden in your product descriptions that is causing validation errors and corrupting the structure of your pages.
23 Nov 2007, 18:20
#15
yairoz avatar

yairoz

New Zenner

Join Date:
May 2007
Posts:
60
Plugin Contributions:
0

Re: Cross Sell Module Mods

Hey Guys

First of all thank u for this great module.

I'm having a few problems with this module:

1. After installing this update (to add addto cart bottuns) the layout of the products is kinda messed up now... instead of showing the products in a row it show them one under the other....

2. weird thing, after adding to cart one of the products from the module, and then adding the main product, it adding the "may we recommend" product again... no matter how many times I try to add the main product to cart, it always add the product from the module...

Please have a look at it at:

4playrusDOTcom/ and look at product number 3 (Adult Content....)

(can't write the full link - zencart blocks my keyword...)

Thank You
23 Nov 2007, 19:54
#16
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Posts:
10,475
Plugin Contributions:
9

Re: Cross Sell Module Mods

YairOz:

1. After installing this update (to add addto cart bottuns) the layout of the products is kinda messed up now... instead of showing the products in a row it show them one under the other....
It's not clear whether the update to which you refer is a mod that you have added or a bit of custom code. However, the end result is a version of cross sell that doesn't have the normal classes that tie into the stylesheet for layout, or the embedded HTML that sets the width of cross sell product. The latter is particularly important for allowing the products to line up horizontally.

YairOz:

2. weird thing, after adding to cart one of the products from the module, and then adding the main product, it adding the "may we recommend" product again... no matter how many times I try to add the main product to cart, it always add the product from the module...
Not so weird. In amongst the other changes the closing </form> tag has been lost. for the first add to cart button. As a result the form extends to the end of the second add to cart button which is the first cross sold product. So now every time you click the first button, it's the product for the second that will be added to the cart.
23 Nov 2007, 22:54
#17
yairoz avatar

yairoz

New Zenner

Join Date:
May 2007
Posts:
60
Plugin Contributions:
0

Re: Cross Sell Module Mods

kuroi:

It's not clear whether the update to which you refer is a mod that you have added or a bit of custom code. However, the end result is a version of cross sell that doesn't have the normal classes that tie into the stylesheet for layout, or the embedded HTML that sets the width of cross sell product. The latter is particularly important for allowing the products to line up horizontally.

Not so weird. In amongst the other changes the closing </form> tag has been lost. for the first add to cart button. As a result the form extends to the end of the second add to cart button which is the first cross sold product. So now every time you click the first button, it's the product for the second that will be added to the cart.


Thank u kuroy for the quick answer :smile:

For the first answer - the changes I done is from the code paulm gave here at the first page of the code... I guess he changed the layout? I gonna look at those files see if I can see something...

as for the second answer - is there any way to fix it? can u tell me how or where to look?

thanks again!
23 Nov 2007, 23:13
#18
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Posts:
10,475
Plugin Contributions:
9

Re: Cross Sell Module Mods

Ah. That would be the code that he warns
will mess up your current cross sell layout
Yes, I can see elements in your code such as his customer class for the div around the cross sell product data, but you would need to create your own CSS to go with this, both to style the content and to create its structure (since his code ignores the Zen Cart variables created to do this).

The missing closing form tag is, I now see, not missing. It's in its usual place at the bottom of the product_information panel. However, you can't nest your additional add to cart buttons inside it, as they too are forms. So you need to move them down, or more likely close your original form immediately after the original add to cart button.
23 Nov 2007, 23:30
#19
yairoz avatar

yairoz

New Zenner

Join Date:
May 2007
Posts:
60
Plugin Contributions:
0

Re: Cross Sell Module Mods

kuroi:

Ah. That would be the code that he warnsYes, I can see elements in your code such as his customer class for the div around the cross sell product data, but you would need to create your own CSS to go with this, both to style the content and to create its structure (since his code ignores the Zen Cart variables created to do this).

The missing closing form tag is, I now see, not missing. It's in its usual place at the bottom of the product_information panel. However, you can't nest your additional add to cart buttons inside it, as they too are forms. So you need to move them down, or more likely close your original form immediately after the original add to cart button.



Thank u very much

as you said I placed the </form> a little bit upper, right after (and like that:):

 
 
$myBuyNow = '';
$myBuyNow .= '</form>';


and it fixed the add to cart problem thanks!

as for the layout... would I need to change the code again? or just write the css file? and do I need to tell zencart to use this css file? or I just put it the css directory of my template?

thank u very much for helping me! :clap::clap:
24 Nov 2007, 15:21
#20
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
3

Re: Cross Sell Module Mods

kuroi:

you would need to create your own CSS to go with this, both to style the content and to create its structure (since his code ignores the Zen Cart variables created to do this).
That's correct. I did not include any styling, but just dropped in some "random" classes. Maybe some default Zen classes would fit nicely?


And I forgot about the fact that I included the xsell box below the closing form tag, while most will probably include it just above or below also purchased (which is before the form closure).

I think at first I wanted the form to redirect to the xsell product when a customer would add it to the cart (and achieved that by giving each xsell product it's own form + action). But later I realized that some customers might be distracted to much by this redirect to the xsell product and possibly would never return to the original product to buy it.....
(of course this behaviour depends on your "Display Cart After Adding Product" setting too)

Anyway, the way it is setup now it's easy to change the form action as desired.