Skip to content

Instantly share code, notes, and snippets.

@renrax
renrax / dokan-add-to-cart.php
Created February 2, 2022 23:26 — forked from mi5t4n/dokan-add-to-cart.php
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.
@renrax
renrax / functions.php
Created February 2, 2022 20:32 — forked from ibndawood/functions.php
Electro v2 - Enable wishlist and compare count
add_filter( 'electro_show_wishlist_count', '__return_true' );
add_filter( 'electro_show_compare_count', '__return_true' );
@renrax
renrax / functions.php
Created February 2, 2022 20:16 — forked from ibndawood/functions.php
Electro v2 - Remove Wishlist and Compare from Header Icons
add_action( 'init', 'ec_child_edit_header_icons', 20 );
function ec_child_edit_header_icons() {
remove_action( 'electro_header_icons', 'electro_compare_header_icon', 70 );
remove_action( 'electro_header_icons', 'electro_wishlist_header_icon', 80 );
}
@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 );
}
@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: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 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 / 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 / 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
*/