ec_email_gift_certificate_recipient gift_certificate_idWhat it does:
Use this to send out the "Gift Certificate Recipient" email after it a purchased certificate is authorized.Defined in: /web/philip/tcl/ecommerce-email.tcl
Source code:
set db [ns_db gethandle subquery] set selection [ns_db 1row $db "select g.recipient_email as email, g.amount, g.certificate_to, g.certificate_from, g.certificate_message, g.claim_check from ec_gift_certificates g where g.gift_certificate_id=$gift_certificate_id"] set_variables_after_query set system_name [ad_system_name] set system_url "[ec_insecure_url]" set customer_service_signature [ec_customer_service_signature] set amount_and_message_summary "" if { ![empty_string_p $certificate_to] } { append amount_and_message_summary "To: $certificate_to\n" } append amount_and_message_summary "Amount: [ec_pretty_price $amount]\n" if { ![empty_string_p $certificate_from] } { append amount_and_message_summary "From: $certificate_from\n" } if { ![empty_string_p $certificate_message] } { append amount_and_message_summary "Message:\n$certificate_message\n" } # have to get rid of ampersands in above variables because they # mess up regsubs regsub -all "&" $system_name {\\&} system_name regsub -all "&" $system_url {\\&} system_url regsub -all "&" $amount_and_message_summary {\\&} amount_and_message_summary regsub -all "&" $claim_check {\\&} claim_check regsub -all "&" $customer_service_signature {\\&} customer_service_signature # Note: template #5 is defined to be the "Gift Certificate Recipient" email set selection [ns_db 1row $db "select subject as email_subject, message as email_body, issue_type_list from ec_email_templates where email_template_id=5"] set_variables_after_query # and get rid of ctrl-M's in the body regsub -all "\r" $email_body "" email_body regsub -all "system_name_here" $email_body $system_name email_body regsub -all "system_url_here" $email_body $system_url email_body regsub -all "amount_and_message_summary_here" $email_body $amount_and_message_summary email_body regsub -all "claim_check_here" $email_body $claim_check email_body regsub -all "customer_service_signature_here" $email_body $customer_service_signature email_body # first let's see if the recipient is a registered user of the system set user_id [database_to_tcl_string_or_null $db "select user_id from users where upper(email)='[DoubleApos [string toupper $email]]'"] ns_db dml $db "begin transaction" # create a customer service issue/interaction/action if { ![empty_string_p $user_id] } { set user_identification_and_issue_id [ec_customer_service_simple_issue $db "" "automatic" "email" "[DoubleApos "To: $email\nFrom: [ad_parameter CustomerServiceEmailAddress ecommerce]\nSubject: $email_subject"]" "" $issue_type_list $email_body $user_id "" "f" $gift_certificate_id] set user_identification_id [lindex $user_identification_and_issue_id 0] } else { # check if the recipient is an unregistered user of the system set user_identification_id [database_to_tcl_string_or_null $db "select user_identification_id from ec_user_identification where upper(email)='[DoubleApos [string toupper $email]]'"] if { [empty_string_p $user_identification_id] } { set user_identification_id [database_to_tcl_string $db "select ec_user_ident_id_sequence.nextval from dual"] ns_db dml $db "insert into ec_user_identification (user_identification_id, email) values ($user_identification_id, '[DoubleApos [string trim $email]]') " } set user_identification_and_issue_id [ec_customer_service_simple_issue $db "" "automatic" "email" "[DoubleApos "To: $email\nFrom: [ad_parameter CustomerServiceEmailAddress ecommerce]\nSubject: $email_subject"]" "" $issue_type_list $email_body "" $user_identification_id "f" $gift_certificate_id] } set issue_id [lindex $user_identification_and_issue_id 1] # add a row to the automatic email log ns_db dml $db "insert into ec_automatic_email_log (user_identification_id, email_template_id, gift_certificate_id, date_sent) values ($user_identification_id, 5, $gift_certificate_id, sysdate) " ns_db dml $db "end transaction" set email_from [ec_customer_service_email_address $user_identification_id $issue_id] ec_sendmail_from_service "$email" "$email_from" "$email_subject" "$email_body" ns_db releasehandle $db