Email after insert order

MichalD

New member
Hi,
I need to make new style of email to admin and customer who is placing an order. I try to make it with video and manual but it doesent works. Can someone help me? i have a table "orders" and all anoter info about users are that same as in dadabik_users. I need to have 2 another mails 1st for admin about "[user] is plasing an order. Print it and in subiect "New order from [user]" and the 2nd to user "thank you for your order" with subiect "New order is placed.

PLEASE HELP MEEE :)

Your current DaDaBIK version​

You are using DaDaBIK version 11.9-Elba monthly, installed on 13/04/2023 (installation code: 1866363eb5c9a21b19), the latest version of DaDaBIK is 11.10-Elba released on 13/07/2023

System info​

PHP Version: 7.4.30

mysql version: 5.7.28-31-log

Web server: Apache

Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

URL installation: http://127.0.0.1/dada/
 
Last edited:

deep64blue

DaDaBIK Guru
but it doesent works.
Can you be clearer about what problem(s) you are having / where you are getting stuck please.

Also please include the mandatory information (version etc) which can be found here:-

In your application go to "Edit this App" in the top right hand corner

1687940705662.png



You will see the About / Upgrade link in the top right hand corner

1687940906015.png
 

MichalD

New member
I see on forum, documentation and on video 3 version of code but all is not working. I dont get any emails. When i put order i get only this default email from system.
 

deep64blue

DaDaBIK Guru
Can you post here the exact code you are using please, we also need the mandatory information as per my post.
 

MichalD

New member
That is a 2 version what i have. I'm not programer and i cant write php myself :( :

$hooks['zamowienia']['insert']['after'] = 'dadabik_send_notice_after_zamowienia_insert';

function dadabik_send_notice_after_zamowienia_insert($id)
{
global $conn;

// get the name from the ID
$sql = "SELECT id FROM zamowienia WHERE id = :id";

$res_prepare = prepare_db($conn, $sql);

$res_bind = bind_param_db($res_prepare, ':id', $id);

$res = execute_prepared_db($res_prepare,0);

$row = fetch_row_db($res_prepare);

mail ('michal@duber.com.pl', 'Otrzymałeś nowe zamowienie od salonu ('.$row['adres'].') .Sprawdź je, zaakceptuj i wydrukuj.');

}
$hooks['zamowienia']['edit']['after'] = 'dadabik_send_notice_after_zamowienia_edit';

function dadabik_send_notice_after_zamowienia_edit($id_user)
{
global $conn;

// get the name from the ID
$sql = "SELECT first_name_user FROM dadabik_users WHERE first_name_user = :first_name_user";

$res_prepare = prepare_db($conn, $sql);

$res_bind = bind_param_db($res_prepare, ':first_name_user', $id_user);

$res = execute_prepared_db($res_prepare,0);

$row = fetch_row_db($res_prepare);

mail ('$row[email_user]', 'Otrzymałeś nowe zamowienie', 'od salonu ('.$row['name_account'].') .Sprawdź je, zaakceptuj i wydrukuj.');


System info​

PHP Version: 7.4.30

mysql version: 5.7.28-31-log

Web server: Apache

Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

URL installation: http://127.0.0.1/dada/
 

deep64blue

DaDaBIK Guru
You are trying to use values you haven't retrieved from the database, you need to specify the fields you need - these can be from multiple tables but you need to write the SQL query to extract them.

$sql = "SELECT id FROM zamowienia WHERE id = :id";
This only retrieves the id but you try to use the address field in your email - $row['adres'].

$sql = "SELECT first_name_user FROM dadabik_users WHERE first_name_user = :first_name_user";
Again only retrieves first_name_user but you try to use $row['name_account'] in the email.
 
Top