Merge branch 'master' of gitlab.antadis.net:mobile-antadis/api-bbb

This commit is contained in:
Christophe Latour 2017-08-30 11:00:42 +02:00
commit 3bf6160cac

View File

@ -13,11 +13,21 @@ class Sale extends BaseSale {
*/
public function toArray() {
global $cookie;
$sale = parent::toArray();
$is_active = strtotime($this->date_start) < strtotime(date('Y-m-d 07:00:00'));
$sale['img'] = $this->getSaleImage($this->id, $is_active);
$sale['reduction'] = $this->extraFields['reduction'] ? $this->extraFields['reduction'] : '0';
$sale['tags'] = $this->extraFields['tags'] ? $this->extraFields['tags'] : [];
if (!class_exists('SaleDelay')) {
require_once _PS_ROOT_DIR_.'/modules/privatesales_delay/saledelay.php';
}
$delay = \SaleDelay::getDayDelay($this->extraFields['delivery_delay'], $cookie->id_lang);
$delay_from = \SaleDelay::getDateWithDelay($delay['value'], new \DateTime());
$delay_to = \SaleDelay::getDateWithDelay($delay['value_max'], new \DateTime());
$sale['delay_from'] = $delay_from->format('d/m');
$sale['delay_to'] = $delay_to->format('d/m');
return $sale;
}