【问题标题】:woocommerce hooks warning "function not found"woocommerce 挂钩警告“未找到功能”
【发布时间】:2017-03-24 12:43:59
【问题描述】:

我想在我的 woocommerce 单品页面中使用挂钩来进行一些更改。

所以我在我的 child-theme 的 function.php 中添加了以下代码:

add_action( 'woocommerce_single_product_summary',' woocommerce_template_single_add_to_cart', 35 );

现在我的产品页面上应该有第二个添加到购物车按钮。 但我得到的只是以下警告:

警告:call_user_func_array() 期望参数 1 为有效回调,未找到函数 'woocommerce_template_single_add_to_cart' 或 /home/userXXX/htdocs/vintagehome/wp-includes/class-wp-hook.php 中的函数名称无效298

你们是我完成这件事的最后机会! 请帮帮我..

问候 亚历克斯

【问题讨论】:

    标签: php wordpress woocommerce warnings hook


    【解决方案1】:
    // define the woocommerce_single_product_summary callback 
    function action_woocommerce_single_product_summary( $woocommerce_template_single_title, $int ) { 
        // make action magic happen here... 
    }; 
    
    // add the action 
    add_action( 'woocommerce_single_product_summary', 'action_woocommerce_single_product_summary', 10, 2 ); 
    

    【讨论】:

    • 这行得通!非常感谢!还有一个问题:如何在函数中添加第二个添加到购物车按钮?这个有特殊的代码sn-p吗?
    • @Alex:请将我的答案标记为正确 (✓) 以及第二个添加到购物车按钮的用途是什么?
    • 第二个添加到卡片按钮只是一个例子——我自己想出来的,谢谢你的帮助:)
    猜你喜欢
    • 2023-03-16
    • 1970-01-01
    • 2021-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-31
    • 2021-04-28
    • 2015-01-06
    相关资源
    最近更新 更多