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

Newest Products

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #81  
Old 04-08-2005, 02:20 AM
 
tron tron is offline
 

Advanced Member
  
Join Date: Jun 2003
Location: Oslo
Posts: 46
 

Default problem solved

I was having problems also. I am using 3.4.2.

I followed all the steps and had to redo it twice. not working.

then I found this:

http://forum.x-cart.com/viewtopic.php?t=1402&highlight=newest+tpl

I replaced the codes and now it's working.
Reply With Quote
  #82  
Old 04-12-2005, 02:31 PM
  2019's Avatar 
2019 2019 is offline
 

Advanced Member
  
Join Date: Dec 2004
Posts: 76
 

Default

ShishaPipe i see that you make it work on 4.0.x
can you post codes here?
i couldn't make it work with my cart!

some1 pls?
__________________
// x-cart 4.1.9

X-CART CSS SKIN
XC SEO
IP Addresses in Users Online for all users
Color coded order status
Reply With Quote
  #83  
Old 05-19-2005, 09:32 PM
 
IndieDepot IndieDepot is offline
 

Advanced Member
  
Join Date: May 2005
Posts: 30
 

Default

I would also like a "Newest Products" mod for 4.0.13.

Can anybody post the code?

- Shannon
__________________
- www.TheShotList.com
X-Cart version 4.0.13
PHP 4.3.10
MySQL 4.0.23
Web server Apache
Operation system Linux
Perl 5.008004
XML parser (expat) 1.95.6
Reply With Quote
  #84  
Old 06-21-2005, 09:47 AM
 
gemanda gemanda is offline
 

Advanced Member
  
Join Date: Sep 2004
Posts: 44
 

Default

I've tried to get this to work...I have the Firetank newest products dialog, so that's not an issue. But I need to get a page of newest products, which that mod doesn't offer.

However, when I try everything in this thread, it looks all crazy. Any ideas on how to get the page to look like a normal product page?

Here's the craziness that it is now.

http://wholefamilymarket.com/shop/newest.php
__________________
X-Cart Pro 4.1.10 - new install
X-Affiliate 4.1.x
X-Gift Reg 4.1.x

Linux Server
Reply With Quote
  #85  
Old 06-26-2005, 01:05 AM
 
craigbrass craigbrass is offline
 

Advanced Member
  
Join Date: May 2005
Location: Cumbria, UK
Posts: 80
 

Default

How would I get it to show as a box like on http://www.itselixir.net/home.php as "Best Sellers" do?
__________________
Its Elixir - www.itselixir.com
Product: X-Cart Gold
Version: 4.0.17
Status: Live

Its Elixir Wholesale - www.itselixirwholesale.com
Product: X-Cart Gold
Version: 4.0.17
Status: In Development

Real Champagne - www.realchampagne.com
Product: X-Cart Gold
Version: 4.0.17
Status: In Development
Reply With Quote
  #86  
Old 09-13-2005, 09:25 AM
 
Lucent88 Lucent88 is offline
 

Senior Member
  
Join Date: Aug 2005
Posts: 147
 

Default

anyone find out how to have to this work for v4.x yet?
Reply With Quote
  #87  
Old 09-13-2005, 12:32 PM
 
WPOO WPOO is offline
 

Advanced Member
  
Join Date: May 2004
Location: Delft - Netherlands -
Posts: 31
 

Default i would like too use this too

i would like too use this too
__________________
X-Cart Gold 4.13
X-Configurator
X-ROM
Easy Checkout
Reply With Quote
  #88  
Old 09-16-2005, 12:41 PM
 
lapidarist lapidarist is offline
 

Advanced Member
  
Join Date: Apr 2003
Location: Hot Springs, Arkansas
Posts: 34
 

Default dd

Quote:
Originally Posted by gemanda
I've tried to get this to work...I have the Firetank newest products dialog, so that's not an issue. But I need to get a page of newest products, which that mod doesn't offer.

However, when I try everything in this thread, it looks all crazy. Any ideas on how to get the page to look like a normal product page?

Here's the craziness that it is now.

http://wholefamilymarket.com/shop/newest.php

I needed a way to show new products added. I wanted a page that had more information and gave some options. I have been working on one for my site. I am new to php and have only made a few small mods in xcart before.

My site is live, but you can see the new products page I have been working on. If this is something that looks interesting, I can clean it up some and post it.

