Hi everyone,
i'm really getting into the ecommerce module it offers a great framework for customisation, but i' having one small [but quite important] problem.

I'm only in testing at the moment but when i buy one of my test 'file' products [set price at £0.01] everything works fine but a payment confirmation email is not always sent to me [acting as the customer] saying what products i bought etc. i believe the emails are sent from the store.module?

i don't know if i'm missing something here, when are these emails meant to be sent and are they sent by the store.module or are they sent by other modules within the ecommerce structure.

any help would be brilliant

thanks
Tom

Comments

neclimdul’s picture

I'm not sure what the problem is but I might be able to point you in the right direction. The code for sending emails is in store.module but it is not actually done by store.module. The payment module is responsible for this. This is slightly counter intuative at some level but it's the way things are right now. See
store_send_invoice_email($txnid);
on line 100 in cod.module for an example of how this is fired off.

My first guess would be that since its not always happening is that you're switching payment modules and only one of the payment modules is triggering this properly. Hope this helps get you on the right track to tracking down the bug.

thomjjames’s picture

Hi, thanks for a rapid response and some useful info.

so this is the way i see it [please correct me if i'm wrong]:
the store.module has the sending mechanism in it [store_send_invoice_email] and the store_send_invoice_email function is called by other modules [mainly the payment.module] to send invoices??

i'm offering file downloads using file.module and only paypal as the payment method, do i need to add something to the file.module or paypal.module to fire off the emails or should the payment.module be handling this when the transaction is set to complete?

thanks again
Tom

thomjjames’s picture

Hello,

thanks to the push in the right direction above and after abit of playing round i've narrowed it down to the paypal.module.

[around line 304]

$is_new = (db_result(db_query('SELECT COUNT(txnid) FROM {ec_paypal} WHERE ppid = %d', $ppid))) ? false : true;

[around line 319]

if ($is_new && $txnid) {

if i remove the $is_new in the above if statement, things work just fine! i'm not too sure what this $is_new is there for, can anyone explain??

thanks
Tom

hirstpf1’s picture

Component: store.module » paypal

The line in paypal.module (around line 310)

$is_new = (db_result(db_query('SELECT COUNT(txnid) FROM {ec_paypal} WHERE ppid = %d', $ppid))) ? false : true;

Appears to be intended to ensure that the customer is only sent a confirmation e-mail if this is the intitial interaction with that ppid (Paypal transaction id). However the logic seems not to work - not sure if it is due to the ? false :true construction. However, adding the following line:

$is_new = !($is_new);

afterwards, seems to make it work ok. Completely deleting $is_new would mean people getting confusing 'confirmations' in response to subsequent interactions.

spazio’s picture

I get the same error, but I am not using paypal module. The error appears when not registered - anonymous user - users buy something. I checked the option "Customers do not have to create accounts in order to purchase items from this site." in /admin/store/settings. If registered users buy something, everything works fine.

Ian Ward’s picture

I can confirm I have the same symptoms. I put in some extra debug lines around the logic to check, and for some reason $is_new was false when the email failed to send.

Ian

Bevan’s picture

Version: 4.7.x-1.x-dev » 5.x-3.0
Status: Active » Closed (duplicate)

I believe this is duplicate of http://drupal.org/node/126523

drupalegg’s picture

I changed "%d" to "%s" and all works fine.
The reason is, Paypal's "txn_id" is not "ingeger". It uses alphabet and integer to create unique ID.

$is_new = (db_result(db_query('SELECT COUNT(txnid) FROM {ec_paypal} WHERE ppid = %d', $ppid))) ? false : true;

TO

$is_new = (db_result(db_query('SELECT COUNT(txnid) FROM {ec_paypal} WHERE ppid = %s', $ppid))) ? false : true;