{"id":6492,"date":"2021-11-19T19:11:36","date_gmt":"2021-11-19T19:11:36","guid":{"rendered":"https:\/\/musilda.cz\/?p=6492"},"modified":"2021-11-19T19:11:36","modified_gmt":"2021-11-19T19:11:36","slug":"pridani-vlastniho-tabu-v-datech-produktu","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/pridani-vlastniho-tabu-v-datech-produktu\/","title":{"rendered":"P\u0159id\u00e1n\u00ed vlastn\u00edho tabu v datech produktu"},"content":{"rendered":"\n

V minul\u00e9m \u010dl\u00e1nku jsme si upravili zobrazen\u00ed metaboxu data produktu, tak aby nebyly vid\u011bt nepot\u0159ebn\u00e9 taby. Dnes si uk\u00e1\u017eeme, jak si p\u0159idat vlastn\u00ed tab, viditeln\u00fd jen pro n\u00e1\u0161 typ produktu.<\/p>\n\n\n\n

Vytvo\u0159ili jsme funkci musilda_event_product_data_tabs, do kter\u00e9 p\u0159id\u00e1me definici dal\u0161\u00edho tabu:<\/p>\n\n\n\n

add_filter( 'woocommerce_product_data_tabs', 'musilda_event_product_data_tabs', 10, 1 );\nfunction musilda_event_product_data_tabs( $option ) {\n\n\tglobal $post;\n\t$product = wc_get_product( $post->ID );\n\n\tif ( 'event' == $product->get_type() ) {\n\n\t\t$option['general']['class'][] \t\t\t= 'show_if_event';\n\t\t$option['general']['class'][] \t\t\t= 'active';\n\t\t$option['inventory']['class'][] \t\t= 'hide_if_event';\n\t\t$option['shipping']['class'][] \t\t\t= 'hide_if_event';\n\t\t$option['linked_product']['class'][] \t= 'hide_if_event';\n\t\t$option['attribute']['class'][] \t\t= 'hide_if_event';\n\t\t$option['advanced']['class'][] \t\t\t= 'hide_if_event';\n\n\t\t$option['event'] = array(\n\t\t\t'label'    => __( 'Event', 'musilda-eventpress' ),\n\t\t\t'target'   => 'musilda_eventpress_product_option',\n\t\t\t'class'    => array( 'show_if_event' ),\n\t\t\t'priority' => 60,\n\t\t);\n\n\t}\n\n\treturn $option;\n\n}<\/code><\/pre>\n\n\n\n

Do pole option p\u0159id\u00e1me polo\u017eku s key event. D\u016fle\u017eit\u00e1 je hodnota target, kter\u00e1 ozna\u010duje id divu, kter\u00fd se bude zobrazovat po kliknut\u00ed na tab. <\/p>\n\n\n\n

Do akce woocommerce_product_data_panels, kter\u00e1 se vol\u00e1 po zobrazen\u00ed v\u0161ech tab\u016f, p\u0159id\u00e1me vlastn\u00ed funkci:<\/p>\n\n\n\n

add_action( 'woocommerce_product_data_panels', 'musilda_eventpress_product_option' );\nfunction musilda_eventpress_product_option() {\n\n\techo '<div id=\"musilda_eventpress_product_option\" class=\"panel woocommerce_options_panel\">';\n\t\techo __( 'Event data', 'musilda-eventpress' );\n\techo '<\/div>';\n\n}<\/code><\/pre>\n\n\n\n

V\u0161e co v t\u00e9to funkci vyp\u00ed\u0161eme, se zobraz\u00ed v na\u0161em tabu<\/p>\n\n\n\n

\"\"<\/a><\/figure>\n\n\n\n

To je dnes v\u0161e, k\u00f3d najdete na Githubu https:\/\/github.com\/Musilda\/musilda-eventpress<\/a> a p\u0159\u00ed\u0161t\u011b si z\u00e1lo\u017eku vypln\u00edme formul\u00e1\u0159ov\u00fdmi poli pro dopl\u0148uj\u00edc\u00ed informace k eventu.<\/p>\n","protected":false},"excerpt":{"rendered":"

V minul\u00e9m \u010dl\u00e1nku jsme si upravili zobrazen\u00ed metaboxu data produktu, tak aby nebyly vid\u011bt nepot\u0159ebn\u00e9 taby. Dnes si uk\u00e1\u017eeme, jak si p\u0159idat vlastn\u00ed tab, viditeln\u00fd jen pro n\u00e1\u0161 typ produktu. Vytvo\u0159ili jsme funkci musilda_event_product_data_tabs, do kter\u00e9 p\u0159id\u00e1me definici dal\u0161\u00edho tabu: Do pole option p\u0159id\u00e1me polo\u017eku s key event. D\u016fle\u017eit\u00e1 je hodnota target, kter\u00e1 ozna\u010duje id<\/p>\n","protected":false},"author":1,"featured_media":5600,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[29],"tags":[],"class_list":["post-6492","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-woocommerce-snippety"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/6492"}],"collection":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/comments?post=6492"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/6492\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/5600"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=6492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=6492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=6492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}