Skip to content

Instantly share code, notes, and snippets.

@renrax
renrax / function.php
Created January 13, 2022 13:11
WooCommerce - Удалить изображения и галерею товара после его удаления
<?php
// Автоматическое удаление изображений Woocommerce после удаления продукта
// Automatically Delete Woocommerce Images After Deleting a Product
add_action( 'before_delete_post', 'delete_product_images', 10, 1 );
function delete_product_images( $post_id )
{
$product = wc_get_product( $post_id );
@renrax
renrax / functions.php
Created January 10, 2022 15:14 — forked from artikus11/functions.php
Добавляем поле описания в форму редактирования атрибута
// Добавляем поле описания в форму редактирования атрибута
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>
/**
* Сортировка атрибутов в админке по алфавиту
*
* @param $attr
*
* @return array
*
* @testedwith WooCommerce 6.0
* @author Artem Abramovich
*/