differentiate hooks and filters on the same page


I’ve simplified my woocommerce by putting my cart and checkout all in one page. The annoying part of this is how to differentiate hooks and filters. Every example I see uses a page check like:

if ( !function_exists( 'turn_shipping_off_on_cart_view_only' ) ){
    function turn_shipping_off_on_cart_view_only(){
        if ( is_cart() ){
            return false;
        return true;
add_filter('woocommerce_cart_needs_shipping', 'turn_shipping_off_on_cart_view_only');

The problem is with the cart and the checkout on the same page the above always evaluates false and turns off the shipping prompt.


Though the subject of this is woocommerce, I feel it is on topic, as the general behavior of hooks and page checks are the same no matter what plugin is being used.

Jamie Marshall 2 years 2020-12-21T19:10:39-05:00 0 Answers 3 views 0

Leave an answer