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

How to change Add Date field for a Product
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #1  
Old 05-13-2012, 11:25 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Lightbulb How to change Add Date field for a Product

Hello Guys,

As you may know in table [xcart_products] there is a field named [add_date]. This is a very powerful field for customization of XC (mark a product as new, newest products, ...). Its value you see it is in UNIX date format (e.g. 2147483647 = Tue, 19 Jan 2038 03:14:07 +0000).

In the past many of you asked in this forum how to change this field in Admin -> Product page. Here is a solution for you free of charge checked and functioning in XC v4.5.0 (you can choose your new date with jQuery UI). By default for new products the date is set for today.

Step 1 - Here are the files we have to change:

- [XC-Dir]/include/product_modify.php
- [XC-Dir]/skin/common_files/main/products_details.tpl

product_modify.php

Search for the following string: // Update product data.

after:
Code:
$small_item = $small_item == 'Y' ? 'N' : 'Y';
add:
Code:
$add_date = func_prepare_search_date($add_date);

Search for the following string $query_data = array (

after:
Code:
'title_tag' => $title_tag,
add:
Code:
'add_date' => $add_date,

product_modify.tpl

Search for the following string $lng.lbl_availability. After this html table row for product availability (the one with html select) paste the following code:

Code:
<tr> <td class="FormButton" nowrap="nowrap">{$lng.lbl_add_date}:</td> <td class="ProductDetails"> {include file="main/datepicker.tpl" name="add_date" date=$product.add_date} </td> </tr>

Step 2 - New Label

We have to add a new label in languages. I have called this label "lbl_add_date" with value "Add Date". You can also execute the following query with phpMyAdmin or inside XC interface

PHP Code:
INSERT INTO `xcart_languages` (`code`, `name`, `value`, `topic`) VALUES('en','lbl_add_date','Add Date','Labels'); 

I have attached the files I modified v4.5.0. Please note to do a backup before replacement in their folders (rename your original files with extensions like .ph_ or .tp_).

As improvement I could change the behavior to see the sticky container coming (Apply button) after altering a value. For this I should create a new template called datapicker_p.tpl and leave only an input html tag in product_modify.tpl. Sticky container comes only if input/check boxes tags exists in product_modify.tpl. You can do it by your own, I can live without it.

Also "Mark a product as new" feature with a time configured in Appearance or just (Start - End) time in product modified page is a piece of cake based on this thread. Looking for volunteers.

In my humble opinion this easy customization should be done years before and being standard in all XC versions.
Attached Files
File Type: php product_modify.php (51.5 KB, 52 views)
File Type: tpl product_details.tpl (20.6 KB, 38 views)
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote

The following 8 users thank ADDISON for this useful post:
Ben G (06-19-2018), chris.ath (07-04-2012), mcanitano (10-13-2014), Mick (08-05-2017), tartaglia (05-15-2012), totaltec (10-13-2014), Vivarant (11-12-2013), wnc2 (06-29-2013)
  #2  
Old 06-18-2012, 02:24 AM
 
Learner Learner is offline
 

X-Adept
  
Join Date: Dec 2008
Posts: 807
 

Default Re: How to change Add Date field for a Product

Hi ADDISON,
Thanks for a good code.Will it work on x-cart Pro 4.4.2?

Thanks.
__________________
4.6.1 Platinum


Reply With Quote
  #3  
Old 06-18-2012, 02:27 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default Re: How to change Add Date field for a Product

I did not test it on a Pro 4.4.2. Make a backup of those two files so nothing wrong could happen if you alter the code.

Normally it should work on all versions since 4.4.

Do not replace your files with the one I uploaded. Do the changes manually. It could be a problem with Pro - Gold and versions.

Quote:
Originally Posted by Learner
Hi ADDISON,
Thanks for a good code.Will it work on x-cart Pro 4.4.2?

Thanks.
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote
  #4  
Old 07-04-2012, 11:12 PM
 
chris.ath chris.ath is offline
 

Member
  
Join Date: Aug 2007
Posts: 27
 

Smile Re: How to change Add Date field for a Product

Hi ADDISON,
It works and on x-cart Pro 4.4.2 also.

Thanks.
__________________
Chris
X-Cart 4.4.2
Reply With Quote
  #5  
Old 05-03-2013, 04:13 AM
  RichieRich's Avatar 
RichieRich RichieRich is offline
 

X-Adept
  
Join Date: Sep 2004
Location: London, England
Posts: 749
 

Default Re: How to change Add Date field for a Product

How can you make it automatially display by newest
__________________
Richard


Ultimate 5.3.6
Reply With Quote
  #6  
Old 05-03-2013, 04:18 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default Re: How to change Add Date field for a Product

If you have installed Gold Plus or Gold + X-HotProducts module you can easy set up a product as new. Read this user manual page: http://help.x-cart.com/index.php?title=X-Cart:X-HotProducts

see in section (middle of the page): Ability to mark any product as new
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote
  #7  
Old 05-03-2013, 04:24 AM
  RichieRich's Avatar 
RichieRich RichieRich is offline
 

X-Adept
  
Join Date: Sep 2004
Location: London, England
Posts: 749
 

Default Re: How to change Add Date field for a Product

ah but that is version 4.5.5 for gold plus, I only have 4.5.4 gold plus.

Will it seperate the products into New arrivals and standard products?
__________________
Richard


Ultimate 5.3.6
Reply With Quote
  #8  
Old 05-03-2013, 04:29 AM
  RichieRich's Avatar 
RichieRich RichieRich is offline
 

X-Adept
  
Join Date: Sep 2004
Location: London, England
Posts: 749
 

Default Re: How to change Add Date field for a Product

Also, in your signature it says you are on version X-Cart Gold Plus: 4.5.6.

My file area shows 4.5.5 as the latest and the next version is announced as 4.6.0
__________________
Richard


Ultimate 5.3.6
Reply With Quote
  #9  
Old 05-03-2013, 04:59 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default Re: How to change Add Date field for a Product

I suggest you waiting for 4.6.0 instead of upgrading to 4.5.5 in order to get that feature.

If you read the manual, XC separates New Arrivals if you want this.
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote
  #10  
Old 10-13-2014, 08:16 AM
  mcanitano's Avatar 
mcanitano mcanitano is offline
 

eXpert
  
Join Date: Feb 2006
Location: Melbourne, FL
Posts: 216
 

Default Re: How to change Add Date field for a Product

We would like to get this to work for us, but when we go to change the date, it seems it's not updating the data. When we click "Apply Changes" on product_modify page, it doesn't save the edited date value.

Even after upgrading to XC 4.5.5 (from 4.5.2) and installing New Arrivals, the ability to enable any product as New Arrival does not function properly for us. If we have new products we have added on 10/12/2014 and enable them as new products, they show in our new arrivals section.

But if we go to enable a product that was added in 2012, as a new product, it does not bump above the products added on 10/12/2014 and show as new product.


EDIT:
NEVERMIND! It's working perfectly, when we saved the product_modify.php file it seems that it didn't save the 'add_date' in the array, oops!
__________________
Marcello Canitano
New Site: X-Cart v4.5.5 GOLD
X-Cart Mobile v1.4.3
X-Payments v1.0.6
CDSEO Pro v2
Total Server Solutions xCDN

www.silverhorseracing.com
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 10:49 PM.

   

 
X-Cart forums © 2001-2018