mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
Ensure the WC session exists before trying to access it
This commit is contained in:
parent
216e805615
commit
f79fb04846
1 changed files with 10 additions and 7 deletions
|
@ -100,16 +100,19 @@ return array(
|
|||
$currency = $container->get( 'api.shop.currency.getter' );
|
||||
assert( $currency instanceof CurrencyGetter );
|
||||
|
||||
$session_id = '';
|
||||
if ( isset( WC()->session ) && method_exists( WC()->session, 'get_customer_unique_id' ) ) {
|
||||
$session_id = substr(
|
||||
md5( WC()->session->get_customer_unique_id() ),
|
||||
0,
|
||||
16
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'enabled' => defined( 'WP_DEBUG' ) && WP_DEBUG,
|
||||
'client_id' => ( $settings->has( 'client_id' ) ? $settings->get( 'client_id' ) : null ),
|
||||
'session_id' => substr(
|
||||
method_exists( WC()->session, 'get_customer_unique_id' ) ?
|
||||
md5( WC()->session->get_customer_unique_id() ) :
|
||||
'',
|
||||
0,
|
||||
16
|
||||
),
|
||||
'session_id' => $session_id,
|
||||
'amount' => array(
|
||||
'currency_code' => $currency->get(),
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue