55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace KupShop\KupShopBundle\Email;
|
|
|
|
class GenerateCouponEmail extends OrderEmail
|
|
{
|
|
protected static $name = 'Dárkový poukaz';
|
|
protected static $type = 'GENERATE_COUPON';
|
|
protected static $priority = 6;
|
|
|
|
protected $subject = 'Dárkový poukaz k objednávce {KOD}';
|
|
protected $template = 'email/email_order_generate_coupon.tpl';
|
|
|
|
public function testEmail(): array
|
|
{
|
|
if (!isset($this->order)) {
|
|
$order = new \Order();
|
|
$id_order = sqlQueryBuilder()->select('MAX(dc.id_order_purchased) AS id')
|
|
->from('discounts_coupons', 'dc')
|
|
->join('dc', 'orders', 'o', 'dc.id_order_purchased = o.id')
|
|
->where('o.status_storno = 0 AND o.status_payed = 1')
|
|
->execute()->fetch()['id'];
|
|
if (!$id_order) {
|
|
$id_order = returnSQLResult('SELECT MAX(id) FROM orders');
|
|
}
|
|
$order->createFromDB($id_order);
|
|
$this->setOrder($order);
|
|
}
|
|
|
|
return parent::testEmail();
|
|
}
|
|
|
|
public static function getPlaceholders()
|
|
{
|
|
$placeholders = [
|
|
'POUKAZY' => [
|
|
'text' => translate('ListOfCoupons', 'emails'),
|
|
],
|
|
];
|
|
|
|
return [self::$type => $placeholders] + (parent::getPlaceholders() ?? []);
|
|
}
|
|
|
|
public function getMicrodata(): array
|
|
{
|
|
if ($microdata = parent::getMicrodata()) {
|
|
if ($this->getOrder()->getDeliveryType()?->getDelivery() instanceof \VirtualDelivery) {
|
|
$microdata['orderStatus'] = 'https://schema.org/OrderDelivered';
|
|
}
|
|
}
|
|
|
|
return $microdata;
|
|
}
|
|
}
|