Zen_cart payment generates order in advance

Source: Internet
Author: User

In addition to PayPal , the customer enters index. php through other payment methods? Main_page = checkout_confirmation. The order can be generated.
!! Paypal is a little different. It can only be returned from its official website [paypal.com] And Go To The checkout_process page to generate an order.
unexpected events often occur, such as poor network conditions. for example, the customer accidentally closes the page before returning.
then, our website's backend will not be able to see what products the customer bought (although we can see who bought them on the PayPal backend, but it is really hard to know what he actually bought.) This is a very depressing thing
the principle of PayPal leak-proof ticket is ------ In the checkout_confirmation.php page, Mr. orders !!!
method: Echo title_continue_checkout_procedure in the last part of the file. '
'. text_continue_checkout_procedure;
Add Code :

// Create the order record leak-proof ticket
If ($ _ session ['payment'] = 'paypal '){
$ Insert_id = $ order-> Create ($ order_totals, 2 );
$ Zco_notifier-> notify ('your Y _ checkout_process_after_order_create ');
$ Payment_modules-> after_order_create ($ insert_id );
$ Zco_notifier-> notify ('your Y _ checkout_process_after_payment_modules_after_order_create ');
// Store the product info to the order
$ Order-> create_add_products ($ insert_id );
$ _ Session ['order _ number_created '] = $ insert_id;

In order to avoid the impact on other payment methods, the Code makes a judgment, only Paypal payment will run these order generation code, after this section is added, you don't have to worry about missing tickets-Background orders after successful payment

The GS/AK is an order that prevents missing orders. These orders are only viewed when a missing order is generated. The information in these orders is less than the normal order number, but at least we can see the customer information and what products we have purchased...

If you need a more perfect practice to prevent customers from repeatedly generating orders when accessing the checkout process, you need to add a judgment.

If ($ _ session ['payment']! = 'Paypal '){
/* // Create the order record
$ Insert_id = $ order-> Create ($ order_totals, 2 );
$ Zco_notifier-> notify ('your Y _ checkout_process_after_order_create ');
$ Payment_modules-> after_order_create ($ insert_id );
$ Zco_notifier-> notify ('your Y _ checkout_process_after_payment_modules_after_order_create ');
// Store the product info to the order
$ Order-> create_add_products ($ insert_id );
$ _ Session ['order _ number_created '] = $ insert_id;
$ Zco_notifier-> notify ('your Y _ checkout_process_after_order_create_add_products ');
// Send email notifications
$ Order-> send_order_email ($ insert_id, 2 );
$ Zco_notifier-> notify ('your Y _ checkout_process_after_send_order_email ');*/
}

In addition, on the confirmation page, if the customer keeps refreshing the page, the order will be generated continuously. You can add a limit.

// Create the order record leak-proof ticket
If ($ _ session ['payment'] = 'paypal 'and! Isset ($ _ session ['order _ number_created ']) {
$ Insert_id = $ order-> Create ($ order_totals, 2 );
$ Zco_notifier-> notify ('your Y _ checkout_process_after_order_create ');
$ Payment_modules-> after_order_create ($ insert_id );
$ Zco_notifier-> notify ('your Y _ checkout_process_after_payment_modules_after_order_create ');
// Store the product info to the order
$ Order-> create_add_products ($ insert_id );
$ _ Session ['order _ number_created '] = $ insert_id;
}

Add unset ($ _ session ['order _ number_created ']) to any location in pages/checkout_payment/header_php.php.
In this way, even if the customer keeps refreshing the confirmation page, because $ _ session ['order _ number_created '] has been set, the order is no longer generated,
If the customer returns and modifies the shopping cart, $ _ session ['order _ number_created '] will be cleared when it reaches checkout_payment again,
In fact, the code for generating an order can be written in function confirmation () of modules/payment/Paypal. php.
The Code is as follows:

Function confirmation (){
If (! Isset ($ _ session ['order _ number_created '])
{
Global $ order, $ order_total_modules, $ order_totals, $ zco_notifier, $ insert_id;
$ Zco_notifier-> notify ('your Y _ checkout_process_begin '); // if the customer is not logged on, redirect them to the time out page
If (! $ _ Session ['customer _ id'])
{
Zen_redirect (zen_href_link (filename_time_out ));
}
Else
{// Validate customer
If (zen_get_customer_validate_session ($ _ session ['customer _ id']) = false)
{
$ _ Session ['navigation']-> set_snapshot (Array ('Mode' => 'ssl ', 'page' => filename_checkout_shipping ));
Zen_redirect (zen_href_link (filename_login, '', 'ssl '));
}
}
If (isset ($ mycartid) & $ mycartid === _ session ['cart']-> cartid)
{
Return array ('title' => module_payment_paypal_text_description );
}
$ Mycartid = $ _ session ['cart']-> cartid;
$ Order = new order; // prevent 0-entry orders from being generated/spoofed
If (sizeof ($ order-> Products) <1)
{
Zen_redirect (zen_href_link (filename_shopping_cart ));
}
$ Order_total_modules = new order_total;
$ Zco_notifier-> Policy ('policy _ checkout_process_before_order_totals_pre_confirmation_check ');
// $ Order_totals = $ order_total_modules-> pre_confirmation_check ();
$ Zco_notifier-> Policy ('policy _ checkout_process_before_order_totals_process ');
$ Order_totals = $ order_total_modules-> process ();
$ Zco_notifier-> notify ('your Y _ checkout_process_after_order_totals_process ');
If (! Isset ($ _ session ['payment']) &! $ Credit_covers)
{
Zen_redirect (zen_href_link (filename_default ));
} // Load the before_process
// Load the before_process function from the payment modules
// $ Zco_notifier-> notify ('your Y _ checkout_process_after_payment_modules_beforeprocess ');
// Create the order record
$ Insert_id = $ order-> Create ($ order_totals, 2 );
Require (dir_ws_ages. 'English/email_extras.php ');
Require (dir_ws_ages. 'English/checkout_process.php ');
// Store the product info to the order
$ Order-> create_add_products ($ insert_id );
$ _ Session ['order _ number_created '] = $ insert_id;
$ Zco_notifier-> notify ('your Y _ checkout_process_after_order_create_add_products ');
$ Order-> send_order_email ($ insert_id, 2 );
If (is_array ($ order_total_modules-> modules ))
{
Reset ($ order_total_modules-> modules );
While (List (, $ value) = each ($ order_total_modules-> modules ))
{
$ Class = substr ($ value, 0, strrpos ($ value ,'.'));
If (! Isset ($ globals [$ class]) continue;
$ Globals [$ class]-> output = NULL;
}
}
}
Else
Return false;
}

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.