Forums / Developer / How to send an e-mail for each item in the order basket

How to send an e-mail for each item in the order basket

Author Message

Luc Chase

Thursday 16 October 2003 7:49:25 am

I need to send an e-mail notice for each item in the confirmed order basket to the owner of the node-product orderded ( {$Basket:ProductItem:item.item_object.contentobject.main_node.contentobject_version_object.creator.data_map.user_account.content.email} ).
I'm hoping to get some hints on how to do this from the default .php script file that sends the order confirmation.

ezshopoperationcollection.php seems to be the one, but I can't figure out how to reference the above value from there and how to loop through the items in the basket to send a copy of the order to the creator of the product (filtered to show only the ordered product they created).

The Web Application Service Provider

Luc Chase

Monday 27 October 2003 4:24:02 am

Ok I've been trying to work this out for two weeks now and I don't want to wait much longer... I've posted a $25 bounty on getting the answer quickly at http://answers.google.com/answers/threadview?id=270037
I'm sure it's easy if you know how.

The Web Application Service Provider

Paul Forsyth

Monday 27 October 2003 5:20:56 am

Have you considered using workflow for this?

Are you intending to take the user to a payment gateway after the order is confirmed, or just send an email?

paul

Luc Chase

Monday 27 October 2003 10:04:21 am

I had a look at the workflow to see if I could achieve this there, but I couldn't find anything that looked like it might work. Right now with no workflow the system does everything I need except the extra e-mails to the suppliers/creators of the products. The customer will not be making any payment for the products they have chosen; they will simply wait to be contacted by the supplier(s) of the product(s) they have chosen; so no payment gateway to deal with, just send the two normal e-mails (to the shopkeeper and the customer) plus one e-mail to each of the product 'owners'/creators to send them their part of the order so they can contact the customer.

The Web Application Service Provider

Luc Chase

Wednesday 29 October 2003 5:42:59 am

Paul,
I was getting all excited that you might be about to suggest a solution... is workflow the way to solve this?

The Web Application Service Provider

Paul Forsyth

Wednesday 29 October 2003 6:03:43 am

Sorry, was busy ;)

You need to write a workflow event that will send the email after you checkout your list. If you know php it isn't too diffficult. But learning can be time consuming.

You should set up a new workflow. Then in the trigger section associate your new workflow with 'shop checkout before'. The aim here is to execute some specific code when your client checkouts, in your case this will be to send an email.

To go through with this you need to write a workflow event that will take the order and send the email. Once you have this event you can associate it with the workflow, then the system should work as expected.

Here are some docs on workflow events:

http://ez.no/developer/ez_publish_3/documentation/development/extensions/workflow_events/wrapping_event
http://ez.no/developer/ez_publish_3/documentation/development/extensions/workflow_events/creating_a_new_event

Hope this helps. Its not the quick-fix you wanted though :(

paul

Luc Chase

Wednesday 29 October 2003 8:25:08 am

okay, at least it's a hint... but don't think I'll be able to get very far. I'm only just learning php right now. Before I sit myself down for an all nighter and hopefully before you're gone for the day...
If I use the gift wrapping code as a template, how would I find the orderID and the items in that order from there. Do I need to find the order in the database or is it passed on to the workflow as a variable?
Would it just be...
$order =& eZOrder::fetch( $orderID ); ?

I need more hints....

The Web Application Service Provider

Paul Forsyth

Wednesday 29 October 2003 9:29:51 am

Yip, you need to get your hands dirty with this.

I believe the order_id is part by post variables and in this case named 'cartId'. Grab the order_id by:

$orderId =& $http->variable( "cartId" );

then it would just be:

$order = eZOrder::fetch( $orderId );

Sorry, i need to go now. Take a look at the documentation for classes:

http://pubsvn.ez.no/doxygen-3.2-1/

Spend time trying things out. Best way to learn, just costly with time.

Paul