View Single Post
  #8  
Old 07-22-2007, 10:24 PM
 
pavant pavant is offline
 

Advanced Member
  
Join Date: Oct 2004
Location: Chicago, Illinois
Posts: 84
 

Default Re: Schedule Item Availability

I liked this mod so I modified for my 4.1.8 xcart. Here's what I have:

Step 1: SQL patch
Quote:

alter table xcart_products add start_date int(11) not null default '0';
alter table xcart_products add end_date int(11) not null default '0';
INSERT INTO `xcart_languages` VALUES ('US', 'lbl_schedule_availability', 'Schedule Item Availability', 'Labels');
INSERT INTO `xcart_languages` VALUES ('US', 'txt_sale_date_instructions','This feature causes an item to appear in the storefront during a specific time period. Both Start and End dates must be provided if you wish to schedule a sale. Leaving either or both fields blank disables the scheduling functionality. Dates may be provided in nearly any format (ie. \"June 1, 2006\", \"tomorrow\", \"6/22/2006 1:22pm\", etc.). ', 'Text');

Step 2: Change /include/product_modify.php

After
Quote:
"free_tax" => $free_tax,

Add
Quote:

"start_date" => '".strtotime($start_date)."',
"end_date" => '".strtotime($end__date)."',

Step 3: Open skin1/main/product_details.tpl and paste the following somewhere near the bottom (just above the Extra Fields works well).
Quote:

<
tr>
{if $productids ne ''}<
td width="15" class="TableSubHead">&nbsp;</td>{/if}
<
td colspan="2"><br />{include file="main/subheader.tpl" title=$lng.lbl_schedule_availability}</td>
</
tr>
<
tr>
<
td colspan="2">{$lng.txt_sale_date_instructions}</td>
</
tr>
<tr>
<td class="FormButton" nowrap>Start Date</td>
<td class="ProductDetails"><input type="text" name="start_date" size="18" autocomplete="off" value="{if $product.productid eq ""}{else}{if $product.start_date ne 0}{$product.start_date|date_format:"%m/%d/%Y %H:%M"}{/if}{/if}" /></td>
</tr>
<tr>
<td class="FormButton" nowrap>End Date</td>
<td class="ProductDetails"><input type="text" name="end_date" size="18" autocomplete="off" value="{if $product.productid eq ""}{else}{if $product.end_date ne 0}{$product.end_date|date_format:"%m/%d/%Y %H:%M"}{/if}{/if}" /></td>
</tr>

Step 4: Open include/func/func.product.php and find
Quote:

if (!$always_select && ($product["forsale"] == "N" || ($product["forsale"] == "B" && empty($pconf)))) {

Replace with:
Quote:
if (($product["start_date"] != "0") && ($product["end_date"] != "0")) {
$rightnow = strtotime(now);

if (((
$rightnow > $product["end_date"]) || ($rightnow < $product["start_date"]))) {
$offsale = "true";
}

}

if (!
$always_select && ($offsale == "true" || $product["forsale"] == "N" || ($product["forsale"] == "B" && empty($pconf)))) {


Step 5: Open include/search.php and find:
Quote:

if (!empty($data["forsale"]))
$where[] = "$sql_tbl[products].forsale = '".$data["forsale"]."'";

Replace with:
Quote:

$where[] = "$sql_tbl[products].forsale = '".$data["forsale"]."' AND ((from_unixtime( unix_timestamp( ) ) BETWEEN from_unixtime( start_date ) AND from_unixtime( end_date )) OR ((`start_date` IS NULL OR start_date =0) OR (end_date IS NULL OR end_date =0)))";

Hope this helps you 4.1 xcart babies. I make no promises that this code will work with your site; each environment is different and your code may function differently especially if it has already been moded. I can't provide any support for this mod. Install only if you have the resources to fix any problems that may occur.
__________________
X-Cart Gold v 4.1.10
PHP 5.2.4
MySQL 5.0.45 standard
Apache/2.2.6
OS - Linux
Reply With Quote