Get Date End of product's price

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Icymars
Posts: 12
Joined: 16 Dec 2020, 18:33

Get Date End of product's price

Post by Icymars » 27 Dec 2020, 17:43

Hi, I want to add a progress bar that indicates how much time remains for the offer.
I've added this code in price-standard.php file to add the bar:

Code: Select all

<p>
	<span class="offer"><?= $enc->html(__("Offer expires in:")); $priceItem->get; ?></span>
	<span class="progress m-b-5">
	<span class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%"><?= #TODO add code for get DateEnd ?> </span>
	</span>
	</p>
But, how I've specified in #todo, I don't have the function to get the end date of the product's price.
Is there any function to get this value?

Aimeos: aimeos/aimeos-laravel 2020.10.6
PHP 7.4.3

User avatar
aimeos
Administrator
Posts: 7917
Joined: 01 Jan 1970, 00:00

Re: Get Date End of product's price

Post by aimeos » 27 Dec 2020, 18:06

The start/end date is stored in the list item that references the price item. Instead of using

Code: Select all

$priceItems = $product->getRefItems( 'price', 'default', default' );
use

Code: Select all

$listItems = $product->getListItems( 'price', 'default', default' );
foreach( $listItems as $listItem ) {
	$datetime = $listItem->getDateEnd();
	$priceItem = $listItem->getRefItem();
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply