How does magento automatically send an email before you go to the payment page?

Source: Internet
Author: User

In the magento system, the confirmation order email is sent by default after the payment is successful, but sometimes we encounter the payment failure.
If the customer doesn't want to pay, how can we send the order email before the payment? First, open the appcodecoremagecheckoutmodeltype folder.
In the onepage. php file, find the saveorder () method, you can see the following sentence:

$ Order = $ service-> getorder ();
If ($ order ){

Mage: dispatchevent ('checkout _ type_onepage_save_order_after ',
Array ('order' => $ order, 'quote' => $ this-> getquote ()));

/**
* A flag to set that there will be redirect to third party after confirmation
* Eg: PayPal standard IPN
*/
$ Redirecturl = $ this-> getquote ()-> getpayment ()-> getorderplaceredirecturl ();
/**
* We only want to send to customer about new order when there is no redirect to third party
*/
If (! $ Redirecturl ){
Try {
$ Order-> sendneworderemail ();
} Catch (exception $ e ){
Mage: logexception ($ E );
}
}

// Add order information to the session
$ This-> _ checkoutsession-> setlastorderid ($ order-> GETID ())
-> Setredirecturl ($ redirecturl)
-> Setlastrealorderid ($ order-> getincrementid ());

// As well a billing agreement can be created
$ Agreement = $ order-> getpayment ()-> getbillingagreement ();
If ($ agreement ){
$ This-> _ checkoutsession-> setlastbillingagreementid ($ agreement-> GETID ());
}
}

It can be found that the magento system jumps to the payment URL immediately after saving the order data. If there is no payment jump, an email will be sent. Now we can
If (! $ Redirecturl ){
Try {
$ Order-> sendneworderemail ();
} Catch (exception $ e ){
Mage: logexception ($ E );
}
}

If condition comment out, so that the system will send an order confirmation email no matter whether there is a payment jump.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.