28 lines
628 B
PHP
28 lines
628 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Antadis\API\Front\Models\Cart as BaseCart;
|
|
|
|
class Cart extends BaseCart
|
|
{
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function toArray() {
|
|
if (!class_exists('SaleDelay')) {
|
|
require_once _PS_ROOT_DIR_.'/modules/privatesales_delay/saledelay.php';
|
|
}
|
|
|
|
$products_delay = \SaleDelay::associateDelay($this->getProducts());
|
|
$delays = array_keys($products_delay);
|
|
$date = new \DateTime();
|
|
$delivery_date = \SaleDelay::getDeliveryDate($delays, null, $date, true);
|
|
|
|
return array_merge(parent::toArray(), array(
|
|
'delay' => empty($delivery_date) ? '' : $delivery_date
|
|
));
|
|
}
|
|
}
|