You are here:  » Show time date stamp with price info


Show time date stamp with price info

Submitted by alexhruby on Sun, 2009-03-29 12:51 in

Thanks for the great script! I am totally new here and was wondering if there is a way to show the date the product price was last updated near the price field. Similar to a blog post last updated ...
Sorry if its something obvious. I searched the forum but did not see it there.
Alex

Submitted by support on Sun, 2009-03-29 13:03

Hi Alex,

Sure - that's a quick and easy mod - the "imported" date/time can be read from the feeds table to be displayed on the prices table. Here's a complete version of html/prices.php to include the last updated information.

html/prices.php:

<?php
  $sql = "SELECT merchant,imported FROM `".$config_databaseTablePrefix."feeds`";
  database_querySelect($sql,$rows);
  foreach($rows as $row) $lastUpdated[$row["merchant"]] = $row["imported"];
?>
<div class='prices'>
  <table width='100%' cellpadding='4'>
    <tr bgcolor='#eeeeee'>
      <th width='200' align='left'><?php print translate("Stockist"); ?></th>
      <th align='left'><?php print translate("Catalogue Product Name"); ?></th>
      <th align='left'><?php print translate("Price"); ?></th>
      <th align='left'><?php print translate("Updated"); ?></th>
      <th align='left'>&nbsp;</th>
    </tr>
    <?php foreach($prices["products"] as $product): ?>
    <tr bgcolor='#ffffcc'>
      <td><a href='<?php print $product["merchantHREF"]; ?>'><?php print $product["merchant"]; ?></a></td>
      <td><?php print $product["name"]; ?></td>
      <td><strong><?php print $config_currencyHTML.$product["price"]; ?></strong></td>
      <td><?php print date("Y-m-d H:i",$lastUpdated[$product["merchant"]]); ?></td>
      <td align='center'><a href='<?php print tapestry_buyURL($product); ?>' <?php print javascript_statusBar("go to ".$product["merchant"]); ?>><?php print translate("Visit Store"); ?></a></td>
    </tr>
    <?php endforeach; ?>
  </table>
</div>

If you have already modified your prices.php, just copy the 5 lines of PHP from the top, and then add the "Updated" TH row and the corresponding TD row to display the updated date as follows:

<td><?php print date("Y-m-d H:i",$lastUpdated[$product["merchant"]]); ?></td>

The format the date/time is displayed in is controlled by the string "Y-m-d", as per the date() format specification which you can find here:

http://uk2.php.net/date

Hope this helps!

Cheers,
David.

Submitted by alexhruby on Sun, 2009-03-29 13:16

That was quick! 7 minutes for a reply!
Amazing works great Thanks!
Alex

Submitted by stonecold111 on Sun, 2013-08-25 08:33

Hi,
can you provide a plugin version of the modification?

Submitted by support on Sun, 2013-08-25 11:59

Hello Lau,

Have a go as follows; in pto_prices.php look for the following code at line 47:

  global $pto_html_prices_after;

...and REPLACE with:

  global $pto_html_prices_after;
  global $pto_config_databaseTablePrefix;
  $sql = "SELECT filename,imported FROM `".$pto_config_databaseTablePrefix."feeds`";
  $wpdb->query($sql);
  foreach($wpdb->last_result as $row) $lastUpdated[$row->filename] = $row->imported;

Then look for the following code at line 114:

  $each = str_replace("%BUY_URL%",pto_common_buyURL($product),$each);

...and REPLACE with:

  $each = str_replace("%BUY_URL%",pto_common_buyURL($product),$each);
  $each = str_replace("%UPDATED%",date("Y-m-d H:i",$lastUpdated[$product->filename]),$each);

And then in your Prices / Each template (wp-admin > Settings > PriceTapestry.org) use the placeholder

%UPDATED%

...as required!

Cheers,
David.
--
PriceTapestry.com

Submitted by stonecold111 on Sun, 2013-08-25 17:43

Hi,

is there a typo in it gives me an error on line 49.

I also want it to show up on the featured page so that visitors will know how updated the featured deals are. Does the placeholder register on the featured page?

Submitted by support on Sun, 2013-08-25 18:06

Hello Lau,

Sorry about that i'd included PHP tags in what isn't a PHP section - corrected above.

Almost identical code can be used for Featured Products. In pto_featured.php look for the following code at line 21:

  global $pto_html_featured_after;

...and REPLACE with:

  global $pto_html_featured_after;
  global $pto_config_databaseTablePrefix;
  $sql = "SELECT filename,imported FROM `".$pto_config_databaseTablePrefix."feeds`";
  $wpdb->query($sql);
  foreach($wpdb->last_result as $row) $lastUpdated[$row->filename] = $row->imported;

And then then the following code at line 139:

  $each = str_replace("%PRODUCT_URL%",pto_common_productHREF($row),$each);

...and REPLACE with:

  $each = str_replace("%PRODUCT_URL%",pto_common_productHREF($row),$each);
  $each = str_replace("%UPDATED%",date("Y-m-d H:i",$lastUpdated[$row->filename]),$each);

And that will add %UPDATED% support to the Featured Products / Each template.

Cheers,
David.
--
PriceTapestry.com

Submitted by Kari on Sat, 2015-07-11 14:40

Hi

I'm using 3rd party theme and can not get this working. Could you help me?

Undefined index: merchant in xxx.php on line 7
01.01.1970 02:00

Here is the code:
{code removed}

Submitted by support on Sat, 2015-07-11 15:01

Hello Kari,

I just posted a what I thought was the problem but immediately realised I made a mistake - please could you post the code section again and I'll check it out...

Thanks,
David.
--
PriceTapestry.com

Submitted by Kari on Sat, 2015-07-11 17:19

No problem:

{code saved}

Submitted by support on Sat, 2015-07-11 17:26

Thanks Kari,

The loop in your version uses $priceProduct instead of $product so where you have this code:

<?php
 
print date(" d.m.Y H:i. ",$lastUpdated[$product["merchant"]]); 
?>

...REPLACE with:

<?php
 
print date(" d.m.Y H:i. ",$lastUpdated[$priceProduct["merchant"]]); 
?>

...and that should be all it is.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Kari on Sat, 2015-07-11 17:36

It works now!

Thank you again for your help!

Submitted by Brice on Mon, 2018-01-15 17:52

This originally posted on 2009-03-29 13:03 but was trying to add an "updated" section next to price but the coding in the post doesnt match what I have so Im hesitant to make a change. This would just show the date of last update.

In relation to this I also wanted to have a column for Stock QTY. I have already added the optional field to the import and register process but trying to find how to add that to the product page to reflect visually.

Appreciate your help!

Submitted by support on Mon, 2018-01-15 18:14

Hello Brice,

Yes - this thread is from a much earlier distribution and goes on to describe changes for the WordPress plugin as well so for standalone Price Tapestry, latest distribution to show updated date in the price comparison table, first edit html/prices.php and add the following code to the top of the script:

<?php
  $sql = "SELECT filename,imported FROM `".$config_databaseTablePrefix."feeds`";
  database_querySelect($sql,$rows);
  foreach($rows as $row) $lastUpdated[$row["filename"]] = $row["imported"];
?>

Then to add the header row, look for the following code at (now) line 32:

          <th><?php print translate("Price"); ?></th>

...and REPLACE with:

          <th><?php print translate("Price"); ?></th>
          <th>Updated</th>

And finally the following code at (now) line 65:

            <td class='pt_pr_price'><?php print tapestry_price($product["price"]); ?></td>

...and REPLACE with:

            <td class='pt_pr_price'><?php print tapestry_price($product["price"]); ?></td>
            <td><?php print date("Y-m-d",$lastUpdated[$product["filename"]]); ?></td>

To style the column, it would be tidiest to create a new class e.g. pt_pr_updated and add to html/default.css for example;

.pt_pr_updated {
  text-align: center;
}

...or as required.

Regarding your custom Stock QTY field - I just replied to your post here (question 2) which should cover that - let me know if you are still not sure of course...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com