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 / 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 / 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 / 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;