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)
-   -   What's new mod (https://forum.x-cart.com/showthread.php?t=12162)

walteis 02-13-2005 03:01 PM

What's new mod
 
I've created a pretty simple "what's new" modification that someone might be interested in. It displays all the products that were created within a configurable number of days.

First, create a PHP file called newest.php that contains the following code:

Code:

<?
// set variables
$daterange = 60 * 60 * 24 * $wn; // days in unix time
$nowtime = time();
$oldtime = $nowtime - $daterange ;

$objects_per_page = $config["Appearance"]["products_per_page"];



// the database query

$search_data["products"] = array();
$search_data["products"]["forsale"] = "Y";
$from_tbl[$sql_tbl['featured_products']] = 0;
$search_condition = "DATE_SUB(CURDATE(),INTERVAL ". $wn . " DAY) <= from_unixtime(".add_date.") AND ";

$mode = "search";

include $xcart_dir."/include/search.php";


$location[]=array("What's New","");





// give the product array to smarty to make it available sitewide.
$smarty->assign("newproducts",$products);
$smarty->assign("location",$location);
$smarty->assign("navigation_script","home.php?wn=$wn");
?>


Then change home.php to include the following:

Code:

if (!empty($wn)) {
        include "./newest.php";
        $smarty->assign("wn","$wn");
}


I put that right after the Bestsellers code.

Next, you'll need a template called customer/main/newest.tpl

Code:


Visit this area of the store to see all the new items we've added in the last {$smarty.get.wn} days.




{if $mode eq "search"}
{if $total_items gt "1"}
{$lng.txt_N_results_found|substitute:"items":$total_items}

{$lng.txt_displaying_X_Y_results|substitute:"first_item":$first_item:"last_item":$last_item}
{elseif $total_items eq "0"}
{$lng.txt_N_results_found|substitute:"items":0}
{/if}
{/if}







{capture name=dialog}

{if $newproducts ne ""}

{if $total_pages gt 2}
{assign var="navpage" value=$navigation_page}
{/if}


<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
{if $sort_fields}
{assign var=url value="home.php?wn="|cat:$smarty.get.wn|cat:"&"}
<TR>
        <TD>{include file="main/search_sort_by.tpl" sort_fields=$sort_fields selected=$search_prefilled.sort_field direction=$search_prefilled.sort_direction url=$url}
       



        </TD>
</TR>
{/if}
<TR>
<TD>

{include file="customer/main/navigation.tpl"}

{include file="customer/main/products.tpl" products=$newproducts}




{include file="customer/main/navigation.tpl"}

</TD>
</TR>
</TABLE>
 
{else}


{$lng.txt_no_new|substitute:"XX":$smarty.get.wn}

{/if}

{/capture}
{include file="dialog.tpl" title="New Products" content=$smarty.capture.dialog extra="width=100%"}



Then edit customer/home_main.tpl to include the previous template:

Code:

{elseif $main eq "subscriptions"}
{include file="modules/Subscriptions/subscriptions.tpl"}

{elseif $wn ne ""}
{include file="customer/main/newest.tpl"}

{elseif $main eq "catalog" and $current_category.category eq ""}
{include file="customer/main/welcome.tpl" f_products=$f_products}



Then I added a config table setting called TFTACustom.wndays, you can call it anything you'd like.

Assuming that you called it that, you can then add a link in the categories.tpl

Code:

What's New


This mod works as written with 4.0.7

Walt

cotc2001 02-14-2005 02:18 AM

I've seen something like this before and very handy it was BUT it's only downfall is if you create a new product and then set it to disabled (because you updating your store and want to enable it later) it will still show in your new product list.

Does yours suffer from that as well or does it obey the disabled rule??

ETInteractive.com 02-14-2005 04:26 AM

$search_data["products"]["forsale"] = "Y";

it will only show if its available for sale.

tlopez 03-24-2005 07:33 PM

Quote:

I've created a pretty simple "what's new" modification that someone might be interested in. It displays all the products that were created within a configurable number of days.

Where do I configure the number of days?

Thanks

TelaFirma 03-25-2005 02:31 AM

Quote:

Originally Posted by tlopez
Quote:

I've created a pretty simple "what's new" modification that someone might be interested in. It displays all the products that were created within a configurable number of days.

Where do I configure the number of days?

Thanks


at the top of the script

Code:

<?
// set variables
$daterange = 60 * 60 * 24 * $wn; // days in unix time
$nowtime = time();
$oldtime = $nowtime - $daterange ;
..
..
..
..


alkhashrami 03-25-2005 10:55 PM

Hi,

thanks for this mod

I've tested your mod in 4.0.12 with fashion moasic skin
every thing was good except it appears in the main page which is not good for that skin

