Skip to content

Instantly share code, notes, and snippets.

/**
* Сортировка атрибутов в админке по алфавиту
*
* @param $attr
*
* @return array
*
* @testedwith WooCommerce 6.0
* @author Artem Abramovich
*/
@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>
@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 / function.php
Last active January 13, 2022 14:01
Быстро перевести любую строку
<?php
//Exemple 1
add_filter('gettext', 'translate_text');
add_filter('ngettext', 'translate_text');
function translate_text($translated) {
$translated = str_ireplace('Choose and option', 'Select', $translated);
return $translated;
@renrax
renrax / art-custom-edits.php
Created January 13, 2022 18:11 — forked from artikus11/art-custom-edits.php
Изменение слова Подытог в WooCommerce
/**
* Замена стандартных текстов на страницах
*
* @param $translated_text
* @param $text
* @param $domain
*
* @return mixed|string
*/
function art_shop_strings( $translated_text, $text, $domain ) {
@renrax
renrax / Readme.txt
Last active January 14, 2022 10:17
Dokan - Adding checkbox for custom settings on New product popup/without popup form
This code adds the Checkbox field to Dokan and to WooCommerce.
But
If the administrator on the Wordpress side edits, the box is saved.
If the seller edits via Dokan, the box will remain unchecked after he saves the page.
@renrax
renrax / functions.php
Created January 21, 2022 15:01 — forked from mikejolley/functions.php
WooCommerce 3.3 - Hide uncategorized category from the shop page on the frontend
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_filter( 'woocommerce_product_subcategories_args', 'custom_woocommerce_product_subcategories_args' );
function custom_woocommerce_product_subcategories_args( $args ) {
$args['exclude'] = get_option( 'default_product_cat' );
return $args;
@renrax
renrax / functions.php
Created February 2, 2022 19:35 — forked from ibndawood/functions.php
Electro - Always display attributes in Specifications tab
add_action( 'woocommerce_before_single_product', 'ec_child_modify_display_specs_attr' );
function ec_child_modify_display_specs_attr() {
global $post;
update_post_meta( $post->ID, '_specifications_display_attributes', 'yes' );
}
@renrax
renrax / functions.php
Created February 2, 2022 19:39 — forked from ibndawood/functions.php
Electro v2 - Add compare and wishlist to mobile header
add_filter( 'electro_handheld_header_links', 'ec_child_add_wishlist_compare', 10 );
function ec_child_add_wishlist_compare( $links ) {
$links['wishlist'] = array(
'priority' => 40,
'callback' => 'ec_child_wishlist_header_link'
);
$links['compare'] = array(
'priority' => 40,
'callback' => 'ec_child_compare_header_link'
@renrax
renrax / functions.php
Created February 2, 2022 19:46 — forked from ibndawood/functions.php
Electro v2 - Show rating in grid view
add_action( 'init', 'ec_child_add_rating' );
function ec_child_add_rating() {
remove_action( 'woocommerce_after_shop_loop_item_title', 'electro_template_loop_rating', 70 );
add_action( 'woocommerce_after_shop_loop_item_title', 'electro_template_loop_rating', 140 );
}