You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.6 KiB
101 lines
3.6 KiB
<?
|
|
|
|
|
|
// woocommerce_product_options_pricing - // после цен
|
|
|
|
|
|
/**
|
|
* Start: Добавление табов и полей в стандартной форме редактирования товара Woocommerce
|
|
*/
|
|
|
|
|
|
/* Вывод пользовательского поля */
|
|
add_action('woocommerce_product_data_panels', function () {
|
|
global $post;
|
|
$composition = get_post_meta($post->ID, '_composition', true);
|
|
echo '<div id="composition_product_data" class="panel woocommerce_options_panel">';
|
|
woocommerce_wp_textarea_input([
|
|
'id' => '_composition',
|
|
'label' => 'Состав',
|
|
'desc_tip' => true,
|
|
'description' => 'Введите состав товара',
|
|
'value' => $composition
|
|
]);
|
|
echo '</div>';
|
|
});
|
|
|
|
/* Вывод пользовательских табов */
|
|
// add_action('woocommerce_product_data_panels', function () {
|
|
// global $post;
|
|
// $feeding = get_post_meta($post->ID, '_feeding_recommendations', true);
|
|
// echo '<div id="feeding_product_data" class="panel woocommerce_options_panel">';
|
|
// woocommerce_wp_textarea_input([
|
|
// 'id' => '_feeding_recommendations',
|
|
// 'label' => 'Рекомендации по кормлению',
|
|
// 'desc_tip' => true,
|
|
// 'description' => 'Введите рекомендации по кормлению',
|
|
// 'value' => $feeding
|
|
// ]);
|
|
// echo '</div>';
|
|
// });
|
|
|
|
|
|
// add_action('woocommerce_product_data_panels', function () {
|
|
// global $post;
|
|
// $important = get_post_meta($post->ID, '_important', true);
|
|
// echo '<div id="important_product_data" class="panel woocommerce_options_panel">';
|
|
// woocommerce_wp_textarea_input([
|
|
// 'id' => '_important',
|
|
// 'label' => 'Важно',
|
|
// 'desc_tip' => true,
|
|
// 'description' => 'Введите важную информацию',
|
|
// 'value' => $important
|
|
// ]);
|
|
// echo '</div>';
|
|
// });
|
|
|
|
// woocommerce_product_options_inventory_product_data ]
|
|
|
|
add_filter('woocommerce_product_data_tabs', function ($tabs) {
|
|
$tabs['composition_tab'] = array(
|
|
'label' => 'Состав',
|
|
'target' => 'composition_product_data',
|
|
'class' => array('composition_tab'),
|
|
'priority' => 60,
|
|
);
|
|
// shipping_product_data
|
|
// shipping_options
|
|
// shipping_tab
|
|
|
|
|
|
// $tabs['feeding_tab'] = array(
|
|
// 'label' => 'Рекомендации по кормлению',
|
|
// 'target' => 'feeding_product_data',
|
|
// 'class' => array('feeding_tab'),
|
|
// 'priority' => 61,
|
|
// );
|
|
// $tabs['important_tab'] = array(
|
|
// 'label' => 'Важно',
|
|
// 'target' => 'important_product_data',
|
|
// 'class' => array('important_tab'),
|
|
// 'priority' => 62,
|
|
// );
|
|
return $tabs;
|
|
});
|
|
|
|
/* сохраненение кастомных полей */
|
|
add_action('woocommerce_process_product_meta', function ($post_id) {
|
|
if (isset($_POST['_composition'])) {
|
|
update_post_meta($post_id, '_composition', sanitize_textarea_field($_POST['_composition']));
|
|
}
|
|
// if (isset($_POST['_feeding_recommendations'])) {
|
|
// update_post_meta($post_id, '_feeding_recommendations', sanitize_textarea_field($_POST['_feeding_recommendations']));
|
|
// }
|
|
// if (isset($_POST['_important'])) {
|
|
// update_post_meta($post_id, '_important', sanitize_textarea_field($_POST['_important']));
|
|
// }
|
|
});
|
|
|
|
/**
|
|
* End: Добавление табов и полей в стандартной форме редактирования товара Woocommerce
|
|
*/ |