public function WishlistItem::getLastPurchasedTime in Commerce Wishlist 8.3
Gets the timestamp of the last purchase.
Return value
int|null The timestamp of the last purchase, or NULL if the wishlist item hasn't been purchased yet.
Overrides WishlistItemInterface::getLastPurchasedTime
File
- src/
Entity/ WishlistItem.php, line 218
Class
- WishlistItem
- Defines the wishlist item entity class.
Namespace
Drupal\commerce_wishlist\EntityCode
public function getLastPurchasedTime() {
$last_purchased_time = NULL;
if ($purchases = $this
->getPurchases()) {
$purchased_times = array_map(function (WishlistPurchase $purchase) {
return $purchase
->getPurchasedTime();
}, $purchases);
asort($purchased_times, SORT_NUMERIC);
$last_purchased_time = end($purchased_times);
}
return $last_purchased_time;
}