【问题标题】:Add a button in order list public/user Woocommerce在订单列表公共/用户 Woocommerce 中添加一个按钮
【发布时间】:2021-10-04 12:58:01
【问题描述】:

我想在用户面板的订单列表中添加一个按钮。

你知道要使用的钩子吗?

谢谢

我想去的地方:

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    您需要使用woocommerce_my_account_my_orders_actions 来添加新操作。您可以根据需要使用条件。如果您需要构建动态网址,您也可以访问订单。

    add_filter( 'woocommerce_my_account_my_orders_actions', 'custom_order_button', 10, 2 );
    function custom_order_button($actions, $order) {
        // If you need order_id for dynamic stuff
        // $order_id = $order->ID;    
        $actions['my_button_action_name'] = array(
            'url' =>  "https://google.com",
            'name' => __( 'My button', 'woocommerce' )
        );
        return $actions;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-08
      • 2021-06-14
      • 2016-04-30
      • 2018-01-12
      • 1970-01-01
      • 2020-12-04
      • 2020-08-15
      • 2021-06-05
      相关资源
      最近更新 更多