X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   How to display the price for products in the recommends list (https://forum.x-cart.com/showthread.php?t=7475)

laureon 05-07-2004 07:49 AM

How to display the price for products in the recommends list
 
Hi,

I have seen many people wondering about how to display the price for products in the recommends list. Has anyone managed to find a suiatble solution that could be shared?

I am presuming that a php file may need to be modified to include the price related to the productid of the recommended products, but which and how I don't know.

If anyone can help it would be very much appreciated.

thanks

Mod King 05-14-2004 07:38 AM

Here is a way to get the price in the non-random method the recommends use
You have to edit ./customer/recommends.php
and replace the query on line 70 with

Code:

    $query = "select distinct sp2.productid, p.*, min($sql_tbl[pricing].price) as price from $sql_tbl[pricing], $sql_tbl[stats_customers_products] as sp1, $sql_tbl[stats_customers_products] as sp2, $sql_tbl[products] as p where sp1.productid='$productid' and sp1.login=sp2.login and sp2.productid!='$productid' and p.productid=sp2.productid and p.forsale='Y' ".$avail_condition2." and $sql_tbl[pricing].productid = p.productid and $sql_tbl[pricing].membership = '' and $sql_tbl[pricing].quantity = '1' GROUP BY p.productid ORDER BY p.product LIMIT ".$config["Modules"]["number_of_recommends"];

You also have to edit ./skin1/modules/Recommended_Products/recommends.tpl

Code:

{section name=num loop=$recommends}[*]
<span class="ItemsList">{$recommends[num].product} {$recommends[num].price}</span>

{/section}


I can't test it myself, I don't have a demo with the proper statistics loaded on it. But it should work, the query doesn't give an errors or anythng.

Let me know how it does

xcell67 05-20-2004 09:56 PM

Hi,
How would you apply the pricing fix to the code for the random method: staring with

Code:

$query = "SELECT * FROM $sql_tbl[products] WHERE forsale='Y' ".$avail_condition.$query_condition;

in

recommends.php

thanks

MOC 07-10-2004 02:21 PM

how do i add the product price to the random selection of this mod?

laureon 07-17-2004 04:49 AM

Hello,

Has anyone managed to come up with a solution to display the prices of items from the random products array? TIA

BCSE 07-17-2004 06:55 AM

I had a little time to look into this and have it working for random products. I tested this with 3.5.5

First edit skin1/modules/Recommended_Products/recommends.tpl Add this code:

Code:

<font class=ProductPrice>{include file="currency.tpl" value=$recommends[num].price}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$recommends[num].price}

AFTER
Code:

<span class="ItemsList">{$recommends[num].product}

Then edit customer/recommends.php

Find this line:
Code:

$query_condition .= "productid='".$products_id[$rnd]["productid"]."'";

CHANGE IT TO:
Code:

$query_condition .= "$sql_tbl[products].productid='".$products_id[$rnd]["productid"]."'";

Find this line:
Code:

$query_condition .= " OR productid='".$products_id[$rnd]["productid"]."'";

CHANGE IT TO:
Code:

$query_condition .= " OR $sql_tbl[products].productid='".$products_id[$rnd]["productid"]."'";

Finally, find this line:
Code:

$query = "SELECT * FROM $sql_tbl[products] WHERE forsale='Y' AND avail>0".$query_condition;

CHANGE IT TO:
Code:

$query = "SELECT * FROM $sql_tbl[products] left join $sql_tbl[pricing] on $sql_tbl[products].productid=$sql_tbl[pricing].productid WHERE forsale='Y' AND avail>0 and quantity='1'".$query_condition;

Hope this helps! Feel free to format recommends.tpl to suit your needs.

Carrie

laureon 07-17-2004 06:59 AM

Fantastic Carrie! - I will implement this in v3.5.10 and let you know how I get on.

laureon 07-17-2004 07:18 AM

Unfortunately there are a number of changes in recommends.php from the 2004/05/05 modification. Therefore it does not work under v3.5.10 - The most stragithforward solution might be to just use the 'recommends.php' file and implement the changes outlined.

BCSE 07-17-2004 07:51 AM

I don't have any version above 3.5.7 installed anywhere yet. I need to do that though, so once I get one of the higher versions installed, I'll report back as to how to change it.

Carrie

BCSE 07-17-2004 06:34 PM

I got around to trying this in 3.5.10 and found a solution since the recommends.php code is quite a bit different from the 3.5.5

First edit skin1/modules/Recommended_Products/recommends.tpl Add this code:

Code:

<font class=ProductPrice>{include file="currency.tpl" value=$recommends_prices[num].price}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$recommends_prices[num].price}

AFTER:
Code:

<span class="ItemsList">{$recommends[num].product}

Then edit customer/recommends.php

Add these two lines:
Code:

$recommends_prices = func_query("select * from $sql_tbl[pricing] where quantity='1' and productid in (".join(",",$query_ids).")");
    $smarty->assign("recommends_prices",$recommends_prices);


AFTER:
Code:

$query = "SELECT $sql_tbl[products].*, $lng_fields FROM $sql_tbl[products] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid $lng_condition WHERE $sql_tbl[products].forsale='Y' ".$avail_condition." AND $sql_tbl[products].productid IN (".join(",",$query_ids).")";

Hope that helps! :)

Carrie

shwekhaw 12-12-2004 12:13 AM

Hi BCSE:
I tried your codes in x-cart 4.0.7. I can see the price next to recommended product names but the price does not match to the product. It seems to me that prices are randomly listed next to product.
PHP codes are beyond my knowledge. Any chance you can fix it for 4.0.7?

Thanks.
S-H-W-E-K-H-A-W

BCSE 12-14-2004 11:54 AM

I just tested the above code in 4.0.4 and it's showing the right price. Perhaps you inserted the php code in the wrong place?

For 4.0.4 I inserted it into recommends.php (in x-cart directory) after this code:
Code:

if ($config["Modules"]["select_recommends_list_randomly"] == "Y" && count($query_ids)>0) {
    $query = "SELECT $sql_tbl[products].*, $lng_fields FROM $sql_tbl[products] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid $lng_condition WHERE $sql_tbl[products].productid IN ('".join("','",$query_ids)."')";


See if that helps!

Carrie

shwekhaw 12-14-2004 01:09 PM

I tried again and still not working.
Here is code after edited.

Code:

{* $Id: recommends.tpl,v 1.4 2004/05/28 12:21:12 max Exp $ *}
{if $recommends}
{capture name=recommends}
{section name=num loop=$recommends}
<LI>
<SPAN class="ItemsList">{$recommends[num].product}
{************* PRICE NEXT TO LIST ******}
<font class=ProductPrice>{include file="currency.tpl" value=$recommends_prices[num].price}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$recommends_prices[num].price}
{**************************************}
</SPAN>
</LI>
{/section}
{/capture}
{include file="dialog.tpl" title=$lng.lbl_recommends content=$smarty.capture.recommends extra="width=100%"}
{/if}


Parts from recommend.php
Code:

if ($config["Modules"]["select_recommends_list_randomly"] == "Y" && count($query_ids)>0) {


    $query = "SELECT $sql_tbl[products].*, $lng_fields FROM $sql_tbl[products] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid $lng_condition WHERE $sql_tbl[products].productid IN ('".join("','",$query_ids)."')";
$recommends_prices = func_query("select * from $sql_tbl[pricing] where quantity='1' and productid in (".join(",",$query_ids).")");
    $smarty->assign("recommends_prices",$recommends_prices);

}
else
    $query = "SELECT DISTINCT sp2.productid, $sql_tbl[products].*, $lng_fields FROM $sql_tbl[stats_customers_products] as sp1, $sql_tbl[stats_customers_products] AS sp2, $sql_tbl[products], $sql_tbl[products_categories], $sql_tbl[categories] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid $lng_condition WHERE sp1.productid='$productid' AND sp1.login=sp2.login AND sp2.productid!='$productid' AND $sql_tbl[products].productid=sp2.productid AND $sql_tbl[products].forsale='Y' AND $sql_tbl[products].productid = $sql_tbl[products_categories].productid AND $sql_tbl[products_categories].main = 'Y' AND $sql_tbl[categories].categoryid = $sql_tbl[products_categories].categoryid AND $sql_tbl[categories].membership IN ('".@$user_account['membership']."','') ".$avail_condition." ORDER BY $sql_tbl[products].product LIMIT ".$config["Modules"]["number_of_recommends"];

$recommends = func_query($query);
$smarty->assign("recommends",$recommends);
?>


I am assuming that you add the code within if statement.
The error is incorrect pricing shows up next to recommended product.

Under module options,
Select recommended products randomly: checked
Number of products to be displayed : 10

CC 12-25-2004 07:28 AM

Worked for me in 4.0.9 Gold.

Nice one Carrie! :wink:

shishapipe 01-06-2005 03:15 AM

This worked for me on 4.0.9, here is the code.
/skin1/modules/Recommended_Products/recommends.tpl
Code:

{* $Id: recommends.tpl,v 1.4 2004/05/28 12:21:12 max Exp $ *}
{if $recommends}
{capture name=recommends}
{section name=num loop=$recommends}
<LI>
<font class=ProductPrice>{include file="currency.tpl" value=$recommends_prices[num].price}</font>
<font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$recommends_prices[num].price}</font>
<span class="ItemsList">{$recommends[num].product}</SPAN>
</LI>
{/section}
{/capture}
{include file="dialog.tpl" title=$lng.lbl_recommends content=$smarty.capture.recommends extra="width=100%"}
{/if}


The above is the full code in recommends.tpl

shishapipe 01-06-2005 03:22 AM

And the last bit of the code in the your_shop_cart_root/recommends.php


Code:

if ($config["Modules"]["select_recommends_list_randomly"] == "Y" && count($query_ids)>0) {
    $query = "SELECT $sql_tbl[products].*, $lng_fields FROM $sql_tbl[products] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid $lng_condition WHERE $sql_tbl[products].productid IN ('".join("','",$query_ids)."')";

# Add extra code for Prices to Show

$recommends_prices = func_query("select * from $sql_tbl[pricing] where quantity='1' and productid in (".join(",",$query_ids).")");
    $smarty->assign("recommends_prices",$recommends_prices);
$query = "SELECT $sql_tbl[products].*, $lng_fields FROM $sql_tbl[products] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid $lng_condition WHERE $sql_tbl[products].forsale='Y' ".$avail_condition." AND $sql_tbl[products].productid IN (".join(",",$query_ids).")";

#End Add extra code for Prices to Show

}

else
    $query = "SELECT DISTINCT sp2.productid, $sql_tbl[products].*, $lng_fields FROM $sql_tbl[stats_customers_products] as sp1, $sql_tbl[stats_customers_products] AS sp2, $sql_tbl[products], $sql_tbl[products_categories], $sql_tbl[categories] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid $lng_condition WHERE sp1.productid='$productid' AND sp1.login=sp2.login AND sp2.productid!='$productid' AND $sql_tbl[products].productid=sp2.productid AND $sql_tbl[products].forsale='Y' AND $sql_tbl[products].productid = $sql_tbl[products_categories].productid AND $sql_tbl[products_categories].main = 'Y' AND $sql_tbl[categories].categoryid = $sql_tbl[products_categories].categoryid AND $sql_tbl[categories].membership IN ('".@$user_account['membership']."','') ".$avail_condition." ORDER BY $sql_tbl[products].product LIMIT ".$config["Modules"]["number_of_recommends"];

$recommends = func_query($query);
$smarty->assign("recommends",$recommends);
?>


I added the extra lines in the code which you can see is marked with:
# Add extra code for Prices to Show
And ends with
# End Add extra code for Prices to Show

enge919 01-23-2005 11:30 PM

How about a mod to display the prices of the product options in the order_info.tpl (in the orders view in the xcart admin)...4.0.x??

MOC 02-14-2005 08:58 PM

What do i have to change in 3.5.14

jvleigh 06-15-2006 05:57 AM

I've tried this MOD and have to agree with other posters that it randomizes the prices so that they do not match the products.

Has anybody had success getting the prices to match?

Thanks.


All times are GMT -8. The time now is 02:12 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.