Add an empty cart button to cart page
-
I want to add a clear cart button next to the update cart button on the cart page.
I added this code to the functions file:// check for clear-cart get param to clear the cart
add_action( ‘init’, ‘woocommerce_clear_cart_url’ );
function woocommerce_clear_cart_url() {
if ( isset( $_GET[‘clear-cart’] ) ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
}
}and I added this code to cart.php just before the update button:
<input type=”submit” class=”button” name=”clear-cart” value=”<?php _e(‘Empty Cart’, ‘woocommerce’); ?>” />
Nothing shows up. Obviously I have done something wrong. I know just enough PHP to be dangerous. If anyone could help I sure would appreciate it.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Add an empty cart button to cart page’ is closed to new replies.