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)
-   -   Newest Products (https://forum.x-cart.com/showthread.php?t=1084)

BHMedia 09-29-2004 07:50 PM

you know what would make this a killer mod - we have a site that ads over 500 products a week - so this mod would just pull out X amount - to eaither make it have it so it can have XXXXX Products but if it is over 10 on a page it will show the 1 2 3 4 5 6 on top or just have like RANDOM newest products... how would i do that?

BHMedia 09-29-2004 08:05 PM

Im not sure if this part is even worth posting but I figured it out..

I wanted to make it so it will just RANDOM the 6 products i had there... Because my client has so many updated products...

here goes

all you have to do is change the query from


Code:

$query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid=$sql_tbl[pricing].productid AND add_date > " . $oldtime . " AND add_date < " . $nowtime . " ORDER BY xcart_products.productID DESC LIMIT 0,5 ";

to

Code:

// the database query
$query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid=$sql_tbl[pricing].productid AND add_date > " . $oldtime . " AND add_date < " . $nowtime . " ORDER BY RAND() LIMIT 6 ";



Hope this helps... This works for 4.03...

mizzlewillz 09-30-2004 09:28 AM

This is a nice mod. After playing around with the settings I was able to limit the choices to a certain category, but is there a way to make it so there are more than one page similar to the products.tpl. We will be adding lots of products each week and would like to list them 10 to 15 items to a page rather than all the new products at once. I thought X-cart would break them into pages but it doesn't.

Also, when working with this mod in 4.0.4 instead of a price it says "enter a price!" I know someone besides me has had this problem, but did anyone find a solution to that.

Any comments is appreciated.

-Mike

BHMedia 09-30-2004 07:15 PM

I just cleared out the label so it reads nothing... I cant figure it out tho...

finestshops 10-01-2004 05:22 PM

Quote:

Originally Posted by mizzlewillz
Also, when working with this mod in 4.0.4 instead of a price it says "enter a price!" I know someone besides me has had this problem, but did anyone find a solution to that.
-Mike


Hi there,

Here is modified newest.php which works in 4.0.4 and shows the price and loads images from server, not via image.php

Code:

<?
#
# $Id: newest.php by FS (based on featured_products.php and newest.php by funkydunk), v 1.2.2.3m 2004/10/01 Exp $

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

#
# Get newest products data and store it into $newproducts array
#

if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); }

#
# select from products table
#

$membership = !empty($user_account['membership'])?$user_account['membership']:"";
$f_cat = (empty ($cat) ? "0" : $cat);
if ($config["General"]["unlimited_products"]=="N" && $config["General"]["disable_outofstock_products"])
        $avail_condition = "($sql_tbl[products].avail>0 OR $sql_tbl[products].product_type='C') and ";
else
        $avail_condition = "";
// $newproducts = func_query("SELECT $sql_tbl[products].*, min($sql_tbl[pricing].price) as price FROM $sql_tbl[products], $sql_tbl[products] USE INDEX (pacpo), $sql_tbl[pricing] WHERE $sql_tbl[products].productid=$sql_tbl[featured_products].productid and $sql_tbl[pricing].productid=$sql_tbl[products].productid and $sql_tbl[products].forsale='Y' and $avail_condition $sql_tbl[featured_products].avail='Y' and $sql_tbl[pricing].quantity=1 AND $sql_tbl[pricing].variantid = 0 AND $sql_tbl[featured_products].categoryid='$f_cat' and ($sql_tbl[pricing].membership='$membership' or $sql_tbl[pricing].membership='') GROUP BY $sql_tbl[products].productid ORDER BY $sql_tbl[featured_products].product_order");
$query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 AND $sql_tbl[pricing].productid=$sql_tbl[products].productid AND add_date > " . $oldtime . " AND add_date < " . $nowtime . " ORDER BY xcart_products.productID DESC LIMIT 0,6 ";
$newproducts = func_query($query);

if(is_array($newproducts)){
    foreach($newproducts as $f_v => $f_k){
        $int_res = '';
        if(is_array($f_k)){
                        if(!empty($active_modules['Product_Options'])) {
                                $tmp_price = func_get_price_default_variant($newproducts[$f_v]['productid'], @$user_account['membership']);
                                if ($tmp_price)
                                        $newproducts[$f_v]["price"] = $tmp_price;
                        }

#
# Get thumbnail's URL (uses only if images stored in FS)

                        $newproducts[$f_v]["tmbn_url"] = func_get_thumbnail_url($newproducts[$f_v]["productid"]);
#
# Recalculate prices if VAT is enabled and prices do not includes VAT
#
                        $newproducts[$f_v]["taxes"] = func_get_product_taxes($newproducts[$f_v], $login);

#
# Check if product have product options
#
                        if(!empty($active_modules['Product_Options'])) {
                                $newproducts[$f_v]["product_options"] = func_query_first_cell("SELECT COUNT(*) FROM $sql_tbl[classes] WHERE productid='".$f_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='".$f_k['productid']."'");
                        if (!empty($int_res["product"])) {
                                $newproducts[$f_v]["product"] = stripslashes($int_res["product"]);
                    }   
                if (!empty($int_res["descr"])) {
                            $newproducts[$f_v]["descr"] = str_replace("\n","
", stripslashes($int_res["descr"]));
                    }   
                    if (!empty($int_res["full_descr"])) {
                        $newproducts[$f_v]["fulldescr"] = str_replace("\n","
", stripslashes($int_res["full_descr"]));
                    }

                        if ($newproducts[$f_v]["descr"] == strip_tags($newproducts[$f_v]["descr"]))
                                $newproducts[$f_v]["descr"] = str_replace("\n", "
", $newproducts[$f_v]["descr"]);

                        if ($newproducts[$f_v]["fulldescr"] == strip_tags($newproducts[$f_v]["fulldescr"]))
                                $newproducts[$f_v]["fulldescr"] = str_replace("\n", "
", $newproducts[$f_v]["fulldescr"]);

                }       
        }
}; 


if (!empty($active_modules["Subscriptions"])) {
    include_once $xcart_dir."/modules/Subscriptions/subscription.php";
}
       
$smarty->assign("newproducts",$newproducts);

// give the product array to smarty to make it available sitewide.
$smarty->assign("newproducts",$newproducts);


?>


Example is here:

http://www.shopping-carts-upgrades.com/store/

:D

Enjoy,

hobbyhandig 10-22-2004 01:49 AM

Using 4.0.5, newest.php gives an parse error on line 23

http://hobbyhandig.webfontein.nl

What did I do wrong?

hobbyhandig 11-01-2004 02:01 AM

Anyone? I really want this mod, but it doesn't work! :roll:

B00MER 11-01-2004 05:40 AM

:arrow: http://www.cart-lab.com/Newest_Products-p-53.html Easier to use and setup :D

hobbyhandig 11-01-2004 06:00 AM

Hi Boomer,

If it were my money I would buy it! :D

But my boss has to pay, so I would really like if I can get the free version to work for me, like all these people in this topic before me! :wink:

StitchClix 11-17-2004 12:40 PM

OK, I hate to be a newbie. I've gotten this to work on the home page, but how do you make an independent page displaying only the new items. I've read this whole section several times, and maybe I just don't know what I'm looking for, but I can't figure it out. Any help would be hugely appreciated.

Mike
StitchClix.com


All times are GMT -8. The time now is 04:30 PM.

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