Merge pull request #25507 from woocommerce/fix/25490
Fixed fatal error on the thank you page if order is not specified.
This commit is contained in:
commit
d64cc69cd7
|
@ -68,11 +68,10 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
$this->description = trim( $this->description );
|
||||
}
|
||||
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
||||
add_action( 'woocommerce_order_status_processing', array( $this, 'capture_payment' ) );
|
||||
add_action( 'woocommerce_order_status_completed', array( $this, 'capture_payment' ) );
|
||||
add_filter( 'woocommerce_thankyou_order_received_text', array( $this, 'order_received_text' ), 10, 2 );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
|
||||
if ( ! $this->is_valid_for_use() ) {
|
||||
$this->enabled = 'no';
|
||||
|
@ -85,6 +84,10 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
new WC_Gateway_Paypal_PDT_Handler( $this->testmode, $this->identity_token );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'yes' === $this->enabled ) {
|
||||
add_filter( 'woocommerce_thankyou_order_received_text', array( $this, 'order_received_text' ), 10, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,7 +253,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if this gateway is enabled and available in the user's country.
|
||||
* Check if this gateway is available in the user's country based on currency.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -461,7 +464,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
* @return string
|
||||
*/
|
||||
public function order_received_text( $text, $order ) {
|
||||
if ( $this->id === $order->get_payment_method() ) {
|
||||
if ( $order && $this->id === $order->get_payment_method() ) {
|
||||
return esc_html__( 'Thank you for your payment. Your transaction has been completed, and a receipt for your purchase has been emailed to you. Log into your PayPal account to view transaction details.', 'woocommerce' );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue