Author Topic: Price Publish Down: How to display in Default.php? (VirtueMart 3.2.6)  (Read 160 times)

mauriziomomix

  • Beginner
  • *
  • Posts: 17
Hi all,
I'm trying to display in the ProductDetail View the date of Publish down for the Product Price

I've tried inserting the piece of code following:


         <?php // End sale     ?>
            <h4>
            <?php echo 'Sale ends on: '?>
            <?php echo $this->product->product_price_publish_down ?>
            </h4>

But the result is an empty field.

Does anyone could please help me find the correct syntax/field name in order to display the date on which the price is going to be removed? (see image)

Thanks in advance and best regards

Maurizio


Ghost

  • Jr. Member
  • **
  • Posts: 377
Re: Price Publish Down: How to display in Default.php? (VirtueMart 3.2.6)
« Reply #1 on: December 04, 2017, 09:39:58 am »
Assuming you have simple price setup with one price, this should work $this->product->prices['product_price_publish_down'].

mauriziomomix

  • Beginner
  • *
  • Posts: 17
Re: Price Publish Down: How to display in Default.php? (VirtueMart 3.2.6)
« Reply #2 on: December 04, 2017, 17:24:38 pm »
Thank you Ghost!
Could you please help me with the date formatting too?.

The output contains also the time but I would like to show only the date it in format "d/m/Y"

The following is the current code (as per your kind suggestion:

   <?php // Product End Sale     ?>
   <h4>
   <?php echo 'Sale ends on: '?>
   <?php echo $this->product->prices['product_price_publish_down']; ?>
   </h4>

In PHP documentation I see that the correct formatting should follow this rule:

<?php
$date=date_create("2013-03-15");
echo date_format($date,"d/m/y");
?>


So I tried formatting this way:

   <?php // Product End Sale     ?>
   <h4>
   <?php echo 'Sale ends on: '?>
   <?php echo $this->product->date_format(prices['product_price_publish_down'],"d/m/y"); ?>
   </h4>

but the syntax isn't correct.

Could you please help me find the correct way to formatting the date without the time?

Many thanks

Maurizio


Ghost

  • Jr. Member
  • **
  • Posts: 377
Re: Price Publish Down: How to display in Default.php? (VirtueMart 3.2.6)
« Reply #3 on: December 05, 2017, 07:41:56 am »
It says you need to create a DateTime object before using date_format:

Code: [Select]
$date = date_create($this->product->prices['product_price_publish_down']);
echo date_format($date, 'd/m/y');

mauriziomomix

  • Beginner
  • *
  • Posts: 17
Re: Price Publish Down: How to display in Default.php? (VirtueMart 3.2.6)
« Reply #4 on: December 06, 2017, 12:21:41 pm »
Wonderful!
Thank you Ghost!

Maurizio