Below is the code to Add 'Clear Cart ' functionality in woocommerce
1) Add this in Theme's functions.php file
1) Add this in Theme's functions.php file
add_action('init', 'woocommerce_clear_cart_url');
function woocommerce_clear_cart_url() {
global $woocommerce;
if( isset($_REQUEST['clear-cart']) ) {
$woocommerce-> cart->empty_cart();
}
}
2) Add Below code in plugins/woocommerce/templates/cart.php file<input class="button" name="clear-cart" type="submit" value="<?php _e('Empty Cart', 'woocommerce'); ?>" />
Note:(You can add this just before below existing code
<input class="button" name="update_cart" type="submit" value="<?php _e('Update Cart', 'woocommerce'); ?>" /></code>
No comments:
Post a Comment