created order_type taxonomy
This commit is contained in:
commit
7e36d05c75
|
@ -91,6 +91,9 @@ class WC_Meta_Box_Order_Actions {
|
|||
// Order data saved, now get it so we can manipulate status
|
||||
$order = get_order( $post_id );
|
||||
|
||||
// Order type
|
||||
wp_set_object_terms( $post_id, 'simple', 'order_type' );
|
||||
|
||||
// Handle button actions
|
||||
if ( ! empty( $_POST['wc_order_action'] ) ) {
|
||||
|
||||
|
@ -138,4 +141,4 @@ class WC_Meta_Box_Order_Actions {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,6 +256,9 @@ class WC_Install {
|
|||
'grouped',
|
||||
'variable',
|
||||
'external'
|
||||
),
|
||||
'order_type' => array(
|
||||
'simple'
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -30,16 +30,25 @@ class WC_Order_Factory {
|
|||
$the_order = get_post( $the_order );
|
||||
}
|
||||
|
||||
if ( ! is_object( $the_order ) ) {
|
||||
if ( ! $the_order || ! is_object( $the_order ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$order_id = absint( $the_order->ID );
|
||||
$post_type = $the_order->post_type;
|
||||
|
||||
if ( 'shop_order' === $post_type ) {
|
||||
$classname = 'WC_Order';
|
||||
$order_type = 'simple';
|
||||
if ( 'shop_order' == $post_type ) {
|
||||
$terms = get_the_terms( $order_id, 'order_type' );
|
||||
$order_type = ! empty( $terms ) && isset( current( $terms )->name ) ? sanitize_title( current( $terms )->name ) : 'simple';
|
||||
|
||||
// Create a WC coding standards compliant class name e.g. WC_Order_Type_Class instead of WC_order_type-class
|
||||
$classname = 'WC_Order_' . implode( '_', array_map( 'ucfirst', explode( '-', $order_type ) ) );
|
||||
|
||||
// The default order class must be WC_Order to provide backwards compatibility
|
||||
if ( 'WC_Order_Simple' ) {
|
||||
$classname = 'WC_Order';
|
||||
}
|
||||
|
||||
} else {
|
||||
$classname = false;
|
||||
$order_type = false;
|
||||
|
@ -54,4 +63,4 @@ class WC_Order_Factory {
|
|||
|
||||
return new $classname( $the_order, $args );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,18 @@ class WC_Post_types {
|
|||
|
||||
$permalinks = get_option( 'woocommerce_permalinks' );
|
||||
|
||||
register_taxonomy( 'order_type',
|
||||
apply_filters( 'woocommerce_taxonomy_objects_order_type', array( 'shop_order' ) ),
|
||||
apply_filters( 'woocommerce_taxonomy_args_order_type', array(
|
||||
'hierarchical' => false,
|
||||
'show_ui' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'query_var' => is_admin(),
|
||||
'rewrite' => false,
|
||||
'public' => false
|
||||
) )
|
||||
);
|
||||
|
||||
register_taxonomy( 'product_type',
|
||||
apply_filters( 'woocommerce_taxonomy_objects_product_type', array( 'product' ) ),
|
||||
apply_filters( 'woocommerce_taxonomy_args_product_type', array(
|
||||
|
|
|
@ -108,6 +108,9 @@ function wc_create_order( $args = array() ) {
|
|||
update_post_meta( $order_id, '_customer_user', $args['customer_id'] );
|
||||
}
|
||||
|
||||
// Set the order type.
|
||||
wp_set_object_terms( $order_id, 'simple', 'order_type' );
|
||||
|
||||
return new WC_Order( $order_id );
|
||||
}
|
||||
|
||||
|
|
|
@ -383,6 +383,18 @@ function wc_ship_to_billing_address_only() {
|
|||
return 'billing_only' === get_option( 'woocommerce_ship_to_destination' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register order type
|
||||
*
|
||||
* @since 2.2
|
||||
* @return void
|
||||
*/
|
||||
function register_order_type( $type ) {
|
||||
if ( ! get_term_by( 'slug', sanitize_title( $type ), 'order_type' ) ) {
|
||||
wp_insert_term( $type, 'order_type' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new order refund programmatically
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue