-
-
Save renrax/a72636385773b8df5cd001793f7bd039 to your computer and use it in GitHub Desktop.
Добавляем поле описания в форму редактирования атрибута
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Добавляем поле описания в форму редактирования атрибута | |
add_action( 'woocommerce_after_edit_attribute_fields', 'scf_atts_fields', 20 ); | |
function scf_atts_fields() { | |
$term_descr = get_term_meta( $_GET['edit'], 'descr', true ) ? get_term_meta( $_GET['edit'], 'descr', true ) : ''; | |
?> | |
<tr class="form-field form-required"> | |
<th scope="row" valign="top"> | |
<label>Описание атрибута</label> | |
</th> | |
<td> | |
<textarea name="att_descr" id="att_descr" cols="30" rows="10"><?php echo $term_descr; ?></textarea> | |
<p class="description">Показывается на сайте при наведении на знак вопроса</p> | |
</td> | |
</tr> | |
<?php | |
} | |
// Сохраняем описание в терммету | |
add_action( 'woocommerce_attribute_updated', 'scf_save_atts_meta', 20 ); | |
function scf_save_atts_meta( $term_id ) { | |
update_term_meta( $term_id, 'descr', $_POST['att_descr'] ); | |
} |
Author
renrax
commented
Jan 10, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment