\
mtwithdrawalbtn
1
0
public function findOrderByReferenceAndInvoicePostcode($reference, $postcode)
{
$reference = pSQL(trim((string)$reference));
$postcode = pSQL(preg_replace('/\s+/', '', strtoupper(trim((string)$postcode))));
$row = Db::getInstance()->getRow('
SELECT o.id_order
FROM `'._DB_PREFIX_.'orders` o
INNER JOIN `'._DB_PREFIX_.'address` a ON a.id_address = o.id_address_invoice
WHERE o.reference = "'.$reference.'" AND REPLACE(UPPER(a.postcode), " ", "") = "'.$postcode.'"
ORDER BY o.id_order DESC
');
if ($row && !empty($row['id_order'])) {
$order = new Order((int)$row['id_order']);
if (Validate::isLoadedObject($order)) {
return $order;
}
}
return null;
}
public function getOrderCustomerEmail(Order $order)
{
$customer = new Customer((int)$order->id_customer);
if (Validate::isLoadedObject($customer) && Validate::isEmail($customer->email)) {
return (string)$customer->email;
}
return (string)Configuration::get('PS_SHOP_EMAIL');
}
public function getOrderCustomerName(Order $order)
{
$customer = new Customer((int)$order->id_customer);
if (Validate::isLoadedObject($customer)) {
return trim($customer->firstname.' '.$customer->lastname);
}
return '';
}
protected function renderItemsForMail(array $items)
{
$html = '
';
$txt = '';
foreach ($items as $p) {
$name = Tools::safeOutput((string)$p['product_name']);
$qty = (int)$p['product_quantity'];
$html .= '- '.$name.' (x'.$qty.')
';
$txt .= '- '.$name.' (x'.$qty.")\n";
}
$html .= '
';
return ['html' => $html, 'text' => trim($txt)];
}
public function sendConfirmationEmail(Order $order, array $items, $message)
{
$customer = new Customer((int)$order->id_customer);
$idLang = (int)$order->id_lang;
$render = $this->renderItemsForMail($items);
$tplVars = [
'{firstname}' => $customer->firstname,
'{lastname}' => $customer->lastname,
'{order_reference}' => $order->reference,
'{fullname}' => $this->getOrderCustomerName($order),
'{email}' => $this->getOrderCustomerEmail($order),
'{message}' => nl2br(Tools::safeOutput((string)$message)),
'{items_html}' => $render['html'],
'{items_text}' => $render['text'],
];
$subject = $this->l('Bestätigung Widerruf').' '.$order->reference;
return Mail::Send(
$idLang,
'withdrawal_received',
$subject,
$tplVars,
$customer->email,
$customer->firstname.' '.$customer->lastname,
null,
null,
null,
null,
dirname(__FILE__).'/mails/',
false,
(int)$order->id_shop
);
}
public function sendMerchantEmailIfEnabled(Order $order, array $items, $message)
{
$notify = (int)Configuration::get(self::CONF_NOTIFY_MERCHANT, 1, 0, (int)$order->id_shop);
if (!$notify) {
return true;
}
$to = (string)Configuration::get(self::CONF_MERCHANT_EMAIL, (string)Configuration::get('PS_SHOP_EMAIL'), 0, (int)$order->id_shop);
if (!Validate::isEmail($to)) {
$to = (string)Configuration::get('PS_SHOP_EMAIL');
}
$idLang = (int)$order->id_lang;
$render = $this->renderItemsForMail($items);
$tplVars = [
'{firstname}' => 'Shop',
'{lastname}' => '',
'{order_reference}' => $order->reference,
'{fullname}' => $this->getOrderCustomerName($order),
'{email}' => $this->getOrderCustomerEmail($order),
'{message}' => nl2br(Tools::safeOutput((string)$message)),
'{items_html}' => $render['html'],
'{items_text}' => $render['text'],
];
$subject = 'Widerruf eingegangen: '.$order->reference;
return Mail::Send(
$idLang,
'withdrawal_received',
$subject,
$tplVars,
$to,
null,
null,
null,
null,
null,
dirname(__FILE__).'/mails/',
false,
(int)$order->id_shop
);
}
protected function renderBackofficeList()
{
$idShop = (int)$this->context->shop->id;
$rows = Db::getInstance()->executeS('
SELECT id_mt_withdrawal_request, date_add, order_reference, id_order, items_json, message
FROM `'._DB_PREFIX_.'mt_withdrawal_request`
WHERE id_shop='.(int)$idShop.'
ORDER BY date_add DESC
LIMIT 100
');
$out = '
'.$this->l('Widerrufe (letzte 100)').'
';
$out .= ''
. '| '.$this->l('Datum').' | '
. ''.$this->l('Bestellreferenz').' | '
. ''.$this->l('Bestellung').' | '
. ''.$this->l('Artikel').' | '
. ''.$this->l('Nachricht').' | '
. '
';
if (!is_array($rows) || empty($rows)) {
$out .= '| '.$this->l('Keine Widerrufe vorhanden.').' |
';
} else {
foreach ($rows as $r) {
$items = [];
if (!empty($r['items_json'])) {
$decoded = json_decode($r['items_json'], true);
if (is_array($decoded)) {
$items = $decoded;
}
}
$itemsTxt = '';
foreach ($items as $p) {
$itemsTxt .= Tools::safeOutput((string)$p['product_name']).' (x'.(int)$p['product_quantity'].")
";
}
$orderLink = '';
if (!empty($r['id_order'])) {
$orderLink = 'index.php?controller=AdminOrders&id_order='.(int)$r['id_order'].'&vieworder=1&token='.Tools::getAdminTokenLite('AdminOrders');
$orderLink = '#'.(int)$r['id_order'].'';
}
$out .= ''
. '| '.Tools::safeOutput($r['date_add']).' | '
. ''.Tools::safeOutput($r['order_reference']).' | '
. ''.$orderLink.' | '
. ''.$itemsTxt.' | '
. ''.nl2br(Tools::safeOutput((string)$r['message'])).' | '
. '
';
}
}
$out .= '
';
return $out;
}
Fehler 404 Zum Inhalt springen check_circle
check_circle
Warenkorb
Kostenloser Versand für Bestellungen ab 99,00 € innerhalb Deutschland! Kostenloser Versand möglich!
Es fehlen noch 99,00 € für eine Vesandkostenfreie Lieferung!