تابع ووکامرسی wc_register_order_type ثبت نوع سفارش جدید

تابع ووکامرسی wc_register_order_type – ثبت نوع سفارش جدید برای فروشگاه
Syntax – سینتکس
wc_register_order_type( (string) $type, (array) $args = array() );
Parameters – پارامتر ها (2)
- 1- $type (string)
- 2- $args (array)
Usage – نحوه استفاده
if ( !function_exists( 'wc_register_order_type' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-order-functions.php';
}
// Post type. (max. 20 characters, can not contain capital letters or spaces)
$type = '';
// An array of arguments.
$args = array();
// NOTICE! Understand what this does before running.
$result = wc_register_order_type($type, $args);
Defined – محل تعریف
/includes/wc-order-functions.php
function wc_register_order_type( $type, $args = array() ) {
if ( post_type_exists( $type ) ) {
return false;
}
global $wc_order_types;
if ( ! is_array( $wc_order_types ) ) {
$wc_order_types = array();
}
// Register as a post type
if ( is_wp_error( register_post_type( $type, $args ) ) ) {
return false;
}
// Register for WC usage
$order_type_args = array(
'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,
'class_name' => 'WC_Order',
);
$args = array_intersect_key( $args, $order_type_args );
$args = wp_parse_args( $args, $order_type_args );
$wc_order_types[ $type ] = $args;
return true;
}
versions – نسخه ها
از نسخه : 2.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر