hideMiniCart( )


Deprecated. This function will continue to work, but will soon be deprecated. Hiding the Mini Cart or Side Cart can be done by clicking anywhere else on the page.

Hides the Mini Cart.

The hideMiniCart() function hides the Mini Cart. Learn more about the Mini Cart.

Note: This API will fail when viewing the site on mobile because there is no Mini Cart on the mobile site.

Method Declaration
Copy
function hideMiniCart(): void;
Request
This method does not take any parameters
Show and hide the Mini Cart

This example uses a deprecated function. Add products to the cart, then show the Mini Cart. After 3 seconds, hide the Mini Cart.

JavaScript
import { cart } from "wix-stores-frontend"; import { formFactor } from "wix-window-frontend"; const products = [ { productId: "0873ed58-f88d-77d1-4566-afd4c50d253e", quantity: 2, }, ]; cart .addProducts(products) .then(() => { // Only show the Mini Cart if the site is not being viewed on mobile if (formFactor !== "Mobile") { cart.showMiniCart(); // After displaying the Mini Cart for 3 seconds, hide the Mini Cart setTimeout(() => cart.hideMiniCart(), 3000); } }) .catch((error) => { console.error(error); });
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?