News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Show related product under check out page

Started by misaelbroertjes, June 29, 2012, 16:11:23 PM

Previous topic - Next topic

misaelbroertjes

guys,

Can I show related product under check out page? and how?

Misael Broertjes

jenkinhill

If you look at the related products code in the view template default_relatedproducts.php then you will see that it relates purely to the product details page, so could not be used for the checkout without a lot of additional coding to that and the chackout templates. Then decide what would happen if you have 10 products in checkout.

Simple answer - no.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

vargpr

step1:You have to add some lines of code to /administrator/components/com_virtuemart/html/basket.php

Step2: Fin the following code
if( $show_basket ) {
      
      if( $auth["show_price_including_tax"] == 1) {
         $basket_html = $tpl->fetch( 'basket/basket_b2c.html.php');         
      }
      else {
         $basket_html = $tpl->fetch( 'basket/basket_b2b.html.php');
      }

Step3: right after that put in the following code
$dbrelated= new ps_DB;

$q = "SELECT product_sku, related_products FROM #__{vm}_product,#__{vm}_product_relations ";
$id_de_producto = $cart[0]["product_id"];
$q .= "WHERE #__{vm}_product_relations.product_id='$id_de_producto' AND product_publish='Y' ";
$q .= "AND FIND_IN_SET(#__{vm}_product.product_id, REPLACE(related_products, '|', ',' )) LIMIT 0, 4";

$dbrelated->query( $q );
      
if( $dbrelated->num_rows() > 0 ) {
   $tpl->set( 'ps_product', $ps_product );
   $tpl->set( 'products', $dbrelated );
   $basket_html .= $tpl->fetch( '/common/relatedProducts.tpl.php' );
}

And your one. However, The problem is that when the cart has more than 1 product, you have to decide which related products of which of the items you want to show.

I hope this helped