http://www.unconventionallapidarist.com/xcart/newproducts.php

I am still looking for the code that sets the <site_name> :: <current> navigation link.

My cart is 4.0.15

- james -
__________________
X-Cart Gold Plus 4.5.4
X-PDF 4.5.3
X-Payments 1.05
CDSEO Pro 1.8.7
WebsiteCM Product Map 2.0.1
WebsiteCM Next-Prev 1.3 disabled because of SQL errors and bugs.
Reply With Quote
  #89  
Old 09-21-2005, 12:22 PM
  MythNReality's Avatar 
MythNReality MythNReality is offline
 

X-Adept
  
Join Date: Mar 2005
Location: S. Cali
Posts: 403
 

Default Re: dd

Quote:
Originally Posted by lapidarist
I am still looking for the code that sets the <site_name> :: <current> navigation link.



James,

Your site looks great, that's the way I wanted to get done...would you please "share" the code and show us how, please~
__________________
_____________
Capture Your Mini-Me Look!

- X-CART Gold (Current Version) V4.6
- Reboot
- CDSEO
Reply With Quote
  #90  
Old 09-23-2005, 07:53 PM
 
lapidarist lapidarist is offline
 

Advanced Member
  
Join Date: Apr 2003
Location: Hot Springs, Arkansas
Posts: 34
 

Default New Products page

This is my first xcart add-on. I wrote some code to show New Products on its own page.

Crude install notes

1) You need to edit {xcart_dir}/skin1/customer/home_main.tpl

Add the following lines before the {else} at bottom of file:

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



2) Copy newproducts.tpl file to {$xcart_dir}/skin1/customer/main/

example: /xcart/skin1/customer/main/newproducts.tpl


3) Copy newproducts.php file to {xcart_dir}/

example: /xcart/newproducts.php


4) Apply the SQL Language file 'language.sql' into the Patch file section
of the X-cart Admin :: Patch/Upgrade center. Or load via mysql



5) You should now be able to put a link using

<domain_name>/{$xcart_dir}/newproducts.php


You can add the link anywhere (speed bar, href, help section, etc).


Let me know if this is useful to you

James



