Wednesday, 18 April 2018

Add Empty Cart button on the Woo-commerce cart page WordPress

//First add this code in your functions.php file
add_action( ‘init’, ‘woocommerce_empty_cart’ );
function woocommerce_empty_cart() {
    global $woocommerce;
    if ( isset( $_GET[’empty-cart’] ) ) {
        $woocommerce->cart->empty_cart();
    }
}

//Empty cart button
<a class=”button” href=”<?php echo $woocommerce->cart->get_cart_url(); ?>?empty-cart”><?php _e( ‘Empty Cart’, ‘woocommerce’ ); ?></a>

-------------------------------------------------
Let me know your thoughts and questions in the comments.
Email: vyasankit2008@gmail.com 

No comments:

Post a Comment