This topic has 6 replies, 2 voices, and was last updated 1 weeks, 4 days ago ago by Luca Rossi
Hi there,
We noticed that when we add a producto to our cart and the it is out of stock, there is no notification on the cart. So when we go to the Checkout page, it only appears that there are issues with products in the cart, but you cant know wich productos are.
Is there a way of showing wich products are out of stock on the cart notification?
Dear @Jennifer,
Thank you for reaching out to us.
We regret to inform you that the feature you inquired about is not currently available in our XStore theme.
If you would like to propose the addition of new features or options, we kindly invite you to share your suggestion on our Taskboard via the following link: https://www.8theme.com/taskboard/. Suggestions that receive significant support from other customers will be carefully reviewed by our development team for potential inclusion in future updates.
Alternatively, if you are interested in a paid customization service, you are welcome to contact the appropriate department through this link: https://www.8theme.com/account/#etheme_customization_panel.
We sincerely appreciate your understanding and thank you for your continued support.
Best regards,
The 8Theme Team
Hello! Thank you for your response.
So, we have other sites creted with Xstore, and there are notifications about productos without stock in the cart page.
We are attaching a screenshoot of the other sites notification when a product is Out of Stock.
Thank you,
Dear @Jennifer,
Could you kindly provide us with the details of both your websites (the one that is functioning correctly and the one that is not) so that we can compare the cart page settings?
Additionally, we would appreciate it if you could share the following information for each website:
– WP Admin URL:
– WP Admin Username:
– WP Admin Password:
Thank you for your cooperation. Please let us know if you have any questions or need further assistance.
Best regards,
The 8Theme Team
Leaving access to both sites.
We are currently using a code to achieve this in the vuapparel.som.ar site, but we notices that this other site is working fine without an additional code.
add_action( ‘woocommerce_after_cart_item_quantity_update’, ‘check_cart_stock_status’, 20, 2 );
add_action( ‘woocommerce_cart_loaded_from_session’, ‘check_cart_stock_status’, 20 );
function check_cart_stock_status() {
if ( ! WC()->cart ) {
return;
}
$out_of_stock_products = [];
// Loop through cart items to check stock status
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$product = $cart_item[‘data’]; // Product data
$product_stock = $product->get_stock_quantity();
$cart_quantity = $cart_item[‘quantity’];
// Check stock
if ( ! $product->is_in_stock() || ( $product_stock !== null && $cart_quantity > $product_stock ) ) {
$out_of_stock_products[] = $product->get_name();
// Add a notice for the out-of-stock product
wc_add_notice(
sprintf(
__( ‘The product “%s” is out of stock and cannot be purchased. Please update your cart.’, ‘woocommerce’ ),
$product->get_name()
),
‘error’
);
}
}
// Optionally remove out-of-stock items from the cart
if ( ! empty( $out_of_stock_products ) ) {
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$product = $cart_item[‘data’];
if ( in_array( $product->get_name(), $out_of_stock_products ) ) {
WC()->cart->remove_cart_item( $cart_item_key );
}
}
}
}
Dear @Jennifer,
We hope this message finds you well.
We would like to inform you that we have made some adjustments to the cart page by switching to the default cart element of Elementor, as shown in the screenshot below:
Could you kindly remove the custom codes and verify if the notifications are functioning as expected?
Thank you in advance for your assistance.
Best regards,
The 8Theme Team
You must be logged in to reply to this topic.Log in/Sign up