在自定义状态

时间:2015-12-09 12:34:49

标签: php email woocommerce status orders

我已将自定义订单状态待批准创建为默认订单状态,表示如果客户从商店订购商品,则会将其置于待批准下,而不是< strong>处理,这是我创建自定义状态的代码:

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的未知状态,我没有为Custom Status更改除此之外的任何内容,请在这方面帮助我..

谢谢:)

1 个答案:

答案 0 :(得分:0)

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

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

    <table class="table table-bordered table-hover table-striped">
                    <thead>
                        <tr>
                            <th width="5%">#</th>
                            <th width="10%">Firstname</th>
                            <th width="10%">Technical Skills</th>
                            <th width="10%">Edit</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr data-ng-repeat="user in post.users | orderBy : '-id'">
                            <th scope="row">{{user.id}}</th>
                            <td> {{user.firstname}} </td>
                            <td> {{user.technology}} </td>
                            <td> <span data-ng-click="editUser(user)"> Edit</span></td>
                        </tr>
                    </tbody>
                </table>

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

<强> TIA

相关问题