Christophe LATOUR c88ea57ba5 Initial commit
2017-07-21 16:40:11 +02:00

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
));
}
}