Save this file as newproducts.php
Code:
<? #+-----------------------------------------------------------------------------+ #| New Products add-on | #| Copyright (c) 2005 James Carpenter <jamesc@unconventionallapidarist.com> | #| All rights reserved. | #+-----------------------------------------------------------------------------+ # # $Id: newproducts.php,v 1.0.0.1 2005/09/23 05:00:00 jfc Exp $ # require "./auth.php"; require $xcart_dir."/include/categories.php"; # I am not sure what the membership should be set. On a generic # Try to determine how to get this info from the current environment. $membership = ""; # this could be set as a config option if (!$days || $days == 0) {$days = 7;} # default sorting if needed. This could be a config option. if (!$sortby || $sortby == "") { $sortby = "add_date"; } # This array is used to determine the from/to date range # in the WHERE clause. It is also used for the labels # for the range. $newproducts_dayrange = array( 1 => func_get_langvar_by_name("lbl_newproducts_24hrs"), 3 => func_get_langvar_by_name("lbl_newproducts_3days"), 7 => func_get_langvar_by_name("lbl_newproducts_7days"), 30 => func_get_langvar_by_name("lbl_newproducts_30days") ); # This array is used to determine the order by clause and labels # used for sorting $sort_fields = array( "add_date" => func_get_langvar_by_name("lbl_newproducts_adddate"), "productcode" => func_get_langvar_by_name("lbl_newproducts_sku"), "product" => func_get_langvar_by_name("lbl_newproducts_product"), "price" => func_get_langvar_by_name("lbl_newproducts_price") ); # set date ranges $date_range = 86400 * (integer)$days; // 60(sec) * 60(min) * 24(hrs) * $days in unix time $now_time = time(); $from_time = $now_time - $date_range; $query = "AND $sql_tbl[products].avail > 0 AND add_date > $from_time AND add_date < $now_time "; # set the default $newproducts = ""; # The function 'func_search_products' was taken from '{xcart_dir}/include/func.php' # in version 4.0.16 # It was modified to give more product data back (descr,fulldescr, etc) and # to be able to get the count that the query would return. # function func_search_newproducts($query, $membership, $retcount, $orderby="", $limit="") { global $current_area, $user_account; global $store_language, $sql_tbl; global $config; global $cart, $login; global $active_modules; # # Generate ORDER BY rule # if (empty($orderby)) { $orderby = ($config["Appearance"]["products_order"] ? $config["Appearance"]["products_order"] : "orderby"); if($orderby == 'title') { $orderby = 'product'; } elseif($orderby == 'quantity') { $orderby = "$sql_tbl[products].avail"; } elseif($orderby == "orderby") { $orderby = "$sql_tbl[products_categories].orderby"; } elseif($orderby == "quantity") { $orderby = "$sql_tbl[products].avail"; } elseif($orderby == "price") { $orderby = "price"; } elseif($orderby == "productcode") { $orderby = "$sql_tbl[products].productcode"; } } # # Generate membership condition # if ($current_area == "C") { $membership_condition = " AND ($sql_tbl[categories].membership='".addslashes($membership)."' OR $sql_tbl[categories].membership='') AND $sql_tbl[products].forsale='Y'"; } else $membership_condition = ""; # # Generate products availability condition # if ($config["General"]["unlimited_products"]=="N" && (($current_area == "C" || $current_area == "B") && $config["General"]["disable_outofstock_products"] == "Y")) $avail_condition = " AND $sql_tbl[products].avail>0 "; else $avail_condition = ""; #$select_query = "SELECT $sql_tbl[products].productid, $sql_tbl[products].product, $sql_tbl[products].productcode, $sql_tbl[products].avail, MIN($sql_tbl[pricing].price) AS price"; if ($retcount == 'Y') { $select_query = "SELECT COUNT($sql_tbl[products].productid)"; } else { $select_query = "SELECT $sql_tbl[products].*, MIN($sql_tbl[pricing].price) AS price"; } $from_query = " FROM $sql_tbl[products], $sql_tbl[categories], $sql_tbl[products_categories], $sql_tbl[pricing]"; $where_query = " WHERE $sql_tbl[products].productid=$sql_tbl[products_categories].productid AND $sql_tbl[products_categories].categoryid=$sql_tbl[categories].categoryid AND $sql_tbl[products].productid=$sql_tbl[pricing].productid AND $sql_tbl[pricing].quantity=1 AND ($sql_tbl[pricing].membership='".addslashes($membership)."' OR $sql_tbl[pricing].membership='') $membership_condition $avail_condition"; $where_query .= " AND $sql_tbl[pricing].variantid = 0"; if ($current_area == 'C' && empty($active_modules['Product_Configurator'])) { $where_query .= " AND $sql_tbl[products].product_type <> 'C' AND $sql_tbl[products].product_type <> 'B' "; } $groupby_query = " GROUP BY $sql_tbl[products].productid"; $orderby_query = " ORDER BY $orderby"; if (!empty($limit)) $limit_query = " LIMIT $limit"; if ($retcount == 'Y') { $search_query = $select_query.$from_query.$where_query.$query.$groupby_query; # print "QUERY: $search_query\n\n"; $result = db_query($search_query); $total_items = db_num_rows($result); # print "Total Items: $total_items\n"; db_free_result($result); $result = $total_items; } else { # # Check if product have prodyct class (Feature comparison) # if(!empty($active_modules['Feature_Comparison']) && $current_area == "C") { global $comparison_list_ids; $from_query .= " LEFT JOIN $sql_tbl[product_features] ON $sql_tbl[product_features].productid = $sql_tbl[products].productid"; $select_query .= ", $sql_tbl[product_features].fclassid"; if(($config['Feature_Comparison']['fcomparison_show_product_list'] == 'Y') && $config['Feature_Comparison']['fcomparison_max_product_list'] > @count((array)$comparison_list_ids)) { $select_query .= ", IF($sql_tbl[product_features].fclassid IS NULL || $sql_tbl[product_features].productid IN ('".@implode("','",@array_keys((array)$comparison_list_ids))."'),'','Y') as is_clist"; } } # # Check if product have product options (Product options) # if(!empty($active_modules['Product_Options'])) { $from_query .= " LEFT JOIN $sql_tbl[classes] ON $sql_tbl[classes].productid = $sql_tbl[products].productid LEFT JOIN $sql_tbl[variants] ON $sql_tbl[variants].productid = $sql_tbl[products].productid"; if ($current_area == 'C' && $config["General"]["disable_outofstock_products"] == "Y" && $config["General"]["unlimited_products"] != "Y") { $from_query .= " AND $sql_tbl[variants].avail > 0"; } $select_query .= ", SUM(IF($sql_tbl[classes].classid IS NULL,0,1)) as product_options, IF ($sql_tbl[classes].classid IS NULL,'','Y') as is_product_options, IF($sql_tbl[variants].variantid IS NULL,'','Y') as is_variant"; } if ($current_area == "C" && $store_language != $config["default_customer_language"]) $from_query .= " LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid"; # # Generate search query # $search_query = $select_query.$from_query.$where_query.$query.$groupby_query.$orderby_query.$limit_query; $result = func_query($search_query); if ($result && ($current_area=="C" || $current_area=="B") ) { # # Post-process the result products array # foreach ($result as $key=>$value) { if (!empty($cart) and !empty($cart["products"]) && $current_area=="C") { # # Update quantity for products that already placed into the cart # $in_cart = 0; foreach ($cart["products"] as $cart_item) if ($cart_item["productid"] == $value["productid"]) $in_cart += $cart_item["amount"]; $result[$key]["avail"] -= $in_cart; } # # Get thumbnail's URL (uses only if images stored in FS) # $result[$key]["tmbn_url"] = func_get_thumbnail_url($result[$key]["productid"]); if ($current_area == "C") { $result[$key]["taxes"] = func_get_product_taxes($result[$key], $login); } # # Check if product have product options # $int_res = func_query_first("SELECT * FROM $sql_tbl[products_lng] WHERE code='$store_language' AND productid='$value[productid]'"); if (!empty($int_res["product"])) $result[$key]["product"] = stripslashes($int_res["product"]); if (!empty($int_res["descr"])) $result[$key]["descr"] = stripslashes($int_res["descr"]); if ($result[$key]["descr"] == strip_tags($result[$key]["descr"])) $result[$key]["descr"] = str_replace("\n", " ", $result[$key]["descr"]); if (!empty($int_res["full_descr"])) $result[$key]["full_descr"] = stripslashes($int_res["full_descr"]); if ($result[$key]["full_descr"] == strip_tags($result[$key]["full_descr"])) $result[$key]["full_descr"] = str_replace("\n", " ", $result[$key]["full_descr"]); } } } return $result; } # determine how many products fit the query criteria. $total_items = func_search_newproducts($query, $membership, $retcount="Y"); if ($total_items > 0) { # # Prepare the page navigation # if(!isset($objects_per_page)) { if ($current_area == "C" || $current_area == "B") $objects_per_page = $config["Appearance"]["products_per_page"]; else $objects_per_page = $config["Appearance"]["products_per_page_admin"]; } $total_nav_pages = ceil($total_items/$objects_per_page)+1; # calculate the upper and lower LIMIT for the SQL statement if (($page == 1) || $page == "") {$lowerLimit = 0; } else {$lowerLimit = (($page - 1) * $objects_per_page); } if ($sortby == "price") { $sortorder = "$sql_tbl[pricing].$sortby";} else { $sortorder = "$sql_tbl[products].$sortby"; } if (!sortdirection || ($sortdirection == "") || ($sortdirection == "0")) { $sort_dir = "desc"; $sortdirection = "0"; } else { $sort_dir = "asc"; $sortdirection = "1"; } } # if we have items to show.. go get them.. if not it will default to empty string "". if ($total_items > 0) { # get the product list that is limited to the page we need to display. $newproducts = func_search_newproducts($query, $membership, $retcount="N", $orderby="$sortorder $sort_dir", $limit="$lowerLimit, $objects_per_page"); } # If I want to have a secondary sort with the product code? Haven't decided yet #$newproducts = func_search_newproducts($query, $membership, $retcount="N", $orderby="$sortorder $sort_dir, $sql_tbl[products].productcode $sort_dir", $limit="$lowerLimit, $objects_per_page"); include $xcart_dir."/include/navigation.php"; # flag set that is used in home_main.tpl $smarty->assign("main","newproducts"); $smarty->assign("newproducts_dayrange", $newproducts_dayrange); $smarty->assign("sort_fields", $sort_fields); $smarty->assign("days",$days); $smarty->assign("sortby",$sortby); $smarty->assign("sortdirection",$sortdirection); # give the product array to smarty to make it available sitewide. $smarty->assign("products",$newproducts); $smarty->assign("first_item", $first_page+1); $smarty->assign("last_item", min($first_page+$objects_per_page, $total_items)); $smarty->assign("total_items",$total_items); $smarty->assign("navigation_script","newproducts.php?days=$days&sortby=$sortby&sort_direction=$sort_direction"); # create the location bar xxx :: New Products $location[] = array(func_get_langvar_by_name("lbl_newproducts"), "newproducts.php"); $smarty->assign("location",$location); # This function will start the display of the .tpl's func_display("customer/home.tpl",$smarty); ?>

