Handle order number and product ui fields

This commit is contained in:
Almira Krdzic
2018-10-24 12:13:07 +02:00
parent e1589ee561
commit e41b643fc5
7 changed files with 77 additions and 17 deletions

View File

@@ -7,7 +7,7 @@ class Wiaas_Admin_Product {
add_action('acf/save_post', array(__CLASS__, 'save_initial_product_country_and_type'), 20, 1); add_action('acf/save_post', array(__CLASS__, 'save_initial_product_country_and_type'), 20, 1);
add_action('woocommerce_after_register_post_type', array(__CLASS__, 'wiaas_register_product_status')); add_action('woocommerce_after_register_post_type', array(__CLASS__, 'wiaas_register_product_status'));
add_filter('woocommerce_register_post_type_product', array(__CLASS__, 'wiaas_modify_product')); add_filter('woocommerce_register_post_type_product', array(__CLASS__, 'wiaas_modify_product'));
add_action('add_meta_boxes', array(__CLASS__, 'wiaas_maybe_remove_metaboxes'), 999); add_action('add_meta_boxes', array(__CLASS__, 'maybe_remove_metaboxes'), 999);
add_filter('wp_insert_post_data', array(__CLASS__, 'wiaas_maybe_set_no_country_status'), 999, 2); add_filter('wp_insert_post_data', array(__CLASS__, 'wiaas_maybe_set_no_country_status'), 999, 2);
add_action('acf/render_field/type=group', array(__CLASS__, 'render_choose_button_for_new_product'), 10, 1); add_action('acf/render_field/type=group', array(__CLASS__, 'render_choose_button_for_new_product'), 10, 1);
@@ -42,7 +42,7 @@ class Wiaas_Admin_Product {
} }
public static function wiaas_maybe_remove_metaboxes() { public static function maybe_remove_metaboxes() {
$screen = get_current_screen(); $screen = get_current_screen();
$screen_id = $screen ? $screen->id : ''; $screen_id = $screen ? $screen->id : '';
@@ -56,15 +56,11 @@ class Wiaas_Admin_Product {
if ($post_id === 0 || $post->post_status === '_wiaas_no_country') { if ($post_id === 0 || $post->post_status === '_wiaas_no_country') {
remove_meta_box('woocommerce-product-data', 'product', 'normal'); remove_meta_box('woocommerce-product-data', 'product', 'normal');
remove_meta_box('submitdiv', 'product', 'side');
remove_meta_box('slugdiv', 'product', 'normal'); remove_meta_box('slugdiv', 'product', 'normal');
remove_meta_box('wiaas_upload_and_link_document', 'product', 'normal');
remove_meta_box('postexcerpt', 'product', 'normal'); remove_meta_box('postexcerpt', 'product', 'normal');
remove_meta_box('template_product_meta_box', 'product', 'normal'); remove_meta_box('template_product_meta_box', 'product', 'normal');
remove_meta_box('postimagediv', 'product', 'normal');
remove_meta_box('woocommerce-product-images', 'product', 'normal');
remove_meta_box('wc-jetpack-product_by_user_role', 'product', 'normal');
remove_meta_box('submitdiv', 'product', 'side');
remove_meta_box('groups-permissions', 'product', 'side'); remove_meta_box('groups-permissions', 'product', 'side');
remove_meta_box('tagsdiv-product_tag', 'product', 'side'); remove_meta_box('tagsdiv-product_tag', 'product', 'side');
@@ -72,15 +68,16 @@ class Wiaas_Admin_Product {
remove_meta_box('tagsdiv-supplier', 'product', 'side'); remove_meta_box('tagsdiv-supplier', 'product', 'side');
remove_meta_box('postimagediv', 'product', 'side'); remove_meta_box('postimagediv', 'product', 'side');
remove_meta_box('woocommerce-product-images', 'product', 'side'); remove_meta_box('woocommerce-product-images', 'product', 'side');
remove_meta_box('submitdiv', 'product', 'side');
remove_meta_box('wiaas_upload_and_link_document', 'product', 'side'); remove_meta_box('wiaas_upload_and_link_document', 'product', 'side');
remove_meta_box('radio-tagsdiv-product_country', 'product', 'side'); remove_meta_box('tagsdiv-product_country', 'product', 'side');
remove_meta_box('tagsdiv-_wiaas_shop_prices', 'product', 'side');
remove_meta_box('tagsdiv-wiaas_units', 'product', 'side'); remove_meta_box('tagsdiv-wiaas_units', 'product', 'side');
} }
//Always hide product category, it is added wit advanced custom fields plugin for simple product //Always hide product category, it is added wit advanced custom fields plugin for simple product
remove_meta_box('radio-product_catdiv', 'product', 'side'); remove_meta_box('product_catdiv', 'product', 'side');
// Always hide
remove_meta_box('tagsdiv-product_country', 'product', 'side');
} }

View File

@@ -23,7 +23,7 @@ class Wiaas_DB_Update {
'20181018064450' => 'wiaas_db_update_add_organization_info_ui_fields', '20181018064450' => 'wiaas_db_update_add_organization_info_ui_fields',
'20191019014550' => 'wiaas_db_update_add_general_ui_fields', '20191019014550' => 'wiaas_db_update_add_general_ui_fields',
'20191019014650' => 'wiaas_db_update_add_product_properties_ui_fields', '20191019014650' => 'wiaas_db_update_add_product_properties_ui_fields',
'20181019064450' => 'wiaas_db_update_add_reference_ui_field', '20181019064450' => 'wiaas_db_update_add_bundle_properties_ui_field',
'20191020014650' => 'wiaas_create_organization_roles_capabilities' '20191020014650' => 'wiaas_create_organization_roles_capabilities'
); );

View File

@@ -28,6 +28,20 @@ class Wiaas_Order {
add_filter('woocommerce_rest_orders_prepare_object_query', array( __CLASS__, 'wiaas_prepare_rest_orders_query'), 10, 2); add_filter('woocommerce_rest_orders_prepare_object_query', array( __CLASS__, 'wiaas_prepare_rest_orders_query'), 10, 2);
add_filter('woocommerce_new_order_note_data', array( __CLASS__, 'update_new_order_comment_date'), 10, 3); add_filter('woocommerce_new_order_note_data', array( __CLASS__, 'update_new_order_comment_date'), 10, 3);
add_filter('woocommerce_order_number', array( __CLASS__, 'format_order_number'));
}
/**
* Prefix order number
*
* @param int $number
*
* @return string
*/
public static function format_order_number($number) {
return "1000000$number";
} }
/** /**

View File

@@ -1,7 +1,7 @@
[ [
{ {
"key": "group_5bc845c001de4", "key": "group_5bc845c001de4",
"title": "Package Reference", "title": "Bundle Properties",
"fields": [ "fields": [
{ {
"key": "field_5bc845dc7eed5", "key": "field_5bc845dc7eed5",
@@ -24,6 +24,28 @@
"load_terms": 1, "load_terms": 1,
"return_format": "id", "return_format": "id",
"multiple": 0 "multiple": 0
},
{
"key": "field_5bcfcc2cf88f4",
"label": "Country",
"name": "country",
"type": "taxonomy",
"instructions": "",
"required": 1,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"taxonomy": "product_country",
"field_type": "select",
"allow_null": 0,
"add_term": 0,
"save_terms": 1,
"load_terms": 1,
"return_format": "id",
"multiple": 0
} }
], ],
"location": [ "location": [

View File

@@ -49,7 +49,7 @@
}, },
{ {
"key": "field_5bc867c3aeafd", "key": "field_5bc867c3aeafd",
"label": "Product category", "label": "Category",
"name": "category", "name": "category",
"type": "taxonomy", "type": "taxonomy",
"instructions": "", "instructions": "",
@@ -90,10 +90,37 @@
"load_terms": 1, "load_terms": 1,
"return_format": "id", "return_format": "id",
"multiple": 0 "multiple": 0
},
{
"key": "field_5bcfcceffe617",
"label": "Country",
"name": "country",
"type": "taxonomy",
"instructions": "",
"required": 1,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"taxonomy": "product_country",
"field_type": "select",
"allow_null": 0,
"add_term": 0,
"save_terms": 1,
"load_terms": 1,
"return_format": "id",
"multiple": 0
} }
], ],
"location": [ "location": [
[ [
{
"param": "post_type",
"operator": "==",
"value": "product"
},
{ {
"param": "post_taxonomy", "param": "post_taxonomy",
"operator": "==", "operator": "==",

View File

@@ -18,9 +18,9 @@ function wiaas_db_update_add_user_organization_ui_fields() {
_wiaas_import_field_group($ui_json); _wiaas_import_field_group($ui_json);
} }
function wiaas_db_update_add_reference_ui_field() { function wiaas_db_update_add_bundle_properties_ui_field() {
$ui_json = file_get_contents( dirname( __FILE__ ) . '/data/wiaas-ui-field-reference.json' ); $ui_json = file_get_contents( dirname( __FILE__ ) . '/data/wiaas-ui-field-bundle-properties.json' );
$ui_json = json_decode( $ui_json, true ); $ui_json = json_decode( $ui_json, true );

File diff suppressed because one or more lines are too long