SO, how can i configure it to work like if we see a category i.e. not in the main page

thanks again

jeeya 03-26-2005 01:27 AM

Quote:

Originally Posted by alkhashrami
Hi,

thanks for this mod

I've tested your mod in 4.0.12 with fashion moasic skin
every thing was good except it appears in the main page which is not good for that skin

SO, how can i configure it to work like if we see a category i.e. not in the main page

thanks again



if (!empty($wn)) {
include "./newest.php";
$smarty->assign("wn","$wn");
}


don't put above code in home.php instead put it in catagories.php

alkhashrami 03-26-2005 04:26 AM

i did what you said
Quote:

if (!empty($wn)) {
include "./newest.php";
$smarty->assign("wn","$wn");
}

don't put above code in home.php instead put it in catagories.php


but after calling, it returns to home page without any results


any other idea?

alkhashrami 03-28-2005 11:37 PM

Hi everybody :) ,

i tried to modify the this mod to work with my x-cart version and skin,
inspite i'm not a php expert but i depend on comparing similar files and do needed changes then testing on the site.

After 2 days i think that i solve it and this is the mod after modifications:

First, create a PHP file called newest.php that contains the following code:

Code:

<?php

require "./auth.php";
require $xcart_dir."/include/categories.php";


// set variables
$daterange = 60 * 60 * 24 * $wn; // days in unix time
$nowtime = time();
$oldtime = $nowtime - $daterange ;

$objects_per_page = $config["Appearance"]["products_per_page"];



// the database query

$search_data["products"] = array();
$search_data["products"]["forsale"] = "Y";
$from_tbl[$sql_tbl['featured_products']] = 0;
$search_condition = "DATE_SUB(CURDATE(),INTERVAL ". $wn . " DAY) <= from_unixtime(".add_date.") AND ";

$mode = "search";

include $xcart_dir."/include/search.php";


$location[]=array(func_get_langvar_by_name("lbl_what_is_new"),"");





// give the product array to smarty to make it available sitewide.
$smarty->assign("main","newest");
$smarty->assign("newproducts",$products);
$smarty->assign("location",$location);
$smarty->assign("wn","$wn");
func_display("customer/home.tpl", $smarty);

?>



Next, you'll need a template called customer/main/newest.tpl that contains the following code:

Code:

{capture name=dialog}

{if $newproducts ne ""}

{$lng.txt_last_added_products} {$smarty.get.wn} {if $smarty.get.wn > 1} {$lng.lbl_days}{else}{$lng.lbl_day}{/if}.


 

{if $mode eq "search"}
{if $total_items gt "1"}
{$lng.txt_N_results_found|substitute:"items":$total_items}
 
{$lng.txt_displaying_X_Y_results|substitute:"first_item":$first_item:"last_item":$last_item}
{elseif $total_items eq "0"}
{$lng.txt_N_results_found|substitute:"items":0}
{/if}
{/if}



 

{if $total_pages gt 2}
{assign var="navpage" value=$navigation_page}
{/if}


<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
{if $sort_fields}
{assign var=url value="home.php?wn="|cat:$smarty.get.wn|cat:"&"}
<TR>
  <TD>{include file="main/search_sort_by.tpl" sort_fields=$sort_fields selected=$search_prefilled.sort_field direction=$search_prefilled.sort_direction url=$url}
 


 
  </TD>
</TR>
{/if}
<TR>
<TD>

{include file="customer/main/navigation.tpl"}

{include file="customer/main/products.tpl" products=$newproducts}


 

{include file="customer/main/navigation.tpl"}

</TD>
</TR>
</TABLE>

{else}


{$lng.txt_no_added_products|substitute:"XX":$smarty.get.wn} {if $smarty.get.wn > 1} {$lng.lbl_days}{else}{$lng.lbl_day}{/if}.

{/if}

{/capture}
{include file="dialog.tpl" title=$lng.lbl_new_products content=$smarty.capture.dialog extra="width=100%"}



Then edit customer/home_main.tpl to include this code:

Code:

{elseif $wn ne ""}
{include file="customer/main/newest.tpl"}



Then, add these lang variables to the database (SQL)

Code:

INSERT INTO xcart_languages VALUES ('US','New products','lbl_new_products','New products','Labels');
INSERT INTO xcart_languages VALUES ('US','These are the products we have added in the last','txt_last_added_products','These are the products we have added in the last','Text');
INSERT INTO xcart_languages VALUES ('US','We are sorry, there are no new added products in the last {{XX}}','txt_no_added_products','We are sorry, there are no new added products in the last {{XX}}','Text');
INSERT INTO xcart_languages VALUES ('US','day','lbl_day','day','Labels');




Finally, you can call this mod through a link e.g:


"wn" indicats the number of days , wn=10 i.e. 10 days


I hope this will be good, and correct me if there is any mistake

thanks for all of you. :)

sabrina 03-29-2005 04:11 AM

If i try this link:
http://www.indyplaza.com/catalog/newest.php?wn=10

I got:

Page not found!
The requested page does not exist or you are not allowed to access it!


If i try this link:
http://www.indyplaza.com/catalog/newest.php

I got:

INVALID SQL: 1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ') <= from_unixtime(add_date) AND xcart_pricing.productid=xcart_
SQL QUERY FAILURE: SELECT COUNT(xcart_products.productid), MIN(xcart_pricing.price) as price , xcart_products_lng.product as product_lng, xcart_products_lng.descr as descr_lng, xcart_products_lng.full_descr as fulldescr_lng, IF(xcart_variants.variantid IS NOT NULL,'Y','') as is_variant, IF(xcart_classes.classid IS NOT NULL,'Y','') as is_product_options, v_pricing.price as v_price FROM xcart_products, xcart_pricing , xcart_featured_products, xcart_products_categories, xcart_categories LEFT JOIN xcart_products_lng ON xcart_products_lng.productid = xcart_products.productid AND xcart_products_lng.code = 'US' LEFT JOIN xcart_classes ON xcart_classes.productid = xcart_products.productid LEFT JOIN xcart_variants ON xcart_variants.productid = xcart_products.productid LEFT JOIN xcart_pricing as v_pricing ON v_pricing.variantid = xcart_variants.variantid AND v_pricing.quantity = 1 AND v_pricing.membership IN ('','') WHERE DATE_SUB(CURDATE(),INTERVAL DAY) <= from_unixtime(add_date) AND xcart_pricing.productid=xcart_products.productid AND xcart_pricing.quantity=1 AND xcart_pricing.membership IN ('','') AND (xcart_pricing.variantid = 0 OR (xcart_variants.variantid = xcart_pricing.variantid)) AND xcart_products_categories.productid=xcart_products .productid AND xcart_products_categories.categoryid = xcart_categories.categoryid AND xcart_categories.membership IN ('','') AND xcart_products.forsale='Y' GROUP BY xcart_products.productid

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/indypla/public_html/catalog/include/func.php on line 102

tlopez 03-29-2005 11:59 AM

Quote:

Finally, you can call this mod through a link e.g:

Code:

New added products in the last 10 days

"wn" indicats the number of days , wn=10 i.e. 10 days


Thanks alkhashrami

The above line of code that you provided solved my problem in getting this mod to work.

[/quote]

august 04-14-2005 11:01 PM

Well, something is definitely not right, this won't work in 4.0.13, and I don't see it working in your sites either.

august 04-25-2005 08:44 AM

**Update** Already got it as I wanted

I'm willing to pay for a "What's New" MOD, that have the same principle as Funky MOD (http://forum.x-cart.com/viewtopic.php?t=1418&postdays=0&postorder=asc&high light=newest%20mod&start=0), with this requirements:

1- Must work in version 4.0.13
2- Need to open in a new window from special.tpl
3- Must do random product.
4- Have a selection of how many days you want to see the new products. (10, 30, 60)
5- Must be open source
6- Be reasonable with the price

All the code is there in the forum it just need to make it work in the actual version, Duncan did it once for me in version 3.4.0, but now he does not want to work with x-cart products. I still have the backup that he gave me.

IndieDepot 05-19-2005 09:49 PM

alkhashrami,

Your mod worked excellent in 4.0.13

All I did was follow your instructions. *smile*

thanks.

- Shannon

alkhashrami 05-20-2005 02:09 AM

Thank you IndieDepot,

this is what i hope


and don't foreget that the original code was posted by walteis


i hope the users of x-cart will find this mod useful as i do.

ShishaPipeUK 04-01-2006 08:12 AM

Hi, just curious, whe do we have 2 instances off {include file="customer/main/navigation.tpl"}

Code:

{include file="customer/main/navigation.tpl"}

{include file="customer/main/products.tpl" products=$newproducts}


 

{include file="customer/main/navigation.tpl"}


MOC 04-21-2006 12:54 PM

How can i get this mod running on 3.5.14?

cherie 06-14-2006 02:40 PM

Quote:

Originally Posted by ShishaPipeUK
Hi, just curious, whe do we have 2 instances off {include file="customer/main/navigation.tpl"}

Code:

{include file="customer/main/navigation.tpl"}

{include file="customer/main/products.tpl" products=$newproducts}


 

{include file="customer/main/navigation.tpl"}


This is the display of page navigation at the top of the page and at the bottom (two). :D

admintds 08-06-2006 07:19 PM

Re: What's new mod
 
Quote:

Originally Posted by walteis


Then I added a config table setting called TFTACustom.wndays, you can call it anything you'd like.

Assuming that you called it that, you can then add a link in the categories.tpl

Code:

What's New


This mod works as written with 4.0.7

Walt


My question is this...I've done everything else from your original post...cept this. Not sure where or how to do t his? I have a new products box showing up on my homepage....but nothing is in it. Is this what I need to do for product to show up??? And if so...how?

Thank you in advance...
Janel

subzero 08-24-2006 03:29 AM

Re: What's new mod
 
Quote:

Originally Posted by admintds
Originally Posted by walteis


Then I added a config table setting called TFTACustom.wndays, you can call it anything you'd like.

Assuming that you called it that, you can then add a link in the categories.tpl

Code:

What's New


This mod works as written with 4.0.7

Walt
My question is this...I've done everything else from your original post...cept this. Not sure where or how to do t his? I have a new products box showing up on my homepage....but nothing is in it. Is this what I need to do for product to show up??? And if so...how?

Thank you in advance...
Janel



i have almost the same problem as you
i did everything but the config table bit as i wasnt sure what to do there
only difference is i dont seem to have any box showing on my home page
its almost as if i had never added the mod at all

anyone help me???

PhilJ 01-11-2007 05:39 AM

Re: What's new mod
 
1 Attachment(s)
Thanks for the mod, seems to work fine in v4.x.
16/1/08 - UPDATED TO FIX SECURITY RISK

tangal 01-31-2007 10:06 AM

Re: What's new mod
 
Hi!

I am using X-Cart Pro 4.1.5 and am looking to install this modification .. I'm at this point:
3) In /skin1/customer/home_main.tpl
Add the following...
{elseif $wn ne ""}
{include file="customer/newest.tpl"}

Instead of adding it to my home_main.tpl, I'd like to add a link in my categories menu. Does anyone have any newbie advice on how to do this? I found my categories.tpl but I am not sure what to add (the above code?) and where to add it in the code.

Thanks in advance for any help with this :)

JWait 02-05-2007 01:33 PM

Re: What's new mod
 
I don't think this mod works with version 4.1.x. It works fine with version 4.0.x though.

Anyway, the newest.tpl refers to the output page I believe. You need to call newproduct.php (or whatever its called) from a link.

Jerrad 02-12-2007 04:49 AM

Re: What's new mod
 
Thanks for this mod. I've got it working, but somehow loading the page(s) with the newest products takes ages... :?

Anybody got a idea what could be causing this?
Thanks!

hwayneb 02-24-2007 04:15 PM

Re: What's new mod
 
Does this Mod work with 4.1.3 ????

When I install this - It returns all the products.

paryaei 02-24-2007 11:09 PM

Re: What's new mod
 
The same here . whatever # you set it on , still returns all the products !!!
philj maybe able to answer this !!!

mesut 04-06-2007 10:44 PM

Re: What's new mod
 
I have exact same problem. It does not matter what you put for wn. It shows just all products.

for example my store has totaly 25 products. wn=1 or wn=7 all 25 products appears then.

I did not get it.

Any help?

JediSam04 05-30-2007 08:59 AM

Re: What's new mod
 
Is there any chance that this mod will be updated to work with 4.1.7?

fogelka 07-21-2007 10:55 PM

Re: What's new mod
 
This mod works great, except...

Example:
I want to see the items added in the last 14 days. Site is set to show 12 items per page.
** I have 15 new items.
** I call the script, and it shows the first 12 items.
** I click on the page 2 button, but instead of the remaining 3 items, I get most or all the items on the site.

I can see that when I hover over the page 2 button, it is going to go to:

www.domain.com/search.php?mode=search&page=2

Wheras the first page is on:

www.domain.com/newest.php?wn=14


Ideas, anyone?

- Ken

JWait 07-22-2007 04:49 AM

Re: What's new mod
 
See the thread at http://forum.x-cart.com/showthread.php?t=1084 for a working version similar to this mod (I think its better) for 4.0.x and later in the thread (around page 19) a working version for 4.1.x

Jon 01-16-2008 07:44 AM

Re: What's new mod
 
If you are using the first version on this page, you need to add this code into your newest.php at the very top or you are vulnerable to being hacked:

Code:

<?php
if ( !defined('XCART_SESSION_START') ) { header("Location: ../../"); die("Access denied"); }
(int)$wn;
?>



If you are using the version posted by PhilJ then find:

Code:

require "./auth.php";
require $xcart_dir."/include/categories.php";



After put:

Code:

(int)$wn;


All times are GMT -8. The time now is 05:11 AM.

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