Esempio n. 1
0
    public function hookNewOrder($params)
    {
        if (!MondialRelay::isMondialRelayCarrier($params['cart']->id_carrier)) {
            return;
        }
        DB::getInstance()->execute('
			UPDATE `' . _DB_PREFIX_ . 'mr_selected`
			SET `id_order` = ' . (int) $params['order']->id . '
			WHERE `id_cart` = ' . (int) $params['cart']->id);
    }
Esempio n. 2
0
    public function hookNewOrder($params)
    {
        if (!MondialRelay::isMondialRelayCarrier($params['cart']->id_carrier)) {
            return;
        }
        $order = $params['order'];
        $currency = $params['currency'];
        $id_lang = (int) $order->id_lang;
        $customer = new Customer($order->id_customer);
        $carrier = new Carrier($order->id_carrier);
        $invoice = new Address((int) $order->id_address_invoice);
        $invoice_state = $invoice->id_state ? new State($invoice->id_state) : false;
        if (version_compare(_PS_VERSION_, '1.5', '<')) {
            $order_date_text = Tools::displayDate($order->date_add, (int) $id_lang);
        } else {
            $order_date_text = Tools::displayDate($order->date_add, null);
        }
        DB::getInstance()->execute('
		UPDATE `' . _DB_PREFIX_ . 'mr_selected`
		SET `id_order` = ' . (int) $order->id . '
		WHERE `id_cart` = ' . (int) $params['cart']->id);
        /*============================================
        		// GET MR INFOS
        		//============================================*/
        $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'mr_selected` WHERE `id_cart` = ' . (int) $params['cart']->id . ' AND `id_order` = ' . (int) $order->id . '';
        $mr_point = DB::getInstance()->getRow($sql);
        if (!$mr_point['MR_Selected_Num']) {
            return false;
        }
        /*============================================
        		// SEND MAIL
        		//============================================*/
        $template = 'mr_new_order';
        $subject = $this->l('New order', false, (int) $id_lang) . ' - ' . sprintf('%06d', $order->id);
        $mr_address = '';
        if ($mr_point['MR_Selected_LgAdr2']) {
            $mr_address .= $mr_point['MR_Selected_LgAdr2'] . '';
        }
        if ($mr_point['MR_Selected_LgAdr3']) {
            $mr_address .= $mr_point['MR_Selected_LgAdr3'] . '';
        }
        if ($mr_point['MR_Selected_LgAdr4']) {
            $mr_address .= $mr_point['MR_Selected_LgAdr4'] . '';
        }
        $templateVars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{delivery_company}' => $mr_point['MR_Selected_LgAdr1'], '{delivery_address1}' => $mr_address, '{delivery_city}' => $mr_point['MR_Selected_Ville'], '{delivery_postal_code}' => $mr_point['MR_Selected_CP'], '{delivery_country}' => $mr_point['MR_Selected_Pays'], '{invoice_company}' => $invoice->company, '{invoice_firstname}' => $invoice->firstname, '{invoice_lastname}' => $invoice->lastname, '{invoice_address2}' => $invoice->address2, '{invoice_address1}' => $invoice->address1, '{invoice_city}' => $invoice->city, '{invoice_postal_code}' => $invoice->postcode, '{invoice_country}' => $invoice->country, '{invoice_state}' => $invoice->id_state ? $invoice_state->name : '', '{invoice_phone}' => $invoice->phone, '{invoice_other}' => $invoice->other, '{order_name}' => sprintf('%06d', $order->id), '{shop_name}' => Configuration::get('PS_SHOP_NAME'), '{date}' => $order_date_text, '{carrier}' => $carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name, '{payment}' => Tools::substr($order->payment, 0, 32), '{currency}' => $currency->sign);
        $iso = Language::getIsoById((int) $id_lang);
        if (file_exists(dirname(__FILE__) . '/mails/' . $iso . '/' . $template . '.txt') && file_exists(dirname(__FILE__) . '/mails/' . $iso . '/' . $template . '.html')) {
            Mail::Send((int) $id_lang, $template, $subject, $templateVars, $customer->email, $customer->firstname . ' ' . $customer->lastname, Configuration::get('PS_SHOP_EMAIL'), Configuration::get('PS_SHOP_NAME'), null, null, dirname(__FILE__) . '/mails/');
        }
    }