public static function Send($id_lang, $template, $subject, $templateVars, $to, $toName = NULL, $from = NULL, $fromName = NULL, $fileAttachment = NULL, $modeSMTP = NULL, $templatePath = _PS_MAIL_DIR_, $die = false, $id_shop = NULL, $bcc = null) { if (Module::isInstalled('agileprepaidcredit') and $template == 'payment_error') { if (AgilePrepaidCredit::isPaymentErrorCausedByTokens($templateVars) > 0) { return true; } } $order_info_templates = array('order_conf', 'bankwire', 'cheque', 'new_order'); if (Module::isInstalled('agilesellershipping') and in_array($template, $order_info_templates)) { AgileSellerManager::adjust_shipping_cost_carriers($templateVars); } if (Module::isInstalled('agilepickupcenter') and $template == 'order_conf') { require_once _PS_ROOT_DIR_ . "/modules/agilepickupcenter/agilepickupcenter.php"; $amodule = new AgilePickupCenter(); $templateVars = $amodule->transform_mail_data($templateVars); if (isset($templateVars['{carrier_email}']) and Validate::isEmail($templateVars['{carrier_email}'])) { parent::Send($id_lang, $template, $subject, $templateVars, $templateVars['{carrier_email}'], $toName, $from, $fromName, $fileAttachment, $modeSMTP, $templatePath, $die, $id_shop, $bcc); } } if (in_array($template, $order_info_templates)) { $shop_email = Configuration::get('PS_SHOP_EMAIL'); if (Module::isInstalled('agilemultipleseller')) { require_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/SellerInfo.php"; $templateVars = AgileSellerManager::appendMailTemplateVars($templateVars, $id_lang); } if (Module::isInstalled('agileprepaidcredit') and in_array($template, array('bankwire', 'cheque'))) { require_once _PS_ROOT_DIR_ . "/modules/agileprepaidcredit/agileprepaidcredit.php"; $templateVars = AgilePrepaidCredit::replace_amount2pay($templateVars); } parent::Send($id_lang, $template, $subject, $templateVars, $shop_email, $toName, $from, $fromName, $fileAttachment, $modeSMTP, $templatePath, $die, $id_shop, $bcc); } if (Module::isInstalled('agilemultipleseller') and $template == 'order_customer_comment') { $id_order = intval($templateVars['{id_order}']); $id_seller = AgileSellerManager::getObjectOwnerID('order', $id_order); $seller = new Employee($id_seller); parent::Send($id_lang, $template, $subject, $templateVars, $seller->email, $toName, $from, $fromName, $fileAttachment, $modeSMTP, $templatePath, $die, $id_shop, $bcc); } if (Module::isInstalled('agilemultipleseller') and $template == 'order_conf') { require_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/agilemultipleseller.php"; AgileMultipleSeller::sendNewOrderMail($id_lang, $templateVars, $from, $fromName, $fileAttachment, $modeSMTP, $die, $id_shop, $bcc); } return parent::Send($id_lang, $template, $subject, $templateVars, $to, $toName, $from, $fromName, $fileAttachment, $modeSMTP, $templatePath, $die, $id_shop, $bcc); }
public static function Send($id_lang, $template, $subject, $template_vars, $to, $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null) { /* * EU-Legal * CMS pages available for all emails => txt and html */ $additional_cms = array('conditions' => 'PS_CONDITIONS_CMS_ID', 'revocation' => 'LEGAL_CMS_ID_REVOCATION', 'revocationform' => 'LEGAL_CMS_ID_REVOCATIONFORM', 'privacy' => 'LEGAL_CMS_ID_PRIVACY', 'environmental' => 'LEGAL_CMS_ID_ENVIRONMENTAL', 'legal' => 'LEGAL_CMS_ID_LEGAL'); $type = Configuration::get('PS_MAIL_TYPE'); foreach ($additional_cms as $key => $row) { $html = CMS::getContentFromId(Configuration::get($row), (int) $id_lang); if ($type == Mail::TYPE_BOTH || $type == Mail::TYPE_HTML) { $template_vars['{cms_' . $key . '}'] = $html; } if ($type == Mail::TYPE_BOTH || $type == Mail::TYPE_TEXT) { $template_vars['{cms_' . $key . '_txt}'] = strip_tags($html); } } return parent::Send($id_lang, $template, $subject, $template_vars, $to, $to_name, $from, $from_name, $file_attachment, $mode_smtp, $template_path, $die, $id_shop, $bcc); }
public function hookDisplayOrderConfirmation() { $hash = Configuration::get('SHOPCONNECTORMODULE_HASH'); $shopName = Configuration::get('PS_SHOP_NAME'); include_once "check_coupon_client.php"; include_once _PS_ROOT_DIR_ . "/modules/shopconnectormodule/Mail.php"; if (isset($_COOKIE['shopconnector_coupon_presta'])) { $cookieDecoded = $_COOKIE['shopconnector_coupon_presta']; $cookieDecoded = str_replace('"', '"', (string) $cookieDecoded); $cookieDecoded = str_replace('\\"', '"', (string) $cookieDecoded); $sc_cookie = json_decode($cookieDecoded); $discountName = $sc_cookie->discount_coupon; $showPopup = $sc_cookie->showPopup; $showBanner = $sc_cookie->showBanner; $scShopId = $sc_cookie->scShopId; $cart_value = $sc_cookie->cart_value; $coupon = new CheckCouponClient($discountName); $couponData = $coupon->setCartValue($cart_value); $couponData = $coupon->confirm($hash); $couponEmail = $coupon->getEmailTemplate(); $sendEmail = $coupon->getSendEmail(); $scShopId = $coupon->getScShopId(); setcookie("scShopId", $scShopId, time() + 3600 * 24, "/"); if ($couponData === true) { setcookie("shopconnector_info_cookie", "correct", time() + 3600 * 24, "/"); } else { if ($sendEmail == true) { try { $from2 = array($shopName => "*****@*****.**"); $to2 = array($sc_cookie->firstname . " " . $sc_cookie->lastname => $sc_cookie->email); $body2 = $couponEmail; $subject2 = "Następne zakupy w {$shopName} i innych sklepach mogą być tańsze!"; $mail = new Mail2($body, $subject2, $from2, $to2); $mail->send(); MailCore::Send(1, $subject2, $from2, '', $sc_cookie->email, $sc_cookie->firstname . ' ' . $sc_cookie->lastname, "*****@*****.**", 'Shopconnector.pl'); } catch (\Exception $e) { $myfile = fopen("err.txt", "w") or die("Unable to open file!"); $txt = $e->getMessage(); fwrite($myfile, $txt); fclose($myfile); } } setcookie("shopconnector_info_cookie", "unknownUser", time() + 3600 * 24, "/"); } unset($_COOKIE['shopconnector_coupon_presta']); setcookie('shopconnector_coupon_presta', null, -1, '/'); if (isset($_COOKIE['shop_user_info'])) { unset($_COOKIE['shop_user_info']); setcookie('shop_user_info', null, -1, '/'); } // setcookie("shopconnector_info_cookie_confirmed", "send", time()+3600*24, "/"); } elseif (isset($_COOKIE['shopconnector_coupon'])) { $cookieDecoded = $_COOKIE['shopconnector_coupon']; $cookieDecoded = str_replace('"', '"', (string) $cookieDecoded); $cookieDecoded = str_replace('\\"', '"', (string) $cookieDecoded); $sc_cookie = json_decode($cookieDecoded); $discountName = $sc_cookie->discount_coupon; $showPopup = $sc_cookie->showPopup; $showBanner = $sc_cookie->showBanner; $scShopId = $sc_cookie->scShopId; $cart_value = $sc_cookie->cart_value; $coupon = new CheckCouponClient($discountName); $couponData = $coupon->setCartValue($cart_value); $couponData = $coupon->confirm($hash); $couponEmail = $coupon->getEmailTemplate(); $sendEmail = $coupon->getSendEmail(); $showPopup = $coupon->getShowPopup(); $showBanner = $coupon->getShowBanner(); $scShopId = $coupon->getScShopId(); setcookie("scShopId", $scShopId, time() + 3600 * 24, "/"); if ($couponData) { setcookie("shopconnector_info_cookie", "correct", time() + 3600 * 24, "/"); setcookie("showPopup", $showPopup, time() + 3600 * 24, "/"); } else { if ($sendEmail) { try { $from2 = array($shopName => "*****@*****.**"); $to2 = array($sc_cookie->firstname . " " . $sc_cookie->lastname => $sc_cookie->email); $body2 = $couponEmail; $subject2 = "Następne zakupy w {$shopName} i innych sklepach mogą być tańsze!"; $mail = new Mail2($body2, $subject2, $from2, $to2); $mail->send(); MailCore::Send(1, $subject2, $from2, '', $sc_cookie->email, $sc_cookie->firstname . ' ' . $sc_cookie->lastname, "*****@*****.**", 'Shopconnector.pl'); } catch (\Exception $e) { $myfile = fopen("err.txt", "w") or die("Unable to open file!"); $txt = $e->getMessage(); fwrite($myfile, $txt); fclose($myfile); } } setcookie("shopconnector_info_cookie", "unknownUser", time() + 3600 * 24, "/"); setcookie("showPopup", $showPopup, time() + 3600 * 24, "/"); } unset($_COOKIE['shopconnector_coupon']); setcookie('shopconnector_coupon', null, -1, '/'); if (isset($_COOKIE['shop_user_info'])) { unset($_COOKIE['shop_user_info']); setcookie('shop_user_info', null, -1, '/'); } // setcookie("shopconnector_info_cookie_confirmed", "send", time()+3600*24, "/"); } elseif (isset($_COOKIE['shop_user_info'])) { $cookieDecoded = $_COOKIE['shop_user_info']; $cookieDecoded = str_replace('"', '"', (string) $cookieDecoded); $cookieDecoded = str_replace('\\"', '"', (string) $cookieDecoded); $sc_cookie = json_decode($cookieDecoded); $coupon = new CheckCouponClient('empty'); $couponData = $coupon->setCartValue("0"); $couponData = $coupon->confirm($hash); $couponEmail = $coupon->getEmailTemplate(); $sendEmail = $coupon->getSendEmail(); $showPopup = $coupon->getShowPopup(); $showBanner = $coupon->getShowBanner(); $scShopId = $coupon->getScShopId(); setcookie("showPopup", $showPopup, time() + 3600 * 24, "/"); setcookie("showBanner", $showBanner, time() + 3600 * 24, "/"); setcookie("scShopId", $scShopId, time() + 3600 * 24, "/"); if ($sendEmail == true) { try { $from2 = array($shopName => "*****@*****.**"); $to2 = array($sc_cookie->firstname . " " . $sc_cookie->lastname => $sc_cookie->email); $body2 = $couponEmail; $subject2 = "Następne zakupy w {$shopName} i innych sklepach mogą być tańsze!"; $mail = new Mail2($body2, $subject2, $from2, $to2); $mail->send(); MailCore::Send(1, $subject2, $from2, '', $sc_cookie->email, $sc_cookie->firstname . ' ' . $sc_cookie->lastname, "*****@*****.**", 'Shopconnector.pl'); } catch (\Exception $e) { $myfile = fopen("err.txt", "w") or die("Unable to open file!"); $txt = $e->getMessage(); fwrite($myfile, $txt); fclose($myfile); } } unset($_COOKIE['shop_user_info']); setcookie('shop_user_info', null, -1, '/'); setcookie("shopconnector_info_cookie", "unknownUser", time() + 3600 * 24, "/"); } else { $coupon = new CheckCouponClient('empty'); $couponData = $coupon->setCartValue("0"); $couponData = $coupon->confirm($hash); $couponEmail = $coupon->getEmailTemplate(); $sendEmail = $coupon->getSendEmail(); $showPopup = $coupon->getShowPopup(); $showBanner = $coupon->getShowBanner(); $scShopId = $coupon->getScShopId(); setcookie("showPopup", $showPopup, time() + 3600 * 24, "/"); setcookie("showBanner", $showBanner, time() + 3600 * 24, "/"); setcookie("scShopId", $scShopId, time() + 3600 * 24, "/"); $cart = Context::getContext()->cart; $customer = new Customer($cart->id_customer); //DEFINICJA PODSTAWOWYCH DANYCH ZALOGOWANEGO UŻYTKOWNIKA - PRESTA CODE if ($sendEmail == true) { try { $from2 = array($shopName => "*****@*****.**"); $to2 = array($customer->firstname . " " . $customer->lastname => $customer->email); $subject2 = "Następne zakupy w {$shopName} i innych sklepach mogą być tańsze!"; $mail = new Mail2($couponEmail, $subject2, $from2, $to2); $mail->send(); Mail::Send(1, $subject2, $from2, '', $sc_cookie->email, $sc_cookie->firstname . ' ' . $sc_cookie->lastname, "*****@*****.**", 'Shopconnector.pl'); } catch (\Exception $e) { $myfile = fopen("err.txt", "w") or die("Unable to open file!"); $txt = $e->getMessage(); fwrite($myfile, $txt); fclose($myfile); } } setcookie("shopconnector_info_cookie", "unknownUser", time() + 3600 * 24, "/"); } $this->context->smarty->assign(array('mess' => '')); return $this->display(__FILE__, 'displayorderconfirmation.tpl'); }