Skip to content

Commit

Permalink
Docs improvement in fetching carts
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed Dec 23, 2023
1 parent cf2449f commit 4bd3d79
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mt-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -1189,8 +1189,10 @@ function mt_get_cart( $user_ID = false, $cart_id = false ) {
$cart = array();
$unique_id = mt_get_unique_id();
if ( $user_ID ) {
// Logged-in user data is saved in user meta.
$cart = get_user_meta( $user_ID, '_mt_user_cart', true );
} elseif ( ! $user_ID && $cart_id ) {
// Public data is saved in transients.
$cart = get_transient( 'mt_' . $cart_id . '_cart' );
} else {
if ( is_user_logged_in() ) {
Expand All @@ -1207,5 +1209,6 @@ function mt_get_cart( $user_ID = false, $cart_id = false ) {
$cart = get_transient( 'mt_' . $unique_id . '_cart' );
}
}

return $cart;
}

0 comments on commit 4bd3d79

Please sign in to comment.