【问题标题】:Send New Order email to Admin on custom Status在自定义状态下向管理员发送新订单电子邮件
【发布时间】:2016-03-14 17:37:58
【问题描述】:

我已将我的自定义订单状态 Pending Approval 创建为默认订单状态,这意味着如果客户从商店订购商品,它会将其置于 Pending Approval 而不是 处理中,这是我创建自定义状态的代码:

function register_my_order_status() {
    register_post_status( 'wc-pending-approval', array(
        'label'                     => 'Pending Approval',
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'exclude_from_orders_screen'       => false,
        'add_order_meta_boxes'             => true,
        'exclude_from_order_count'         => false,
        'exclude_from_order_views'         => false,
        'exclude_from_order_webhooks'      => false,
        'exclude_from_order_reports'       => false,
        'exclude_from_order_sales_reports' => false,
        'label_count'               => _n_noop( 'Pending Approval <span class="count">(%s)</span>', 'Pending Approval <span class="count">(%s)</span>' )
    ) );
}
add_action( 'init', 'register_my_order_status' );

// Add to list of WC Order statuses
function add_my_order_statuses( $order_statuses ) {

    $new_order_statuses = array();

    // add new order status after processing
    foreach ( $order_statuses as $key => $status ) {

        $new_order_statuses[ $key ] = $status;

        if ( 'wc-pending' === $key ) {
            $new_order_statuses['wc-pending-approval'] = 'Pending Approval';
        }
    }

    return $new_order_statuses;
}
add_filter( 'wc_order_statuses', 'add_my_order_statuses' );

为了使其成为默认状态,我编辑了这个文件:

wp-content/plugins/woocommerce/includes/gateways/cod/class-wc-gateway-cod.php

public function process_payment( $order_id ) {

        $order = wc_get_order( $order_id );

        // Mark as processing (payment won't be taken until delivery)
        //$order->update_status( 'processing', __( 'Payment to be made upon delivery.', 'woocommerce' ) );
        $order->update_status( 'pending-approval', __( 'Payment to be made upon delivery.', 'woocommerce' ) );
...

如您所见,我已将默认状态(处理中)注释为“待批准”..

现在的问题是它没有向管理员和客户发送新订单电子邮件,因为这是我的自定义状态并且它是 woocommerce 的未知状态,除了自定义状态之外我没有更改任何其他内容,请在这方面帮助我..

谢谢:)

【问题讨论】:

    标签: php email woocommerce status orders


    【解决方案1】:

    我知道这不是一个有效的解决方案,但我的问题已经解决了,我所做的是:

    我将默认订单状态设置为处理中,当我发送了所有需要的电子邮件后,我将订单状态更改为我的自定义状态待批准:P

    $order->update_status( 'processing', __( 'Payment to be made upon delivery.', 'woocommerce' ) );
    $order->update_status( 'pending-approval', __( 'Payment to be made upon delivery.', 'woocommerce' ) );
    

    我的学习目的仍然需要任何有效的解决方案..

    TIA

    【讨论】:

      猜你喜欢
      • 2017-06-14
      • 2020-10-02
      • 1970-01-01
      • 2018-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-13
      • 2012-12-17
      相关资源
      最近更新 更多