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)
-   -   How to change Add Date field for a Product (https://forum.x-cart.com/showthread.php?t=63608)

ADDISON 05-13-2012 11:25 AM

How to change Add Date field for a Product
 
2 Attachment(s)
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.

Learner 06-18-2012 02:24 AM

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.

ADDISON 06-18-2012 02:27 AM

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.


chris.ath 07-04-2012 11:12 PM

Re: How to change Add Date field for a Product
 
Hi ADDISON,
It works and on x-cart Pro 4.4.2 also.

Thanks.

RichieRich 05-03-2013 04:13 AM

Re: How to change Add Date field for a Product
 
How can you make it automatially display by newest

ADDISON 05-03-2013 04:18 AM

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

RichieRich 05-03-2013 04:24 AM

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?

RichieRich 05-03-2013 04:29 AM

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

ADDISON 05-03-2013 04:59 AM

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.

mcanitano 10-13-2014 08:16 AM

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!


All times are GMT -8. The time now is 01:16 AM.

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