最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

woocommerce offtopic - differentiate hooks and filters on the same page

programmeradmin0浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 4 years ago.

Improve this question

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.

edit

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.

发布评论

评论列表(0)

  1. 暂无评论