Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Blocks/Utils
File: CartCheckoutUtils.php
*
[500] Fix | Delete
* @return bool True if the cart page is defined, false otherwise.
[501] Fix | Delete
*/
[502] Fix | Delete
public static function has_cart_page() {
[503] Fix | Delete
return wc_get_page_permalink( 'cart', -1 ) !== -1;
[504] Fix | Delete
}
[505] Fix | Delete
[506] Fix | Delete
/**
[507] Fix | Delete
* Get product IDs from a user's persistent cart.
[508] Fix | Delete
*
[509] Fix | Delete
* This method retrieves product IDs stored in the user's persistent cart meta.
[510] Fix | Delete
* It can be used for abandoned cart emails, cart-based product collections,
[511] Fix | Delete
* and other scenarios where cart products need to be retrieved for a user.
[512] Fix | Delete
*
[513] Fix | Delete
* @param int|null $user_id The user ID. If not provided, will attempt to look up by email.
[514] Fix | Delete
* @param string|null $user_email The user email. Used to lookup user if ID not provided.
[515] Fix | Delete
* @return array<int> Array of product IDs from the user's cart, or empty array if none found.
[516] Fix | Delete
*/
[517] Fix | Delete
public static function get_cart_product_ids_for_user( ?int $user_id, ?string $user_email ) {
[518] Fix | Delete
if ( empty( $user_id ) && ! empty( $user_email ) ) {
[519] Fix | Delete
$user = get_user_by( 'email', $user_email );
[520] Fix | Delete
if ( $user ) {
[521] Fix | Delete
$user_id = $user->ID;
[522] Fix | Delete
}
[523] Fix | Delete
}
[524] Fix | Delete
[525] Fix | Delete
if ( empty( $user_id ) ) {
[526] Fix | Delete
return array();
[527] Fix | Delete
}
[528] Fix | Delete
[529] Fix | Delete
$cart_meta = get_user_meta( $user_id, '_woocommerce_persistent_cart_' . get_current_blog_id(), true );
[530] Fix | Delete
[531] Fix | Delete
if ( empty( $cart_meta ) || ! is_array( $cart_meta ) || empty( $cart_meta['cart'] ) ) {
[532] Fix | Delete
return array();
[533] Fix | Delete
}
[534] Fix | Delete
[535] Fix | Delete
return array_values(
[536] Fix | Delete
array_unique(
[537] Fix | Delete
array_filter(
[538] Fix | Delete
array_map(
[539] Fix | Delete
function ( $cart_item ) {
[540] Fix | Delete
return isset( $cart_item['product_id'] ) ? intval( $cart_item['product_id'] ) : 0;
[541] Fix | Delete
},
[542] Fix | Delete
$cart_meta['cart']
[543] Fix | Delete
)
[544] Fix | Delete
)
[545] Fix | Delete
)
[546] Fix | Delete
);
[547] Fix | Delete
}
[548] Fix | Delete
}
[549] Fix | Delete
[550] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function