Skip to content

Commit

Permalink
PHP Fatal Error, ref #762
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed Jun 8, 2017
1 parent 2a22cbc commit 1b167f0
Showing 1 changed file with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ public function __construct($version) {
$this->angelleye_skip_text = !empty($this->setting['angelleye_skip_text']) ? $this->setting['angelleye_skip_text'] : 'Skip the forms and pay faster with PayPal!';
add_action('woocommerce_after_add_to_cart_button', array($this, 'buy_now_button'));
if($this->save_abandoned_checkout == false) {
add_action('woocommerce_after_checkout_validation', array($this, 'angelleye_paypal_express_checkout_redirect_to_paypal'), 99, 2);
if (version_compare(WC_VERSION, '3.0', '<')) {
add_action('woocommerce_after_checkout_validation', array($this, 'angelleye_paypal_express_checkout_redirect_to_paypal'), 99, 1);
} else {
add_action('woocommerce_after_checkout_validation', array($this, 'angelleye_paypal_express_checkout_redirect_to_paypal'), 99, 2);
}
}
add_action('woocommerce_add_to_cart_redirect', array($this, 'add_to_cart_redirect'));
add_action('woocommerce_checkout_billing', array($this, 'ec_set_checkout_post_data'));
Expand Down Expand Up @@ -154,37 +158,26 @@ public function buy_now_button() {
}
}

public function angelleye_paypal_express_checkout_redirect_to_paypal($data, $errors) {
if( !empty($errors) ) {
public function angelleye_paypal_express_checkout_redirect_to_paypal($data, $errors = null) {
$notice_count = 0;
if( !empty($errors)) {
foreach ( $errors->get_error_messages() as $message ) {
wc_add_notice( $message, 'error' );
$notice_count = $notice_count + 1;
}
} else {
$notice_count = wc_notice_count( 'error' );
}
if ( empty( $posted_data['woocommerce_checkout_update_totals'] ) && 0 === wc_notice_count( 'error' ) ) {
if ( empty( $_POST['woocommerce_checkout_update_totals'] ) && 0 === $notice_count ) {
try {
WC()->session->set( 'post_data', $_POST);
if (isset($_POST['payment_method']) && 'paypal_express' === $_POST['payment_method'] && $this->function_helper->ec_notice_count('error') == 0) {
$this->function_helper->ec_redirect_after_checkout();
}
} catch (Exception $ex) {

}
} else {
if ( is_ajax() ) {
if ( ! isset( WC()->session->reload_checkout ) ) {
ob_start();
wc_print_notices();
$messages = ob_get_clean();
}
$response = array(
'result' => 'failure',
'messages' => isset( $messages ) ? $messages : '',
'refresh' => isset( WC()->session->refresh_totals ),
'reload' => isset( WC()->session->reload_checkout ),
);
unset( WC()->session->refresh_totals, WC()->session->reload_checkout );
wp_send_json( $response );
}
}
}

}

public function add_to_cart_redirect($url = null) {
Expand Down

0 comments on commit 1b167f0

Please sign in to comment.