【问题标题】:Add custom functionality on WooCommerce complete button在 WooCommerce 完成按钮上添加自定义功能
【发布时间】:2015-08-18 21:24:29
【问题描述】:

我有一种情况要在订单状态完成按钮上向数据库表中添加一些数据。

我可以在 class-wc-admin-post-types.php 中看到 url

有人可以帮我解决任何问题吗?或者 admin-ajax.php 是如何工作的?我必须将状态添加到我的一些自定义数据库表中。

【问题讨论】:

    标签: php ajax wordpress woocommerce


    【解决方案1】:

    此代码将触发客户的订单设置为已完成..

    add_action( 'woocommerce_order_status_completed', 'custom_task' );
    function custom_task( $order_id ) {
    
        // Only continue if have $order_id
        if ( ! $order_id ) {
            return;
        }
    
        // Get order
        $order = wc_get_order( $order_id );
    
        // Do your thing
    
    }
    

    【讨论】:

    • 我已经要求在管理仪表板中提供完整的按钮。
    • 对不起.. 比尝试 woocommerce_order_status_completed 而不是 woocommerce_thankyou
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-18
    • 2012-11-30
    • 2016-09-05
    • 1970-01-01
    • 2018-04-16
    • 2017-10-10
    • 1970-01-01
    相关资源
    最近更新 更多