结账后根据用户的送货状态添加挂钩

时间:2015-03-12 20:48:40

标签: wordpress woocommerce hook checkout

我正在寻求有关如何在用户结账后将WooCommerce挂钩与我的订单状态结合使用的建议。我创建了自定义订单状态,并希望订单根据用户在结帐时输入的运送状态自动转到该状态。

例如:用户来自PA - >订单状态自动设置为“东海岸”

以下代码是我用于创建新订单状态的代码

/** 
 * Register East Coast status
**/
function register_processing_newtown_square_status() {
register_post_status( 'wc-processing-ec', array(
    'label'                     => 'Processing East Coast',
    'public'                    => true,
    'exclude_from_search'       => false,
    'show_in_admin_all_list'    => true,
    'show_in_admin_status_list' => true,
    'label_count'               => _n_noop( 'Processing East Coast <span class="count">(%s)</span>', 'Processing East Coast <span class="count">(%s)</span>' )
    ) );
}
add_action( 'init', 'register_processing_east_coast_status' );

// Add to list of WC Order statuses
function add_register_processing_east_coast_status( $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-processing' === $key ) {
        $new_order_statuses['wc-processing-ec'] = 'Processing East Coast';
    }
}

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

任何人都可以告诉我有关使用WooCommerce钩子获取购物车中用户状态信息并在结账时将其与此订单状态相关联的任何信息吗?

http://docs.woothemes.com/document/hooks/

0 个答案:

没有答案