{"id":202759,"date":"2022-02-12T03:59:41","date_gmt":"2022-02-12T06:59:41","guid":{"rendered":"https:\/\/quadlayers.com\/?p=202759"},"modified":"2022-02-24T15:58:25","modified_gmt":"2022-02-24T18:58:25","slug":"create-woocommerce-mini-cart","status":"publish","type":"post","link":"https:\/\/quadlayers.com\/create-woocommerce-mini-cart\/","title":{"rendered":"How to Create a WooCommerce Mini Cart: 3 Methods"},"content":{"rendered":"
Are you looking for an easy way to set yp a WooCommerce mini cart<\/strong>? If your checkout experience is sluggish and repetitive, it can affect your customer\u2019s shopping experience. Improving the flow of your checkout process is an integral part of improving your lead conversions and a mini cart can be a great solution for it.<\/p>\n So to help you add one to your website, here’s a guide on how to create a WooCommerce mini cart.<\/strong> But first, let\u2019s take a look at what exactly is a mini cart and why you might need to use one.<\/p>\n Your WooCommerce Mini cart is just a small form of your actual WordPress cart page. It contains the products added to your cart along with some more details. The contents of the mini cart depend on your active WordPress theme but they generally include:<\/p>\n Regardless of the details your WooCommerce mini cart shows, it is a crucial part of your customer\u2019s user experience while browsing your WooCommerce store. It’s an accessible tool that your customers can use to move to the checkout page directly from any part of your website and helps in keeping track of the cart items.<\/p>\n Even we use the mini cart at QuadLayers<\/a>. If you add a product to the cart, you can view the mini cart by hovering on the cart icon in the header menu.<\/p>\n If you look at the screenshot below, we have added the product WooCommerce Checkout Manager<\/a> to the cart. This is also displayed in the mini cart along with the quantity and subtotal.<\/p>\n <\/p>\n By default, your WooCommerce theme might come with its own WooCommerce mini cart. And even if it does, its position and style itself may not be fully customizable from your theme settings. Furthermore, it also may not be in the perfect place for your mini cart.<\/p>\n Some of our readers might consider adding a floating mini cart whereas others might add it to the sidebar or the footer. There are various possible mini cart approaches that you might want to consider using. Moreover, you might also need to add more content to your mini carts such as shipping prices, additional cart details, custom messages, and more.<\/p>\n The ease of comfort when using your cart can also be important for you and your customers to improve your actual sales<\/strong>. A customized, sales-ready checkout that perfectly fits your website aesthetic can be a game-changer for your WooCommerce website. So if you want to create and add your custom mini cart to different pages of your website, then look no further!<\/p>\n To create and add your WooCommerce Mini cart,<\/strong> you can use 3 different methods<\/strong>:<\/p>\n Let’s take a look at each method and the steps involved in all of them, starting with the default method of using WordPress Widgets.<\/p>\n By default, you can create WooCommerce mini carts using the\u00a0WooCommerce cart widget.<\/strong> Since we’re using a widget, it can be positioned in only the available widget areas of the theme. The most common areas include:<\/p>\n There can be more widget areas depending on your theme. But please make sure that you use one of the WooCommerce compatible themes<\/a> as well.<\/p>\n To add a cart widget, you will need to select a widget area first. So open your WP Admin Dashboard and go to Appearance > Widgets<\/strong>. Then, you choose the widget area for your mini cart.<\/p>\n For our demo, we\u2019ll be using the Sidebar<\/strong>. But you can use the widget area that is most convenient for you.<\/p>\n <\/p>\n After you select the widget area for your mini cart, click on the + button<\/strong> to add the widget.\u00a0Use the search bar to search for Cart<\/strong> and click on it to add the widget<\/strong>.<\/p>\n If you can’t see the widget, please make sure that you have properly set up WooCommerce<\/a> on your website.<\/p>\n Here, you can also enable or disable the Hide if cart is empty <\/strong>option. We recommend you enable it because your sidebar cart will be hidden if your customer\u2019s cart is empty. This will also make your website look more functional.<\/p>\n <\/p>\n Once you finish adding the cart widget, Update<\/strong> your widgets\u00a0to save your changes. Now, your sidebar mini cart should show up on your front end.<\/p>\n <\/p>\n Of course, you can also add your mini cart to a different widget area as well. Simply select the location under the widgets page and you can easily add the widget below your header<\/a> or on the footer.<\/p>\n <\/p>\n While this is the easiest way<\/strong> to create your WooCommerce mini cart, it comes with a fair number of limitations<\/strong>. For one, there are no customizations<\/strong> for your mini cart. You are very limited in terms of how your mini cart looks like and how it’s accessed by your customers.<\/p>\n The mini cart positions are limited to the widget areas provided by your theme. Additionally, features like pop-up mini carts or custom fields to the cart are also not available for the customers or the website owner. So, if you want a more customizable mini cart we recommend you keep reading and consider the following methods instead.<\/p>\n Using a WordPress plugin is one of the easiest ways to curate your cart experience. You can ensure that your customers can easily check out at any time with ease with the help of plugins. They also allow you to simplify the checkout experience of your website.<\/p>\n The mini cart plugins provide nifty features to promote your product sales and improve your lead generation. For example:<\/p>\n So, we highly recommend using a WordPress plugin dedicated to adding and customizing your WooCommerce mini cart.<\/p>\n For our demo, we\u2019ll be using the Woocommerce Cart All in One plugin<\/strong><\/a>. It is one of the best plugins to create a mini cart on your website. The plugin is also very easy to use and has all the features that you need like a mini cart popup, sidebar cart, or menu cart customization options.<\/p>\n <\/p>\n We also have a list of the best WooCommerce mini cart plugins<\/a>. If you want to use any other plugin, you can have a look at it too.<\/p>\n Let\u2019s start by installing and activating the plugin.<\/p>\n Open your WP Admin Dashboard<\/strong> and then go to Plugins > Add New<\/strong> on your sidebar.<\/p>\n <\/p>\n Then, use the search bar on the top right to search for Cart All In One For WooCommerce<\/strong>.<\/p>\n After you find the plugin, click on Install Now<\/strong> to install the plugin. Finally, Activate<\/strong> the plugin once it’s installed.<\/p>\n <\/p>\n If you want to use a premium plugin, you’ll have to upload and install it manually. Have a look at our detailed guide to install a WordPress plugin manually<\/a> for more information.<\/p>\n Now, we need to configure the plugin to enable your WooCommerce mini cart.<\/p>\n To configure the plugin\u2019s WooCommerce mini cart, click on the Cart All in One tab<\/strong> on your WP Admin Dashboard<\/strong>. This will open the plugin\u2019s Dashboard page.<\/p>\n <\/p>\n In the free version of the plugin, you can enable a Sidebar<\/strong> Mini cart<\/strong> or a Menu mini cart<\/strong>. You can also add and configure an AJAX Add to Cart button but let\u2019s focus on only the mini cart options for now.<\/p>\n To activate the mini cart popup on your website, open the Sidebar Cart <\/strong>and\u00a0click on Enable<\/strong>. You can also use the Mobile Enable<\/strong> option to enable\/disable the mini cart popup on mobile devices. Finally, Save<\/strong> your changes.<\/p>\n <\/p>\n Now, go and reload the front end of your website. You should see your new mini cart icon on your web page. You can just click on it to open your mini cart.<\/p>\n <\/p>\n Additionally, you can also add a menu cart<\/strong> to any of your menus. Just open the Menu Cart<\/strong> tab and Enable <\/strong>it just like the previous steps. You can also enable it on the mobile menus<\/a> if needed.<\/p>\n Next, you need to add the WordPress menus where you want to display the menu cart on your website. Simply choose the menus where you\u2019d like to add to your WooCommerce mini cart in the Menus<\/strong> field. Then click on Save<\/strong>.<\/p>\n <\/p>\n You should now see your menu mini cart on your website. It will be added to the menus that you selected for the mini cart.<\/p>\n <\/p>\n Customization is a key feature with the Cart All in One plugin<\/strong>. You can freely customize your sidebar cart as well as the menu cart. This includes colors, mini cart styles, positions, custom animations, mini cart icons, sidebar menu styles, and much more.<\/p>\n To access the customization options, go to Appearance > Customize<\/strong> on your WP Admin Dashboard. You will be redirected to your theme customizer. Here, click on Cart All in One For WooCommerce<\/strong> and you should see all the mini cart customization options.<\/p>\n <\/p>\n For this demo, we’ll customize the Sidebar Cart. So click\u00a0Sidecart Cart<\/strong> and you should see all the options for it. For now, we’ll enable a smaller mini cart using the Display Sidebar<\/strong> content option and change the Sidebar cart position.<\/strong><\/p>\n But you can further customize your mini cart using these options depending on how it suits your website. There is still a lot to edit like interaction with the cart icon itself so the mini cart appears when you hover the icon, customize the loading icon, and many more.<\/p>\n <\/p>\n Once you\u2019re done with your changes, click on Publish<\/strong> save them. You’ll be able to see all these customizations of your mini cart on your website.<\/p>\n And that\u2019s the basic gist of customizing your mini cart using the plugin. If you want to learn more about all the customization options provided by the plugin we highly recommend going through their documentation<\/a>.<\/a><\/strong><\/p>\n Let’s say you\u2019d rather not use a plugin to add your WooComerce Mini cart to maintain a light framework of your website. Then, you can also choose to create one programmatically instead.<\/p>\n This will require you to create a custom shortcode<\/strong> using a custom function and paste it to your theme\u2019s functions.php<\/strong> file. Then, you can use the shortcode on any part of your website or even add it to any of your WordPress or WooCommerce template<\/a> files to directly add the WooCommerce mini cart.<\/p>\n Since we will be changing some of the core files, it’s best that you backup your website<\/a> and also create a child theme<\/a> programmatically or by using one of the child theme plugins<\/a>. This ensures that you won’t lose your custom codes when you update the WordPress theme<\/a>.<\/p>\n We’ll add the custom codes in the theme files of your website from the theme file editor. If you are not fully comfortable about adding codes to WooCommmerce, we recommend going through this article<\/a> first.<\/p>\n Once you\u2019re ready, open your Theme editor from Appearance > Theme File Editor<\/strong> on your WP Admin Dashboard<\/strong>. Use the theme files sidebar on the right and click on functions.php<\/strong>. This will open the functions.php file on your Theme editor.<\/p>\n <\/p>\n Now, paste the following code in your theme editor:<\/p>\n <\/p>\n After you add the code, click on Update<\/strong> File<\/strong>. This will create a custom shortcode titled \u2018[quadlayers-mini-cart]\u2019<\/strong> for your website. Now, you can use this shortcode on any post, page, or widget to add your custom WooCommerce Mini Cart.<\/p>\n You can also use the following code snippet to add your custom mini cart to any theme template file or WooCommerce templates.<\/p>\n For example, let’s add this code to your WooCommerce product archive template file. To open your WooCommerce template file, go to Plugins > Plugin File Editor\u00a0<\/strong>from your WordPress dashboard.<\/p>\n <\/p>\n Then, use the Select Plugin to Edit<\/strong> option on the top right and choose WooCommerce<\/strong> and click on Select.<\/strong> Using the Plugin Files menu, click on templates <\/strong>> archive-product.php.<\/strong><\/p>\n <\/p>\n Next, add the following line of code to any appropriate part of the template.<\/p>\n For our demo, we\u2019ll be adding the line of code under the <\/p>\n Finally, update the file<\/strong> after you have added the codes in the plugin editor. The mini-cart will show up on your designated WooCommerce pages<\/a>. In our case, it’s the Shop\/Product Archive page.<\/p>\n <\/p>\n This approach will add your mini cart to the template. However, the mini cart may not look exactly the way you want<\/strong> and might require additional styling using your theme\u2019s file stylesheet. So, this method is recommended only if you\u2019re used to coding and have a fair bit of knowledge to add PHP and CSS to WordPress<\/a>.<\/p>\n If you want your customers to have a quicker checkout process, you can also choose to skip the cart page<\/strong> entirely. As the mini cart is already provided to your customers, there’s not much need for the cart page. So, you can redirect your customers straight to the checkout page<\/a> when they want to make a purchase.<\/p>\n You can do so by either using a dedicated plugin or by using a custom function.\u00a0For now, we\u2019ll be covering how you can skip the cart page programmatically.<\/p>\n But before you proceed, you need to go to WooCommerce > Settings<\/strong> from your WP dashboard and open the Products<\/strong> tab. Under the General<\/strong> options, disable both Add to Cart Behavior options<\/strong>. This ensures that there\u2019s no interference with our custom function.<\/p>\n <\/p>\n Now, open your Child Theme\u2019s functions.php file once again using the same step as above. Simply go to the theme editor from Appearance > Theme File Editor<\/strong> and click on the functions.php\u00a0<\/strong>file.<\/p>\n Then, paste the following code snippet here.<\/p>\n <\/p>\n Now, every time your customers add a product to your cart, they\u2019ll be directly taken to the checkout page instead of their cart page<\/a>.<\/p>\n <\/p>\n To simplify this process, you can also use a plugin like Direct Checkout for WooCommerce<\/a>. If you want to learn about it and why you should consider using it, you can check out our dedicated guide here.<\/a><\/p>\n And that ends our guide on how to create a WooCommerce mini cart.<\/strong> Setting up and customizing WooCommerce Mini Cart isn\u2019t a tedious process and you can choose to use different methods to do so. Let\u2019s summarize the methods we\u2019ve used in today\u2019s guide to add and customize our WooCommerce Mini Cart:<\/p>\n If you\u2019re not sure which process to use, we highly recommend using a plugin<\/strong> to create your WooCommerce mini cart. Not only is this method safer and easier, but you also get tons of dedicated customization and personalization option for your mini cart. If you\u2019re a WordPress beginner and want to add a WooCommerce mini-cart with minimal limitations, we highly recommend you use a dedicated plugin.<\/p>\n Furthermore, if you\u2019re looking for additional means to shorten your checkout process and improve your sales why don\u2019t you go through some of our other articles:<\/p>\n So can you add a mini cart to your website now? Or have you already added it? We will be glad to know about it in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":" Are you looking for an easy way to set yp a WooCommerce mini cart? If your checkout experience is sluggish […]<\/p>\n","protected":false},"author":5092,"featured_media":202794,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2218],"tags":[12760,1262],"coauthors":[2129,8588],"yoast_head":"\nWhat is a WooCommerce mini cart?<\/h2>\n
\n
Why create a Mini Cart for your WooCommerce website?<\/h2>\n
How to create a WooCommerce Mini Cart in WordPress<\/h2>\n
\n
1. Create a WooCommerce Mini Cart using WordPress Widgets<\/h3>\n
\n
1.1. Select the Widget Area<\/h4>\n
1.2. Add Cart Widget to the Widget Area<\/h4>\n
2. Create a WooCommerce Mini Cart using a WordPress Plugin<\/h3>\n
\n
2.1. Install and Activate the Plugin<\/h4>\n
2.2. Configure the Cart All in One For WooCommerce Plugin<\/h4>\n
2.3. Customize your WooCommerce Mini Cart using the plugin<\/h4>\n
3) Create a WooCommerce Mini Cart Programmatically<\/h3>\n
3.1. Add the Custom Shortcode to your Theme Functions<\/h4>\n
function custom_mini_cart() {\r\necho '<a href=\"#\" class=\"dropdown-back\" data-toggle=\"dropdown\"> ';\r\necho '<i class=\"fa fa-shopping-cart\" aria-hidden=\"true\"><\/i>';\r\necho '<div class=\"basket-item-count\" style=\"display: inline;\">';\r\necho '<span class=\"cart-items-count count\">';\r\necho WC()->cart->get_cart_contents_count();\r\necho '<\/span>';\r\necho '<\/div>';\r\necho '<\/a>';\r\necho '<ul class=\"dropdown-menu dropdown-menu-mini-cart\">';\r\necho '<li> <div class=\"widget_shopping_cart_content\">';\r\nwoocommerce_mini_cart();\r\necho '<\/div><\/li><\/ul>';\r\n\r\n}\r\nadd_shortcode( 'quadlayers-mini-cart', 'custom_mini_cart' );<\/pre>\n
3.2. Use the Shortcode in a WooCommerce Template<\/h4>\n
<?php echo do_shortcode('[quadlayers-mini-cart]'); ?><\/pre>\n
echo do_shortcode('[quadlayers-mini-cart]');<\/pre>\n
do_action( 'woocommerce_before_main_content' )<\/strong>;<\/code> line. But you can add the snippet on any of the template files and wherever necessary.<\/p>\n
Bonus: How to skip cart page in WooCommerce<\/h3>\n
add_filter('add_to_cart_redirect', 'ql_skip_cart_page');\r\nfunction ql_skip_cart_page () {\r\nglobal $woocommerce;\r\n$redirect_checkout = $woocommerce->cart->get_checkout_url();\r\nreturn $redirect_checkout;\r\n}<\/pre>\n
Conclusion<\/h2>\n
\n
\n