Skip to content

Commit

Permalink
Merge pull request #1474 from angelleye/PFW-658
Browse files Browse the repository at this point in the history
prevent order object error, PFW-658
  • Loading branch information
deepakmaurya committed Jul 23, 2020
2 parents 054eefd + a5dd581 commit 0ccba09
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,15 @@ public function angelleye_get_express_checkout_details() {
public function angelleye_do_express_checkout_payment() {
try {
if (!isset($_GET['order_id'])) {
// todo need to redirect to cart page.
wc_add_notice(__("Error processing checkout. Please try again. ", 'paypal-for-woocommerce'), 'error');
$this->angelleye_redirect();
}
$this->confirm_order_id = absint( wp_unslash( $_GET['order_id'] ) );
$order = wc_get_order($this->confirm_order_id);
if($order === false) {
wc_add_notice(__("Error processing checkout. Please try again. ", 'paypal-for-woocommerce'), 'error');
$this->angelleye_redirect();
}

if (WC()->cart->needs_shipping()) {
$errors = new WP_Error();
$shipping_country = WC()->customer->get_shipping_country();
Expand All @@ -332,8 +338,7 @@ public function angelleye_do_express_checkout_payment() {
}
}

$this->confirm_order_id = absint( wp_unslash( $_GET['order_id'] ) );
$order = wc_get_order($this->confirm_order_id);

$old_wc = version_compare(WC_VERSION, '3.0', '<');
$order_id = version_compare(WC_VERSION, '3.0', '<') ? $order->id : $order->get_id();
if ($old_wc) {
Expand Down Expand Up @@ -1642,6 +1647,8 @@ public function angelleye_process_customer($order_id) {
wp_update_user(apply_filters('woocommerce_checkout_customer_userdata', $userdata, WC()->customer));
wc_clear_notices();
}
WC()->session->set('paypal_express_checkout', $paypal_express_checkout);
WC()->session->set('post_data', $post_data);
}
}

Expand Down

0 comments on commit 0ccba09

Please sign in to comment.