Modify the zen-cart order and payment process to prevent missing orders. After the zen-cart enters the third-party payment website, if it cannot be returned normally, it will cause the customer to be paid but there is no order data in the background. This article provides a solution for this problem. if the result cannot be returned normally after the zen-cart enters the third-party payment website, the customer will be embarrassed to have paid but no order data in the background. This article provides a solution to this problem, hoping to help the peers who are troubled by the same problem.
Anyone who has used zen-cart knows that the order steps in zen-cart are as follows ([] indicates that they are not required ):
1. shopping cart)
2. [freight method]
3. payment method)
4. confirm the order (confirmation)
5. [third-party website payment]
6. order processing (checkout process) -- This step is important because the information in the shopping cart is written to the order.
7. The order is successfully placed (checkout success)
Such a process is normal. However, during the process from step 1 to step 2, the user may close the webpage directly if the payment is successful, or cannot jump to the checkout_process page due to network reasons, the consequence is that the order cannot be created normally.
Based on the above analysis, we hope to slightly change the process, that is, the order has been created before the payment, so that even if the payment cannot be redirected back from the third-party payment website, we will not see the user's payment is successful but there is no order in the background. The modified blueprint is basically as follows:
1. after confirming the order on the checkour_confirmation page, the system will directly proccess and go to the checkour_success page, where you can go to the payment page. As shown in:
2. if the customer fails to pay at the time, he can go to his background to make payment for the historical order. As shown in:
Next, let's take a look at how to implement the above functions step by step.
1. First, we need to transform the existing payment module. You need to add the paynow_action_url field to the class of the payment method to indicate the page url for the payment. you also need to add a function, paynow_button ($ order_id ), to obtain the parameter hidden domain code of the payment form.
To add the paynow_action_url field, add the following code in the constructor of the payment class:
If (zen_not_null ($ module) & (in_array ($ module. '. php', $ this-> modules) & (isset ($ GLOBALS [$ module]-> paynow_action_url ))){
$ This-> paynow_action_url = $ GLOBALS [$ module]-> paynow_action_url;
}
To add the paynow_button ($ order_id) function, add the following code after the last function of the payment class:
Function paynow_button ($ order_id ){
If (is_array ($ this-> modules )){
If (is_object ($ GLOBALS [$ this-> selected_module]) {
Return $ GLOBALS [$ this-> selected_module]-> paynow_button ($ order_id );
}
}
}
2. use the paypal payment method as an example to describe how to implement it. In order not to destroy the original code of paypal, we copied a copy of the paypal. php file and named it paypalsimple. php, and modified the code. The code is as follows. we can see that the form_action_url is removed and the paynow_action_url is given. because we want users to click "confirm order" and directly enter checkout_process, if form_action_url is not specified, then the form for confirming the order will be directly submitted to the checkout_process page, and paynow_action_url is the previous value of form_action_url. The implementation of the paynow_button function is also very simple. here we just cut the content of the original process_button () function, but we didn't use the global $ order variable, instead, you can use $ order = new order ($ order_id) to reconstruct an object to prepare for displaying the pay now button in the history order.
- Three pages in total:
- Previous Page
- 1
- 2
- 3
- Next page
Bytes. This article provides a solution to this problem...