Elementor: Disable the Menu Cart Widget Default Function and Link to the Cart Page

Smart Web Creative - Elementor: Disable the Menu Cart Widget Default Function and Link to the Cart Page

If you have ever used the Elementor widget, “Menu Cart”, you are probably familiar with its features of showing the cart subtotal and item count. What if you wanted to take users to the cart page instead? Normally you would have to create a button with just an icon that links them there. But, by doing this, you lose out on having the dynamic features of the menu cart widget like the subtotal and item count.

What if there was a way to disable the menu cart widget default function and link to the cart page? This can be accomplished with some custom code.

Adding the Code

Go to your theme’s functions.php file and add the following code:

* Redirect Menu Cart Widget to Cart Page
function redirect_menu_cart_to_cart_page() {
// Check if the current page is the cart page
if (is_cart()) {

// Get the URL of the cart page
$cart_page_url = wc_get_cart_url(); // WooCommerce cart URL

// Modify the URL if you're using a custom cart page URL
// $cart_page_url = site_url('/your-custom-cart-page'); // Example for custom cart page URL

document.addEventListener('DOMContentLoaded', function() {
var menuCartLink = document.querySelector('#elementor-menu-cart__toggle_button');
if (menuCartLink) {
menuCartLink.addEventListener('click', function(event) {
window.location.href = '<?php echo esc_url($cart_page_url); ?>';
event.stopPropagation(); // Prevent event propagation
add_action('wp_footer', 'redirect_menu_cart_to_cart_page');

Now when a user clicks on the menu cart widget, it will take them to your cart page. By adding this function, it enables the user to see their cart subtotal and item count, plus it takes them to the cart page.

Other Helpful Articles

Creating A Blog Post in WordPress

Creating a blog post in WordPress is a great way to add fresh content to your site. However, make sure that your site was built with a blog feature. Here are steps on how to create a new blog post in WordPress: Log into your WordPress site Go to yoursite.com/admin

Read More »

Content Writing Tips

If you are writing content for your website, it can be at times challenging. There’s a specific format that you should write content for your site. If you want to write some particular information on your website that pertains to your businesses or service, there are some ways to do

Read More »

Use Gmail for Webmail Accounts

If you use Gmail and you have a Webmail account, you can actually use Gmail for your Webmail accounts. There are some benefits, but also drawbacks to using this setup. It is important though that before you take the following steps, you ensure that your DNS records have the correct

Read More »

What Do You Need Done?:

(Please check all that apply)

Tell Us About You

Almost Done!

Let's Get Some Info

Let's Get Some Info

Let's Get Some Info

Let's Get Some Info

Let's Get Some Info

Let's Get Some Info