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)
-   -   ITEMS FOR SALE (https://forum.x-cart.com/showthread.php?t=7446)

daddyroy 05-05-2004 09:28 AM

ITEMS FOR SALE
 
Greetings everyone. I want to have a "ITEMS FOR SALE PAGE", is there a way to setup a query using "Price " and "List Price", so for every item whose list price is for example $20.00 over current price, then that item would be returned in the query and can be classified as an item ON SALE. I will figure it out eventually but anyhelp is appreciated!! Thanks.

shan 05-05-2004 01:16 PM

i moved your post as the custom mods forum is for finished mods only.

The best place to start here is taking a look at the bestsellers module. You can adjust the idea behind this to fit your needs

daddyroy 05-05-2004 03:50 PM

ON SALE PAGE COMPLETE
 
I said I would figure it out and I did. I will post in 5 min!!

daddyroy 05-05-2004 04:07 PM

ON SALE CONTINUED ...........
 
1) First create a file called "on_sale.php" --> customer/on_sale.php:


Code:

<?
#
# $Id: on_sale.php,v 1.14.2.2 2004/02/05 12:29:22 mclap Exp $
#

require "../smarty.php";
require "../config.php";
@include "./https.php";
require "./auth.php";
require "../include/categories.php";
require "./sales_items.php";


#
# Assign Smarty variables and show template
#
$tmp = strstr($QUERY_STRING, "$XCART_SESSION_NAME=");
if (!empty($tmp)) 
        $QUERY_STRING = ereg_replace("([&]*)$XCART_SESSION_NAME=([0-9a-zA-Z]*)([&]*)", "", $QUERY_STRING);
       
if ( !defined('XCART_SESSION_START') ) { header("Location: home.php"); die("Access denied"); }
if ($new)
        $smarty->assign("sales",mainsales);
$smarty->display("customer/sales.tpl");
?>



2) The create a file called "sales_items.php" ---> customer/sales_items.php:

Code:

<?

// the database query
$query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].list_price - $sql_tbl[pricing].price > 20 ORDER BY xcart_products.productID DESC LIMIT 0,6 ";


// give the product array to smarty to make it available sitewide.
$salesproducts = func_query($query);
$smarty->assign("salesproducts",$salesproducts);
?>


PLEASE NOTE IN: "$sql_tbl[products].list_price - $sql_tbl[pricing].price > 20" THAT 20 can be any number you choose!!!

3) Now go to "skin1/customer" and create the following 3 files:

- #new_sales.tpl#

Code:

{capture name=dialog}
{if $salesproducts ne ""}
{include file="customer/onsale.tpl" products=$salesproducts}
{else}
{$lng.txt_sales_items}
{/if}
{/capture}
{include file="dialog.tpl" title=$lng.lbl_sales_items content=$smarty.capture.dialog extra="width=100%"}


- #on_sale.tpl#

Code:

{* $Id: onsale.tpl,v 1.2 2003/04/24 09:50:33 svowl Exp $ *}
<center><table border=0 width="100%"><tr><td>

  <center><table border=0 width=100%>

  {section name=product loop=$products}
  {if $smarty.section.product.index is div by 2}
    </tr><tr valign="top">
  {/if}

  <td valign="top"width=350>

    <center><table border=0 width=100%><tr>
      <td width=150 align=center valign=top><a href=product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}>{include file="product_thumbnail.tpl" productid=$products[product].productid product=$products[product].product}
{$products[product].param02}


 
</td>
      <td valign=top width=200>{$products[product].product|escape}</font>
<font size=1>{$products[product].descr|truncate:80:"...":true}</font>
<hr size=1 noshade width=130 align=left>
      {if $active_modules.Subscriptions ne "" and $products[product].catalogprice}
      {include file="modules/Subscriptions/subscription_info_inlist.tpl"}
      {else}
      {if $products[product].price ne 0}
      {if $products[product].discount ne 0}
      <font class=MarketPrice>{$lng.lbl_market_price}: <s>{math equation="(price/(100-discount))*100" price=$products[product].price discount=$products[product].discount format="%d.00" assign=unformatted}{include file="currency.tpl" value=$unformatted}</s></font>
 
      {/if}
      <font class=TableCenterProductTitleOrange>{include file="currency.tpl" value=$products[product].price}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].price}</font>{if $products[product].discount ne 0}, save {$products[product].discount}%{/if}
      {else}
      <font class=TableCenterProductTitleOrange>{$lng.lbl_enter_your_price}</font>
      {/if}
      {/if}
      </td></tr>
    </table>
</center>

  </td>

  {/section}

</td></tr></table></center>
</td></tr></table> </center>


And finally:

- #sales.tpl#

Code:

{* $Id: sales.tpl,v 1.3 2003/04/09 10:13:30 olga Exp $ *}
{ config_load file="$skin_config" }
<html>
<head>
<title>

Uppity Footwear - On Sale!!!!</title>
{ include file="meta.tpl" }
<link rel="stylesheet" href="{$SkinDir}/{#CSSFile#}">
</head>
<body LEFTMARGIN=0 TOPMARGIN=0 RIGHTMARGIN=0 BOTTOMMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>{ include file="head.tpl" }

<table border=0 width="750" cellpadding=0 cellspacing=0 align="center">
<tr>
<td valign=top width=750>






{include file="customer/new_sales.tpl"}






</td>
</tr>
</table>
{ include file="rectangle_bottom.tpl" }
</body>
</html>



Now where ever you have your main links, whether in "head.tpl" or in "rectangle_bottom.tpl" go and add your link to the on_sale.php page there!!

Remember if you're using DHTML Drop down menus, you have to add you javascript code to the meta.tpl file, without "{literal} {/literal}. That's it. I will continue to post as I figure new things out. I appreciate all of the posts that everyone has made. They have helped me tremendously. I will do the same in return!!

shan 05-05-2004 04:32 PM

and back to custom mods we go :wink:

daddyroy 05-05-2004 06:31 PM

CORRECTION
 
The the query in the "sales_items.php" shoulb be:

Code:

// the database query
$query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid LIKE $sql_tbl[pricing].productid AND $sql_tbl[products].list_price - $sql_tbl[pricing].price > 19 ORDER by xcart_products.productID DESC LIMIT 0,10 ";


Sorry

teriwinkle 05-10-2004 11:42 PM

How to add link?
 
Hello daddyroy,

I am trying out your mod, and I am not sure how to link the code to the on_sale.php file? I tried a few things and nothing has worked. Could you tell me how to link it?

Thanks!
:D

daddyroy 05-11-2004 05:40 AM

LINKING ON_SALE.php
 
Hello how are you. You can simply add the code in the ../skin1/head.tpl like I did. Here is my modified version of head.tpl:


Code:

{* $Id: head.tpl,v 1.3 2003/04/24 09:50:33 svowl Exp $ *}
<center><TABLE WIDTH=750 BORDER=0 CELLPADDING=0 CELLSPACING=0>
        <TR>
                <TD COLSPAN=5 valign=top>
                        [img]{$ImagesDir}/uppity_01.gif[/img]</TD>
                <TD COLSPAN=4 valign=bottom>
                        <div align=right><table border=0 cellpadding=1 cellspacing=0 width=190>
<tr>
<td width=118 valign=top><font color="#910021">Items in Cart:</font></td> <td width=68 valign=top><div align=right>{if $minicart_total_items > 0}[b]{$minicart_total_items}{else}0{/if}</div></td></tr>
<tr>
<td width=118 valign=bottom><font color="#910021">Cart Total:</font></td> <td width=68 valign=top><div align=right>{if $minicart_total_items > 0}{include file="currency.tpl" value=$minicart_total_cost}{else}$0.00{/if}</div></td></tr></table>
[img]{$ImagesDir}/view_cart.jpg[/img][img]{$ImagesDir}/check_out.jpg[/img]</div>

</TD>
        </TR></table><table border=0 cellpadding=0 cellspacing=0 width=750>

        <TR>
                <TD width=750><script language="JavaScript1.2">mmLoadMenus();</script>[img]../skin1/images/category.jpg[/img][img]../skin1/images/uppity_04.gif[/img][img]../skin1/images/brand.jpg[/img][img]../skin1/images/uppity_04.gif[/img][img]../skin1/images/style.jpg[/img][img]../skin1/images/uppity_04.gif[/img][img]../skin1/images/new_arrivals.jpg[/img][img]../skin1/images/uppity_04.gif[/img][img]../skin1/images/sales_items.jpg[/img]</TD>
        </TR>
<tr>
<td width=750 height=1 bgcolor=#910021></td></tr>



<tr>
<td width=750 valign=bottom><div align=right>

<form action="../customer/sizes.php"method="GET"><table border=0 cellspacing=0 cellpadding=0>
<tr>
<td valign=bottom>[img]{$ImagesDir}/size.jpg[/img]</td><td valign=bottom>
{literal}<select name="sz">
<option selected value="5">5</option>
<option value="5.5">5.5</option>
<option value="6">6</option>
<option value="6.5">6.5</option>
<option value="7">7</option>
<option value="7.5">7.5</option>
<option value="8">8</option>
<option value="8.5">8.5</option>
<option value="9">9</option>
<option value="9.5">9.5</option>
<option value="10">10</option>
<option value="10.5">10.5</option>
<option value="11">11</option>
<option value="11.5">11.5</option>
<option value="12">12</option>
</select>{/literal}</td> <td valign=bottom><input type=image src="{$ImagesDir}/search_go.jpg"border=0">
</td></tr></table></FORM></div></td></tr></TABLE>



OR

You can add the links to .../skin1/rectangle_bottom.tpl like this. Again my modified verson of rectangle_bottom.tpl:

Code:

{* $Id: rectangle_bottom.tpl,v 1.3.2.1 2003/09/17 11:52:12 svowl Exp $ *}<table border=0 cellpadding=0 cellpadding=0 width=750><tr><td width=750 valign=top><center>Home |My Account | Recover Password | Contact Us | Privacy Policy | Return Policy | F.A.Q.

</center></td></tr>
<tr><td width=750 valign=bottom>
<center>[img]{$ImagesDir}/visa-mastercard.jpg[/img]

YOUR COMPANY
Tel: (123) 456 - 7810

Email: <a href ="mailto:sales@yourwebsite.com">sales@mywebsite.com</a>

Copyright &copy; My COmpany. All rights reserved. </center></td></tr></table></center>


This works!!! :D

daddyroy 05-11-2004 05:44 AM

The on_sale.php
 
Code:

$sql_tbl[products].list_price - $sql_tbl[pricing].price > 19

This > 19 could be any number you set. I just set it that any item that is $19 or more less than the list price would be considered ON SALE.

teriwinkle 05-11-2004 09:57 PM

blank page
 
Hello daddroy. Thanks for answering !:) . I know this will be a nice mod. I put the link in, but when I click it, the on_sale.php gives me a blank screen. I haven't been able to figure out why. One of the things I had to change was the "require" section on the on_sale.php to the following, because it couldn't find the template engine:

Quote:

//require "../smarty.php";
//require "../config.php";
@include "./https.php";
//require "./auth.php";
require "../include/categories.php";
//require "./sales_items.php";

The template error messages went away when I did that, but now the screen just goes blank. If you have any ideas, please let me know. Otherwise, thanks for your help and the mod info, and I will try to see what I am doing wrong.

By the way, what version of xcart was this written on?


All times are GMT -8. The time now is 06:27 AM.

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