Код

Hide woocommerce zero price product and related products wiget

function hide_zero_price_products( $query ) { if ( is_woocommerce() && $query->is_main_query() ) { $query->set( ‘meta_query’, array( array( ‘key’ => ‘_regular_price’, ‘compare’ => ‘>’, ‘value’ => 0, ), ) ); } } add_action( ‘woocommerce_product_query’, ‘hide_zero_price_products’ ); add_filter( ‘woocommerce_related_products_args’, function( $args ) { unset( $args[‘post__in’] ); $args[‘meta_query’] = array( ‘key’ => ‘_regular_price’, ‘compare’ => ‘>’, ‘value’ => 0, […]

Hide woocommerce zero price product and related products wiget Читать далее »

Automatic Add FAQ shemma (JetEngine)

$post_id = get_the_ID(); $repeater = get_post_meta( $post_id, ‘faqshema’, true); if (!empty($repeater)) { $cnt = count($repeater); echo ‘ <script type=»application/ld+json»> { «@context»: «https://schema.org», «@type»: «FAQPage», «mainEntity»: [ ‘; foreach($repeater as $one){ echo ‘ { «@type»: «Question», «name»: «‘; echo $one[‘question’]; echo ‘», «acceptedAnswer»: { «@type»: «Answer», «text»: «‘; echo $one[‘answer’]; echo ‘» } }’; if($cnt >

Automatic Add FAQ shemma (JetEngine) Читать далее »

Get category and subcategory + sorting by custom meta field / bricksultimate

// cat $term = get_queried_object(); $args = []; if( $term ) { $args = [ ‘taxonomy’ => $term->taxonomy, ‘parent’ =>false, ‘hide_empty’ => false, ‘meta_key’ => ‘cat_eq_order’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’ ]; } return $args; //subcat $term = get_queried_object(); $args = []; if( $term ) { $args = [ ‘taxonomy’ => $term->taxonomy, ‘parent’ =>

Get category and subcategory + sorting by custom meta field / bricksultimate Читать далее »

Get woo product and atribut by product category except current product

<?php global $product; $current_product_id = $product->get_id(); $category_id = get_product_cat_id(); // Replace with desired category ID $args = array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘term_id’, ‘terms’ => $category_id, ‘operator’ => ‘IN’, ), ), ‘post__not_in’ => array( $current_product_id ), ); $query = new WP_Query(

Get woo product and atribut by product category except current product Читать далее »

Language Locale Overwrite for WordPress

This lightweight SEO plugin for WordPress allows changing the default HTML lang attribute globally, and on individual Posts and Pages. Along with cross-referencing similar Posts/Pages in different Languages using Alternate Hreflang tags. The Plugin is mostly of use when your WordPress blog contains a mix of languages with individual Posts/Pages, and you do not want to

Language Locale Overwrite for WordPress Читать далее »

Send email to customer when woocommerce order status changed

add_action(«woocommerce_order_status_changed», «my_awesome_publication_notification»); function my_awesome_publication_notification($order_id, $checkout=null) { global $woocommerce; $order = new WC_Order( $order_id ); if($order->status === ‘completed’ ) { // Create a mailer $mailer = $woocommerce->mailer(); $message_body = __( ‘Your track number:’ . $order->get_billing_company() ); $message = $mailer->wrap_message( // Message head and message body. sprintf( __( ‘Order %s received’ ), $order->get_order_number() ), $message_body ); //

Send email to customer when woocommerce order status changed Читать далее »

Woocommerce recently viewed products shortcode — save in COOKIES

//viewed products function custom_track_product_view() { if ( ! is_singular( ‘product’ ) ) { return; } global $post; if ( empty( $_COOKIE[‘woocommerce_recently_viewed’] ) ) $viewed_products = array(); else $viewed_products = (array) explode( ‘|’, $_COOKIE[‘woocommerce_recently_viewed’] ); if ( ! in_array( $post->ID, $viewed_products ) ) { $viewed_products[] = $post->ID; } if ( sizeof( $viewed_products ) > 15 )

Woocommerce recently viewed products shortcode — save in COOKIES Читать далее »

Sort user default by register_date, add user register_date column / сортировка по дате регистрации пользователя, колонка с датой регистрации

//sort defoult by register function change_user_order($args){ $args[«orderby»] = «user_registered»; $args[«order»] = «DESC»; return $args; } add_filter(«users_list_table_query_args»,»change_user_order»); /* * Creating a column (it is also possible to remove some default ones) */ add_filter( ‘manage_users_columns’, ‘rudr_modify_user_table’ ); function rudr_modify_user_table( $columns ) { // unset( $columns[‘posts’] ); // maybe you would like to remove default columns $columns[ ‘registration_date’

Sort user default by register_date, add user register_date column / сортировка по дате регистрации пользователя, колонка с датой регистрации Читать далее »

Add group links to dashboard wordpress / добавить меню в консоль водпресс

function add_group_links_to_dashboard() { global $wp_admin_bar; $wp_admin_bar->add_menu( array( ‘id’ => ‘group_links’, ‘title’ => ‘Group Links’, ‘href’ => ‘#’, ‘meta’ => array( ‘class’ => ‘group-links’ ), ) ); $wp_admin_bar->add_menu( array( ‘parent’ => ‘group_links’, ‘id’ => ‘group_link_1’, ‘title’ => ‘Group Link 1’, ‘href’ => ‘http://example.com/group-link-1’, ) ); $wp_admin_bar->add_menu( array( ‘parent’ => ‘group_links’, ‘id’ => ‘group_link_2’, ‘title’ => ‘Group

Add group links to dashboard wordpress / добавить меню в консоль водпресс Читать далее »

Delete posts / cpt by sheduling / Удалять посты по расписанию

$args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 10, ); $products = get_posts($args); foreach ($products as $product) { wp_delete_post($product->ID, true); } wp_delete_post( $postid = 0, $force_delete = false ) $postid — (целое число) Собственно ID поста, который хотим удалить (параметр обязателен, текущий пост из цикла функция удалять не станет). $force_delete — (логическое) Параметр появился в

Delete posts / cpt by sheduling / Удалять посты по расписанию Читать далее »

Check has_term and get additional info / проверить есть ли таксономия у записи и вывести инфо

add_shortcode( ‘pamyatka4event’, function() { //if ( has_term( », ‘event-tag’ ) ){ // echo ‘<div>has event-tag term </div>’; //} $tag_id = wp_get_post_terms(get_queried_object_id(), ‘event-tag’,array(‘fields’ => ‘ids’) ); if (!empty($tag_id[0])) //also if has event-tag term end ged id { $pam_id = get_term_meta( $tag_id[0], ‘id-pamiatki’, true); //get custom meta term if(empty($pam_id)) {return ;} $slug = basename(get_permalink($pam_id)); $ttle = get_the_title($pam_id);

Check has_term and get additional info / проверить есть ли таксономия у записи и вывести инфо Читать далее »

Automatic manage stock and backorders notify woocommerce products

/* backorder text on single product page */ function so_42345940_backorder_message( $text, $product ){ if ( $product->managing_stock() && $product->is_on_backorder( 1 ) ) { $text = __( ‘Даний товар можливо замовити, термін доставки 12-22 дні. ‘, ‘your-textdomain’ ); } return $text; } add_filter( ‘woocommerce_get_availability_text’, ‘so_42345940_backorder_message’, 10, 2 ); /*different backorder text on single product page for dif

Automatic manage stock and backorders notify woocommerce products Читать далее »

Прокрутить вверх