Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Upselling Products module modification

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 09-23-2003, 04:49 AM
 
maki maki is offline
 

Advanced Member
  
Join Date: May 2003
Location: Spain
Posts: 46
 

Default Upselling Products module modification

Hi all !!!

I have modified Upselling Products module

- Added: thumbnails in products links
- Added: Add to cart
- Added: if product link has options ...

the new related_products.tpl located in ../skin1/modules/Upselling_Products :

Code:
{* $Id: related_products.tpl,v 1.7 2003/11/26 10:27:05 mAKI Exp $ *} {if $product_links ne ""} {capture name=dialog} <table border=0 cellspacing=5 width="100%"> {section name=cat_num loop=$product_links} <tr class="ItemsList"> <td align=center valign=center> {include file="product_thumbnail.tpl" productid=$product_links[cat_num].productid image_x=60} </td> <td colspan="4" align=top valign=top><hr size=1 noshade align=top> <table border=0 cellspacing=5 width="100%"> <tr class="ItemsList"> <td colspan="3" align=top valign=top> {$product_links[cat_num].product|escape} </td> </tr> <tr> <td colspan="2" valign=top> {if $product_links[cat_num].price ne 0} {if $product_links[cat_num].list_price gt 0 and $product_links[cat_num].price lt $product_links[cat_num].list_price} {math equation="100-(price/lprice)*100" price=$product_links[cat_num].price lprice=$product_links[cat_num].list_price format="%d" assign=discount} <font class=MarketPrice>{$lng.lbl_market_price}: <s>{include file="currency.tpl" value=$product_links[cat_num].list_price}</s></font> {/if} <font class=ProductPrice>{$lng.lbl_our_price}: {include file="currency.tpl" value=$product_links[cat_num].price}</font> <font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$product_links[cat_num].price}</font> {if $product_links[cat_num].list_price gt 0 and $product_links[cat_num].price lt $product_links[cat_num].list_price}, {$lng.lbl_save} {$discount}%{/if} {if $config.Taxes.use_vat eq "Y" and $product_links[cat_num].vat gt "0"}, {$lng.lbl_including_vat} {$product_links[cat_num].vat}%{/if} {else} <font class=ProductPrice>{$lng.lbl_enter_your_price}</font> {/if} </td> <td colspan="3" align="right" valign=center> {if $usertype eq "C" and $config.Appearance.buynow_button_enabled eq "Y"} {include file="customer/main/buy_now.tpl" product=$product_links[cat_num]} {/if} </td> </tr> </table> </td> </tr> {/section} </table> {/capture} {include file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra="width=100%"} {/if}
-------------------------------------
2003/10/12 ---> edited the code

- Added: |escape:"html" in the $smarty's variables "add to cart"
- Removed: Showing "product prices by quantity" in list products (it showed the prices of the main article, still adding variable "product=$product_links[cat_num]" in in the call to the file buy_now.tpl ... lol
-------------------------------------
2003/11/26 ---> edited the code

- Removed "add to cart" code if $js_disabled. (this verification is made from buy_now.tpl) thanks Jon
- Removed "add to whishlist" (is added from buy_now.tpl)
- Fixed sintax error (thanks Jon)
- Fixed Link Add to Cart if product as options
-------------------------------------
2004/03/19 ---> edited the code: related_products.php

- Added Multilingual Products
- Added Fix security patch detected by X-Cart Team in all 3.4.x versions

Backup and edit ../xcart/modules/Upselling_Products/related_products.php
to replace the original code by the following one:

Code:
<? /*****************************************************************************\ +-----------------------------------------------------------------------------+ | X-Cart | | Copyright (c) 2001-2003 Ruslan R. Fazliev <rrf@rrf.ru> | | All rights reserved. | +-----------------------------------------------------------------------------+ | PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" | | FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE | | AT THE FOLLOWING URL: http://www.x-cart.com/license.php | | | | THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE | | THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT RUSLAN R. | | FAZLIEV (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING | | AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). | | PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT | | CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, | | COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY | | (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS | | LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS | | AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND | | OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS | | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE | | THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE.| | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. | | | | The Initial Developer of the Original Code is Ruslan R. Fazliev | | Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2003 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # # $Id: related_products.php,v 1.9.4.1 2004/03/19 11:57:50 mAKI Exp $ # # This Module forms list of upsailing products # if ( !defined('XCART_SESSION_START') ) { header("Location: ../../"); die("Access denied"); } $membership = $user_account['membership']; $p_cat = (empty ($cat) ? "0" : $cat); if ($config["General"]["unlimited_products"]=="N") $avail_condition = "$sql_tbl[products].avail>0 and "; else $avail_condition = ""; $product_links = func_query($search_query = "select DISTINCT $sql_tbl[products].*, $sql_tbl[categories].category, $sql_tbl[pricing].price from $sql_tbl[products], $sql_tbl[pricing], $sql_tbl[categories], $sql_tbl[product_links] where ($sql_tbl[pricing].membership='') and ($sql_tbl[pricing].productid=$sql_tbl[products].productid) and ($sql_tbl[pricing].quantity=1) and ($sql_tbl[products].categoryid=$sql_tbl[categories].categoryid) and $sql_tbl[products].forsale='Y' and ($sql_tbl[products].productid=$sql_tbl[product_links].productid2) and ($sql_tbl[product_links].productid1='$productid') ORDER BY $sql_tbl[products].product"); if(is_array($product_links)){ foreach($product_links as $p_v => $p_k){ $int_res = ''; if(is_array($p_k)){ # # Check if product have product options # $product_links[$p_v][product_options] = array_pop(func_query_first("SELECT COUNT(*) FROM $sql_tbl[product_options] WHERE productid='".$p_k["productid"]."'")); # # Replace descr and fulldescr on international (if defined) # $int_res = func_query_first("SELECT * FROM $sql_tbl[products_lng] WHERE code='$store_language' AND productid='".$p_k['productid']."'"); if ($int_res["product"]){ $product_links[$p_v]["product"] = stripslashes($int_res["product"]); } if ($int_res["descr"]){ $product_links[$p_v]["descr"] = str_replace("\n"," ", stripslashes($int_res["descr"])); } if ($int_res["full_descr"]){ $product_links[$p_v]["fulldescr"] = str_replace("\n"," ", stripslashes($int_res["full_descr"])); } } } }; $smarty->assign("product_links",$product_links); ?>
-------------------------------------
suggestions and corrections well will be received

greetings !!!
Reply With Quote
  #2  
Old 09-23-2003, 05:10 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

Is this for Version 3.4.7 ?
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #3  
Old 09-23-2003, 05:13 AM
 
maki maki is offline
 

Advanced Member
  
Join Date: May 2003
Location: Spain
Posts: 46
 

Default

ups !!! yes ... i am runnig v.3.4.7
Reply With Quote
  #4  
Old 09-23-2003, 05:19 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #5  
Old 09-23-2003, 05:24 AM
 
maki maki is offline
 

Advanced Member
  
Join Date: May 2003
Location: Spain
Posts: 46
 

Default

Hi !!

it would be well that it was included like option in future versions of x-cart

Reply With Quote
  #6  
Old 09-23-2003, 06:38 AM
 
dealsondeals dealsondeals is offline
 

eXpert
  
Join Date: Dec 2002
Location: Dallas, Texas, USA
Posts: 231
 

Default

Nice contribution! Keep up the good work!
__________________
Never understimate stupidity.
--------
X-Cart Version: 3.5.2
Hosting:mind-in-design.net
Configuration: Virtual Dedicated Server || Intel Pentium 4 2.4 GHZ CPU || 1024MB PC2100 DDR RAM || Linux || PHP 4.3.2 || MySQL server 4.0.14
Reply With Quote
  #7  
Old 09-26-2003, 12:16 AM
 
parmar parmar is offline
 

eXpert
  
Join Date: Apr 2003
Location: London, UK
Posts: 286
 

Default

Great Mod Maki, Thanks
__________________
--------------------
Sandip


x-cart version 5.4.X, hosted on X-Cart server/
Reply With Quote
  #8  
Old 10-12-2003, 06:10 AM
 
bluecat bluecat is offline
 

X-Adept
  
Join Date: Nov 2002
Posts: 674
 

Default

Great hack, thanks!

A couple of questions...

Is there a way to turn "off" the images on certain ones, so just a link is shown?

Secondly, how can I make it so when a customer clicks on a related item it doesn't open a new window? I want it so they can use their back button if needed. Thanks again.
Reply With Quote
  #9  
Old 10-13-2003, 01:44 AM
 
maki maki is offline
 

Advanced Member
  
Join Date: May 2003
Location: Spain
Posts: 46
 

Default

Quote:
Originally Posted by bluecat
Great hack, thanks!

A couple of questions...

Is there a way to turn "off" the images on certain ones, so just a link is shown?

Secondly, how can I make it so when a customer clicks on a related item it doesn't open a new window? I want it so they can use their back button if needed. Thanks again.

Hi !!

For the first question, remove: {include file="product_thumbnail.tpl" productid=$product_links[cat_num].productid image_x=60} and the thumbnails will not be shown

For the last question, remove: target=_blank

the code would be thus:

<td width=90 align=center valign=center></td>

I hope that he is to you useful
Reply With Quote
  #10  
Old 10-13-2003, 05:42 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

This was defiantly a must, nice mod! Thanks Maki!
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:46 PM.

   

 
X-Cart forums © 2001-2020