Save as newproducts.tpl
Code:
{* $Id: newproducts.tpl,v 1.0.0.1 2005/09/23 01:00:00 jfc Exp $ *} {* This uses $lng.lbl_newproducts_since => "Products added since" $lng.lbl_newproducts => "New Products" *} {if ($navigation_page eq "")||($navigation_page eq "1")}{$current_category.description|regex_replace:"/[\n]/":" "} {/if} {capture name=dialog} {assign var="tmp" value="0"} {assign var="url" value="newproducts.php?"} {* ext-1 - this could be moved to a new .tpl file *} <font size="2">{$lng.lbl_newproducts_since}: {foreach from=$newproducts_dayrange key=name item=field} {if $name eq $days}{$field}{else}{$field}{/if} {/foreach} </font> {* ext-1 *} {if $products ne "" } <BR clear="left"> <HR size="1" noshade> {/if} {if !empty($products) && is_array($products)} {* ext-2 - this could be moved to a new .tpl file *} {if $sort_fields} <DIV align="right"><font size="2"> {$lng.lbl_sort_by}: {foreach from=$sort_fields key=name item=field} {if $name eq $sortby}[img]{$ImagesDir}/{if $sortdirection eq [/img]{/if}{$field}{if $name eq $sortby}{/if} {/foreach}</font> </DIV> {/if} {* ext-2 *} {if $total_pages gt 2} { include file="customer/main/navigation.tpl" } {/if} <HR size="1" width="100%"> {include file="customer/main/products.tpl" products=$products} {else} {$lng.txt_no_newproducts} {/if} {/capture} {include file="dialog.tpl" title=$lng.lbl_newproducts content=$smarty.capture.dialog extra="width=100%"} { include file="customer/main/navigation.tpl" }

Save file as language.sql
Quote:
INSERT INTO xcart_languages (code, descr,name,value,topic) VALUES ('US','New Products','lbl_newproducts','New Products','Labels');
INSERT INTO xcart_languages (code, descr,name,value,topic) VALUES ('US','New Products added since (days)','lbl_newproducts_since','Products added since','Labels');

INSERT INTO xcart_languages (code, descr,name,value,topic) VALUES ('US','24 hour label','lbl_newproducts_24hrs','24 Hours','Labels');
INSERT INTO xcart_languages (code, descr,name,value,topic) VALUES ('US','3 day label','lbl_newproducts_3days','3 Days','Labels');
INSERT INTO xcart_languages (code, descr,name,value,topic) VALUES ('US','7 day label','lbl_newproducts_7days','7 Days','Labels');
INSERT INTO xcart_languages (code, descr,name,value,topic) VALUES ('US','30 days label','lbl_newproducts_30days','30 Days','Labels');


INSERT INTO xcart_languages (code, descr,name,value,topic) VALUES ('US','New Products add_date','lbl_newproducts_adddate','Add Date','Labels');
INSERT INTO xcart_languages (code, descr,name,value,topic) VALUES ('US','New Products add_date','lbl_newproducts_sku','SKU','Labels');
INSERT INTO xcart_languages (code, descr,name,value,topic) VALUES ('US','New Products add_date','lbl_newproducts_product','Title','Label s');
INSERT INTO xcart_languages (code, descr,name,value,topic) VALUES ('US','New Products add_date','lbl_newproducts_price','Price','Labels' );

INSERT INTO xcart_languages (code, descr,name,value,topic) VALUES ('US','New Products not found','txt_no_newproducts','No new products have been listed within timeframe you specified','Text');


Here is an example on my site. This site is a live site.
http://www.unconventionallapidarist.com/xcart/newproducts.php
__________________
X-Cart Gold Plus 4.5.4
X-PDF 4.5.3
X-Payments 1.05
CDSEO Pro 1.8.7
WebsiteCM Product Map 2.0.1
WebsiteCM Next-Prev 1.3 disabled because of SQL errors and bugs.
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 11:15 AM.

   

 
X-Cart forums © 2001-2020