Friday, October 23, 2020

Woocommerce: Cart Summary - which "Return to Shop" to use?

Shows nothing....

 // Hide "Return to Shop" button when all items are removed @ Cart Page

remove_action( 'woocommerce_cart_is_empty', 'wc_empty_cart_message', 10); //remove the default message

add_action( 'woocommerce_cart_is_empty', 'custom_empty_cart_message', 10); //add custom designed

function custom_empty_cart_message() {

echo "Oops your cart is lonely...";

add_action( 'woocommerce_return_to_shop', 'return_to_shop', 10); //remove return to shop button

//$_SERVER['cart'];

}



Shows both messages with custom messaging....


// Hide "Return to Shop" button when all items are removed @ Cart Page

remove_action( 'woocommerce_cart_is_empty', 'wc_empty_cart_message', 10 );

add_action( 'woocommerce_cart_is_empty', 'custom_empty_cart_message', 10 );


function custom_empty_cart_message() {

    //$html  = '<div class="col-12 offset-md-1 col-md-10"><p class="cart-empty">';

    $html .= wp_kses_post( apply_filters( 'wc_empty_cart_message', __( 'Your cart is currently empty.', 'woocommerce' ) ) );

    echo $html . '</p></div>';

}

No comments: