Modify Zen-cart order and payment process to prevent missing orders _php tutorial

Source: Internet
Author: User
Zen-cart Enter the third party payment website, if not return normally, it will cause the customer has paid but the backstage but no order data embarrassing situation. This article gives a solution to this problem, hoping to be helpful to peers who are troubled by the same problem.

People who have used Zen-cart know that the next step in Zen-cart is the following (where the representation in [] is not required):

1. Shopping cart (shopping cart)

2. [Shipping Method (delivery method)]

3. Payment method (Payment method)

4. Order Confirmation (Confirmation)

5. [Payment by third party website]

6. Order Processing (checkout process)-This step is important because the information in the shopping cart will be written to the order here

7. Order success (Checkout success)

Such a process does not have any problems under normal circumstances. However, from the 5th to the 6th part of the process, the user may think that the payment is successful directly off the page, or due to network causes can not jump to the checkout_process page, the result is very serious, because the order can not be created normally.

Based on the above analysis, we would like to change the process a little bit, that is, the order has been created before payment, so even if the payment can not be from the third-party payment site to return, we will not have the user payment success in the background without orders. The revised blueprint is basically the following:

1. After confirming the order on the Checkour_confirmation page, it will be proccess directly and go to the Checkour_success page where you can enter the payment page. As shown in the following:

2. If the customer is not able to pay at that time, can also enter their own backstage to pay for the historical order. As shown in the following:

Let's take a look at how to achieve the above functionality step-by-step.

1. First we need to make a transformation of the existing payment module. You need to add a field paynow_action_url to the class of the payment method that represents the URL of the page to be paid, plus a function, Paynow_button ($order _id), to get the parameters of the payment form to hide the field code.

To increase the Paynow_action_url field, add the following code to the constructor of the class payment:

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. Take the PayPal payment method as an example to illustrate how to implement it. In order not to break the original PayPal code, we will copy the paypal.php file, and name it paypalsimple.php, and make appropriate changes to the code inside. The code looks like this, and you can see that the designation for Form_action_url is removed and given the Paynow_action_url, because we want the user to go directly to Checkout_process after clicking "Confirm Order", so if you don't specify FORM_ Action_url, then the confirmation order form will be submitted directly to the Checkout_process page, and Paynow_action_url is the value of the previous form_action_url. The implementation of the Paynow_button function is also very simple, just cut the contents of the original Process_button () function, except that we do not use the global $order variable, but instead use $order = New Order ($order _id). , to reconstruct an object that is prepared for displaying the pay Now button in a history order.

    • Total 3 Pages:
    • Previous page
    • 1
    • 2
    • 3
    • Next page

http://www.bkjia.com/PHPjc/364529.html www.bkjia.com true http://www.bkjia.com/PHPjc/364529.html techarticle Zen-cart Enter the third party payment website, if not return normally, it will cause the customer has paid but the backstage but no order data embarrassing situation. This article gives a solution to this problem ...

  • 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.