0

I'm using Channel Form to edit the data stored for a CartThrob Order entry. I have a couple of CartThrob notifications set up to send an email when the status is changed. These work just fine. However, they are also being triggered when any data field is changed... without the Status being changed.

For example, if an Entry Status is set to "Booked", a Notification is sent. If I edit the Entry (using Channel Form) but leave the Status as it is (still as "Booked"), the Notification email is sent again anyway.

Am I doing something wrong?

2 Answers 2

0

Sounds like a bug to me...the cartthorb notifications/status update system is a bit ropey in all.

I have been poking around in that area for other reasons...I suspect you could trap this and stop the emails going out by modifying

third_party/cartthrob/libraries/cartthrob_email.php

around line 49 you could add an extra condition to make sure the status actually has changed...the following code is NOT tested but might get you started:

From: if ($status_end && ($notification['status_end'] == "ANY" || $notification['status_end'] == $status_end))

To:

                if (($status_end && ($notification['status_end'] == "ANY" || $notification['status_end'] == $status_end)) && $status_start !== $status_end)

It's a hack you'll have to maintain, so I would book a call in with the CartThrob folks (and/or ping them on twitter) - and get it fixed properly, but this might work in the meantime.

3
  • Apologies for the formatting on the code block, the Stack Exchange editor blows... Commented Jul 24, 2014 at 2:33
  • Hi Jeremy, Thanks a lot for your constructive help. Much appreciated. :-) I'll put this to CartThrob peeps and see what they think. Thanks again. Commented Jul 25, 2014 at 7:40
  • How did you go? and...Maybe accept the answer? Commented Aug 24, 2014 at 2:38
0

I contacted CartThrob Support and this what they came back with...

"I reviewed the edit that the other user offered on StackExchange. After testing locally, I discovered that their fix is a good start, but won't fix the problem entirely. The current channel form hook that triggers the email unfortunately already has both the start and end statuses set to the end status by the time it reaches the function to send the email. Basically whenever Channel Form submits, the start and end statuses are the same so that updated conditional will not send an email. I made some edits to the ext.cartthrob.php file and the libraries/Cartthrob_emails.php file and it seems to be working now."

I don't know what specific changes were made in those files, but let me know if you'd like me to send you copies. :-)

1
  • Well I said it was untested ;) Commented Oct 27, 2014 at 1:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.