mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 12:25:15 +08:00
Fix get_cart_contents
null error
This commit is contained in:
parent
74f01c341a
commit
c64d174817
1 changed files with 5 additions and 1 deletions
|
@ -1397,7 +1397,11 @@ class SmartButton implements SmartButtonInterface {
|
|||
}
|
||||
}
|
||||
|
||||
$items = WC()->cart->get_cart_contents();
|
||||
$cart = WC()->cart ?? null;
|
||||
if ( ! $cart || $cart->is_empty() ) {
|
||||
return '';
|
||||
}
|
||||
$items = $cart->get_cart_contents();
|
||||
foreach ( $items as $item ) {
|
||||
$product = wc_get_product( $item['product_id'] );
|
||||
assert( $product instanceof WC_Product );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue