The code in this download creates a shortcode you can use to display a mini cart in any widget area, hook or file. The mini cart :
- Updates automatically when the quantity is changed.
- By default displays the product thumbnail, product name, quantity and subtotal.
- Includes buttons for the cart and checkout pages.
Basically, the code creates a custom cart widget for WooCommerce for users not using the cart block.
Demo Video
Shows products added to the cart displaying using the [[custom_cart]] shortcode in the primary sidebar with the quantity and sub total automatically updated when increased or decreased.
Installation
There’s 3 steps :
- Upload the files named new-cart-totals.php and custom-cart.php to your child theme folder.
- Copy and paste the PHP code ( without the opening PHP tag ) to the end of your child themes functions file.
- Copy and past the CSS to the end of your child themes style sheet and clear caching.
Usage
There’s 3 options :
- You can use the shortcode in any widget area
- Hook the shortcode in using any action hook
- Add the shortcode to any template
Example for template usage :
echo do_shortcode('[custom_cart]');
Example for action hook usage in functions file :
add_action('your_action_hook', 'hook_block' ); function hook_block() { echo do_shortcode('[custom_cart]'); }
Reviews
There are no reviews yet.