Adding property delay_from / delay_to in sale model
This commit is contained in:
parent
ed7a142da7
commit
b6d6136978
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user