Skip to content

Instantly share code, notes, and snippets.

/**
* Сортировка атрибутов в админке по алфавиту
*
* @param $attr
*
* @return array
*
* @testedwith WooCommerce 6.0
* @author Artem Abramovich
*/
@artikus11
artikus11 / art-custom-edits.php
Last active January 13, 2022 18:11
Изменение слова Подытог в WooCommerce
/**
* Замена стандартных текстов на страницах
*
* @param $translated_text
* @param $text
* @param $domain
*
* @return mixed|string
*/
function art_shop_strings( $translated_text, $text, $domain ) {
@artikus11
artikus11 / snippet-woo.php
Last active November 16, 2023 20:08
Подключение скриптов и стилей только на страницах WooCommerce
/**
* Подключение скриптов и стилей только на страницах WooCommerce
*
* @testedwith WooCommerce 5.5
* @verphp 7.0
* @author Artem Abramovich
*/
function art_connection_css_js_only_woocommerce_pages() {
if ( is_woocommerce() || is_cart() || is_checkout() || is_account_page() ) {
@jmabbas
jmabbas / function.php
Created June 23, 2021 03:51
Electro - Sale label only for logged in users
function electro_get_sale_flash( $html, $post, $product ) {
if( is_user_logged_in() ) {
$html = '<span class="onsale">-' . electro_get_savings_on_sale( $product, 'percentage' ) . '</span>';
return apply_filters( 'electro_get_sale_flash', $html, $post, $product );
}
}
@rashedripon
rashedripon / functions.php
Last active February 7, 2022 08:03
Dokan store open-close in single product page
<?php
//Remove the <?php while using it in your theme's functions.php file
//Add store open-show information before single product add-to-cart button
add_action('woocommerce_before_add_to_cart_form', 'dokan_open_close', 1000);
function dokan_open_close() {
global $product;
@artikus11
artikus11 / added-function.php
Last active January 11, 2022 08:59
Создание записи при отправке формы из Contact Form 7
add_action( 'wpcf7_before_send_mail', 'created_post_in_cf7' );
function created_post_in_cf7( $contact_form ) {
$title = $_POST['text-title-post'] && ! empty( $_POST['text-title-post'] ) ? sanitize_text_field( $_POST['text-title-post'] ) : '';
$content = $_POST['text-contant-post'] && ! empty( $_POST['text-contant-post'] ) ? wp_strip_all_tags( $_POST['text-contant-post'] ) : '';
$field = $_POST['text-field-post'] && ! empty( $_POST['text-field-post'] ) ? sanitize_text_field( $_POST['text-field-post'] ) : '';
$ars = [
'post_type' => 'post',
'post_title' => $title,
@jmabbas
jmabbas / function.php
Created November 21, 2019 05:37
Electro - Remove Uncategorized category in Store Directory
add_filter( 'woocommerce_product_categories_widget_args', 'el_child_exclude_uncategory' );
function el_child_exclude_uncategory( $cat_args ) {
$cat_args['exclude'] = get_option( 'default_product_cat' );
return $cat_args;
}
@jmabbas
jmabbas / function.php
Created October 23, 2019 08:48
WooCommerce - Remove uncategoriezed
add_filter( 'woocommerce_product_categories_widget_args', 'custom_woocommerce_product_subcategories_args' );
function custom_woocommerce_product_subcategories_args( $args ) {
$args['exclude'] = get_option( 'default_product_cat' );
return $args;
}
@mi5t4n
mi5t4n / dokan-add-to-cart.php
Last active April 26, 2022 15:57
Make product purchasable based on the vendor opening and closing time in dokan plugin.
<?php
/**
* Hide or display add to cart button based on opening hours.
*/
function prefix_woocommerce_is_purchasable( $is_purchasable, $product ) {
// Get the store id.
$store_id = get_post_field( 'post_author', $product->get_id() );
// Get the store info.
@jmabbas
jmabbas / function.php
Last active April 3, 2024 12:08
Electro - Copyright in mobile
add_action( 'init', 'el_child_copyright_in_handheld' );
function el_child_copyright_in_handheld() {
add_action( 'electro_footer_v2_handheld', 'electro_copyright_bar_v2', 81 );
add_action( 'electro_mobile_footer_v1', 'electro_copyright_bar_v2', 100 );
add_action( 'electro_mobile_footer_v2', 'electro_copyright_bar_v2', 100 );
}