News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Price Publish Down: How to display in Default.php? (VirtueMart 3.2.6)

Started by mauriziomomix, December 02, 2017, 18:16:44 PM

Previous topic - Next topic

mauriziomomix

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

Assuming you have simple price setup with one price, this should work $this->product->prices['product_price_publish_down'].

mauriziomomix

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

It says you need to create a DateTime object before using date_format:

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