mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +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' );
|
$currency = $container->get( 'api.shop.currency.getter' );
|
||||||
assert( $currency instanceof CurrencyGetter );
|
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(
|
return array(
|
||||||
'enabled' => defined( 'WP_DEBUG' ) && WP_DEBUG,
|
'enabled' => defined( 'WP_DEBUG' ) && WP_DEBUG,
|
||||||
'client_id' => ( $settings->has( 'client_id' ) ? $settings->get( 'client_id' ) : null ),
|
'client_id' => ( $settings->has( 'client_id' ) ? $settings->get( 'client_id' ) : null ),
|
||||||
'session_id' => substr(
|
'session_id' => $session_id,
|
||||||
method_exists( WC()->session, 'get_customer_unique_id' ) ?
|
|
||||||
md5( WC()->session->get_customer_unique_id() ) :
|
|
||||||
'',
|
|
||||||
0,
|
|
||||||
16
|
|
||||||
),
|
|
||||||
'amount' => array(
|
'amount' => array(
|
||||||
'currency_code' => $currency->get(),
|
'currency_code' => $currency->get(),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue