Jump to content

Recommended Posts

Hola, tengo un problema con el módulo mailalerts, cuando se recibe un nuevo pedido me llega el correo, pero si el producto tiene un campo personalizado éste no se ve reflejado en el mail.

 

He visto una entrada de un usuario que le ocurria lo mismo y da el tema por solucionado, pero no consigo hacerlo funcionar.

 

http://www.prestashop.com/forums/topic/279998-e-mail-de-pedido-no-muestra-atributos-m%C3%B3dulo-mailalerts-solucionado/

 

 

Mi versión de mailalerts es la 2.2 y la de prestashop es la 1.4.

 

 

Este es el código original del mailalerts.php:

 

 

public function hookNewOrder($params)
    {
        if (!$this->_merchant_order OR empty($this->_merchant_mails))
            return;

        // Getting differents vars
        $id_lang = (int)(Configuration::get('PS_LANG_DEFAULT'));
         $currency = $params['currency'];
        $configuration = Configuration::getMultiple(array('PS_SHOP_EMAIL', 'PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME'));
        $order = $params['order'];
        $customer = $params['customer'];
        $delivery = new Address((int)($order->id_address_delivery));
        $invoice = new Address((int)($order->id_address_invoice));
        $order_date_text = Tools::displayDate($order->date_add, (int)($id_lang));
        $carrier = new Carrier((int)($order->id_carrier));
        $message = $order->getFirstMessage();
        if (!$message OR empty($message))
            $message = $this->l('No message');

        $itemsTable = '';
        foreach ($params['order']->getProducts() AS $key => $product)
        {
            $unit_price = $product['product_price_wt'];
            $price = $product['total_price'];
            $itemsTable .=
                '<tr style="background-color:'.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
                    <td style="padding:0.6em 0.4em;">'.$product['product_reference'].'</td>
                    <td style="padding:0.6em 0.4em;"><strong>'.$product['product_name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').'</strong></td>
                    <td style="padding:0.6em 0.4em; text-align:right;">'.Tools::displayPrice($unit_price, $currency, false, false).'</td>
                    <td style="padding:0.6em 0.4em; text-align:center;">'.(int)($product['product_quantity']).'</td>
                    <td style="padding:0.6em 0.4em; text-align:right;">'.Tools::displayPrice(($unit_price * $product['product_quantity']), $currency, false, false).'</td>
                </tr>';
        }
        foreach ($params['order']->getDiscounts() AS $discount)
        {
            $itemsTable .=
            '<tr style="background-color:#EBECEE;">
                    <td colspan="4" style="padding:0.6em 0.4em; text-align:right;">'.$this->l('Voucher code:').' '.$discount['name'].'</td>
                    <td style="padding:0.6em 0.4em; text-align:right;">-'.Tools::displayPrice($discount['value'], $currency, false, false).'</td>
            </tr>';
        }
        if ($delivery->id_state)
            $delivery_state = new State((int)($delivery->id_state));
        if ($invoice->id_state)
            $invoice_state = new State((int)($invoice->id_state));

        // Filling-in vars for email
        $template = 'new_order';
        $subject = $this->l('New order');
        $templateVars = array(
            '{firstname}' => $customer->firstname,
            '{lastname}' => $customer->lastname,
            '{email}' => $customer->email,
            '{delivery_company}' => $delivery->company,
            '{delivery_firstname}' => $delivery->firstname,
            '{delivery_lastname}' => $delivery->lastname,
            '{delivery_address1}' => $delivery->address1,
            '{delivery_address2}' => $delivery->address2,
            '{delivery_city}' => $delivery->city,
            '{delivery_postal_code}' => $delivery->postcode,
            '{delivery_country}' => $delivery->country,
            '{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
            '{delivery_phone}' => $delivery->phone,
            '{delivery_other}' => $delivery->other,
            '{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}' => $order->payment,
            '{items}' => $itemsTable,
            '{total_paid}' => Tools::displayPrice($order->total_paid, $currency),
            '{total_products}' => Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency),
            '{total_discounts}' => Tools::displayPrice($order->total_discounts, $currency),
            '{total_shipping}' => Tools::displayPrice($order->total_shipping, $currency),
            '{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $currency),
            '{currency}' => $currency->sign,
            '{message}' => $message
        );
        $iso = Language::getIsoById((int)($id_lang));
        if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.txt') AND file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.html'))
            Mail::Send($id_lang, $template, $subject, $templateVars, explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails), NULL, $configuration['PS_SHOP_EMAIL'], $configuration['PS_SHOP_NAME'], NULL, NULL, dirname(__FILE__).'/mails/');
    }
 

 

 

He probado a añadir trozos de código del hilo que comentaba, pero no he conseguido hacerlo funcionar. :(

 

 

 

Gracias.

Link to comment
Share on other sites

  • nadie locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...