0 ) || isset( $templateVars['{order_name}' ]) && $templateVars['{order_name}'] != '' ) ) { if ( !isset( $templateVars['{id_order}'] ) || (int)$templateVars['{id_order}'] == 0 ) { $orderList = Db::getInstance (_PS_USE_SQL_SLAVE_)->ExecuteS ("SELECT `id_order` FROM `"._DB_PREFIX_."orders` WHERE `reference` = '" . $templateVars[ '{order_name}' ] . "'"); $orderList = $orderList[0]; } else $orderList = array('id_order' => $templateVars['{id_order}']); foreach ($orderList as $order) { $order = new Order($order); if ( $order -> id ) { $templateVars['{id_order}'] = $order->id; $customer_message = $order->getFirstMessage(); $templateVars['{message}'] = $customer_message; $where = 'id_cart ='.(int)$order->id_cart; $data = array('id_order' => (int)$order->id); Db::getInstance(_PS_USE_SQL_SLAVE_)->update('custom_field_userdata', $data, $where); $module = Module::getInstanceByName('customfields'); $custom_fileds = $module->getEmailFields($order->id, ' and a.show_customer = 1'); // adres do faktury w mailu $custom_fileds_text = ''; foreach ( $custom_fileds['payment'] as $item ) { if ( $item['id_custom_field'] != 1 ) $custom_fileds_text .= '' . $item['field_name'] . ': ' . $item['field_value'] . '
'; } $templateVars['{customfields}'] = $custom_fileds_text; require_once 'modules/inpostship/classes/InpostPack.php'; require_once 'modules/inpostship/classes/InpostPoint.php'; $ship = InpostPack::issetCart( (int)$order -> id_cart ); if ( !empty( $ship['receiver_machine'] ) and strpos( $templateVars['{carrier}'], 'Inpost Paczkomaty 24' ) !== false ) { $point = InpostPoint::getPointInfo( $ship['receiver_machine'] ); $templateVars['{point_code}'] = ' - paczkomat: ' . $point['point_code']; } else $templateVars['{point_code}'] = ''; if ( $idLang == 1 ) { $content = file_get_contents(_PS_ROOT_DIR_.'/Regulamin_sklepu_internetowego.pdf'); $file_attachment['content'] = $content; $file_attachment['name'] ='Regulamin_sklepu_internetowego.pdf'; $file_attachment['mime'] = 'application/pdf'; } if ( $idLang == 2 ) { $content = file_get_contents(_PS_ROOT_DIR_.'/online-shop-regulations.pdf'); $file_attachment['content'] = $content; $file_attachment['name'] ='online-shop-regulations.pdf'; $file_attachment['mime'] = 'application/pdf'; } } if ( strpos( $templateVars['{carrier}'], 'osobisty' ) !== false and $idLang == 2 ) $templateVars['{carrier}'] = 'Pickup in person'; if ( $subject == 'Potwierdzenie zamówienia' ) { if ( strpos( $templateVars['{payment}'], 'Płatności elektroniczne' ) !== false and $idLang == 1 ) $templateVars['{payment}'] = 'Przedpłata / Przelew'; } if ( $subject == 'Oczekiwanie na płatność przelewem' ) { $user_group = Customer::getDefaultGroupId( $order -> id_customer ); if ( $user_group >= 4 ) { $subject = 'Realizacja zamówienia'; $templateVars['{payment}'] = 'Możesz spodziewać się faktury do przedpłaty, lub jeśli posiadasz uzgodniony termin płatności natychmiastowej wysyłki.

Metoda płatności: Przedpłata / Przelew
Przedpłata - zapłacisz po otrzymaniu faktury. Po zaksięgowaniu przelewu zamówienie zostanie wysłane najszybciej jak to możliwe.
Przelew - zapłacisz w uzgodnionym terminie, dotyczy wyłącznie dystrybutorów. Zamówienie zostanie wysłane najszybciej jak to możliwe.'; } else $templateVars['{payment}'] = 'Możesz spodziewać się dostawy natychmiast po otrzymaniu płatności'; } if ( $subject == 'Awaiting bank wire payment' ) { $user_group = Customer::getDefaultGroupId( $order -> id_customer ); if ( $user_group >= 4 ) { $subject = 'Realization of the order'; $templateVars['{payment}'] = 'You can expect an invoice to be prepaid, or if you have an agreed payment term for immediate shipment.

Payment method: Prepayment/ Transfer
Prepayment - you will pay after receiving the invoice. After the transfer is credited to the account, the order will be sent as soon as possible.
Transfer - you pay at the agreed time, applies only to distributors. The order will be shipped as soon as possible.'; } else $templateVars['{payment}'] = 'You can expect delivery as soon as your payment is received.'; } /* TODO: czy Klient B2B * 19/04/2022 */ $user_group = Customer::getDefaultGroupId( $order -> id_customer ); $user_group >= 4 ? $templateVars['b2b-client'] = 1 : $templateVars['b2b-client'] = 0; /* --- */ $test = file_get_contents( 'dump.txt' ); $test .= PHP_EOL . '--------------------------------'; $test .= PHP_EOL . $subject; $test .= PHP_EOL . $templateVars['{payment}']; // if ( strpos( $templateVars['{payment}'], 'Płatności elektroniczne' ) !== false and $idLang == 1 ) // { $test .= PHP_EOL . $order -> id_customer; $user_group = Customer::getDefaultGroupId( $order -> id_customer ); $test .= PHP_EOL . $user_group; // if ( $user_group >= 4 ) // $templateVars['{payment}'] = 'Twoje zamówienie na Redline jest gotowe.
Przedpłata - zapłacisz po otrzymaniu faktury
Przelew - zapłacisz w uzgodnionym terminie, dotyczy wyłącznie dystrybutorów.'; // else // $templateVars['{payment}'] = 'Przedpłata / Przelew'; $test .= PHP_EOL . $templateVars['{payment}']; // } $st = parent::Send( $idLang, $template, $subject, $templateVars, $to, $toName, $from, 'REDLINE', $file_attachment, $mode_smtp, $templatePath, $die, $idShop, $bcc, $replyTo, $replyToName ); if ($status && !$st) $status = false; } return $status; } else { return parent::Send($idLang, $template, $subject, $templateVars, $to, $toName, $from, 'REDLINE', $fileAttachment, $mode_smtp, $templatePath, $die, $idShop, $bcc); } return true; } }