Jump to content

Custom input field not appearing in email


jaimeweb

Recommended Posts

Hi,
I have some products that require the user to put a "player number" in a input field.

when the order goes through the custom field appear on the order in BO but not on the email sent to me.

Anyway i could get this to show on my notification email?

thanks

Link to comment
Share on other sites

This is actually quite tricky to do, so forgive me if I don't get the code right the first time. It is the hookNewOrder function in modules/mailalerts/mailalerts.php that writes the product information for the emails into the $itemsTable variable. It is the first foreach loop you'll need to edit. You'll need to add:

$customizedDatas = Product::getAllCustomizedDatas($order->id_cart, $id_lang);



then in the foreach loop, you can use the following to get the customised value:

$customizedName = ($product['id_customization'] > 0 ? $customizedDatas[$product['id_product']][$product['id_product_attribute']][$product['id_customization']][1]['value'] : NULL);



Then change the following line:

'.$product['name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').'



to:

'.$product['name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').($customizedName != NULL ? ' - ' . $customizedName : '').'

Link to comment
Share on other sites

  • 3 months later...

Hello Rocky !

I'm trying to modify mailalerts.php as you explained, but my customized datas are still not showing on the email...

Here is mi code :

$itemsTable = '';

       foreach ($params['cart']->getProducts() AS $key => $product)
       {
           $unit_price = Product::getPriceStatic($product['id_product'], true, $product['id_product_attribute']);
           $price = Product::getPriceStatic($product['id_product'], true, $product['id_product_attribute'], 6, NULL, false, true, $product['cart_quantity']);
           $customizedDatas = Product::getAllCustomizedDatas($order->id_cart, $id_lang); //MOdif
           $customizedName = ($product['id_customization'] > 0 ? $customizedDatas[$product['id_product']][$product['id_product_attribute']][$product['id_customization']][1]['value'] : NULL);//Modif
           $itemsTable .=
               '
'.$product['reference'].'
'.$product['name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').($customizedName != NULL ? ' - ' . $customizedName : '').'
'.Tools::displayPrice($unit_price, $currency, false, false).'
'.intval($product['cart_quantity']).'
'.Tools::displayPrice(($price * $product['cart_quantity']), $currency, false, false).'
';
       }



Do you have an idea ?

Thanks

Link to comment
Share on other sites

  • 3 weeks later...

Hi babyewok,

I finally used the client's notification email (wich has the customized textfields listed) :

I have modified the PayementModule.php class in order to send the email to 3 other persons.

Around the line 381 (But my file is modified because I list the customized textfields with ) you have to find

                    if ($orderStatus->send_email AND Validate::isEmail($customer->email))
                       Mail::Send(intval($order->id_lang), 'order_conf', 'Order confirmation', $data, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, $fileAttachment);



and add just after

                        Mail::Send(intval($order->id_lang), 'order_conf_admin', 'New Order from '.($customer->firstname).' '.($customer->lastname), $data, array('[email protected]','[email protected]','[email protected]'), $customer->firstname.' '.$customer->lastname, NULL, NULL, $fileAttachment);



As I am sending the email to 3 persons, I uses an array, but you can put just an address instead.

I hope it will help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...