PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Change the "featured" text

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.
12

Hello, we need to translate the texts in other language. If someone selects featured products in the filter (roduct_visibility=featured) then the"featured" text appears above the results. When this text is clicked, the featured filter is removed again.

Image Link auf this featured text: https://ibb.co/HFPzksV

How can we translate this “featured” text? We have not found anything in Loco Translate.

Hello

Please try this - https://products-filter.com/hook/woof_ext_custom_title_xxx

Can you drop me exact link to the issue?

Hello,

Sorry, I don't understand. What should I do?

The site is still under development and not publicly accessible. I have marked in the following picture which “featured” text I want to translate:

https://ibb.co/wpnq4Db

Ok! try in file - \woocommerce-products-filter\ext\by_featured\index.php - add this code -https://share.pluginus.net/image/i20241107114616.png

add_action('wp_head', array($this, 'wp_head'));

public function wp_head () {
self::$includes['js_lang_custom'][$this->index] = esc_html__('Featured products', 'woocommerce-products-filter');
}

Thank you. We work with a child theme and do not work directly on the original php files.

Can I also insert the code in the functions.php of the child theme?

Hello

Fix this in the plugin file. This fix will be included in the next version.

Ok. Code is inserted but the “featured” text is still not translated. What else needs to be done?

Here my index.php code:

 

<?php
if (!defined('ABSPATH'))
    die('No direct access allowed');
final class WOOF_EXT_BY_FEATURED extends WOOF_EXT {
    public $type = 'by_html_type';
    public $html_type = 'by_featured'; //your custom key here
    public $index = 'featured';
    public $html_type_dynamic_recount_behavior = 'none';
    public function __construct() {
        parent::__construct();
        $this->init();
    }
    public function get_ext_path() {
        return plugin_dir_path(__FILE__);
    }
    public function get_ext_override_path() {
        return get_stylesheet_directory() . DIRECTORY_SEPARATOR ."woof" . DIRECTORY_SEPARATOR ."ext" . DIRECTORY_SEPARATOR . $this->html_type . DIRECTORY_SEPARATOR;
    }
    public function get_ext_link() {
        return plugin_dir_url(__FILE__);
    }
    public function woof_add_items_keys($keys) {
        $keys[] = $this->html_type;
        return $keys;
    }
    public function init() {
        add_filter('woof_add_items_keys', array($this, 'woof_add_items_keys'));
        add_action('woof_print_html_type_options_' . $this->html_type, array($this, 'woof_print_html_type_options'), 10, 1);
        add_action('woof_print_html_type_' . $this->html_type, array($this, 'print_html_type'), 10, 1);
        add_action('woocommerce_product_query', array($this, 'parse_query'));
        add_action('woof_get_tax_query', array($this,"woof_get_tax_query"), 9999);
add_action('wp_head', array($this, 'wp_head'));
        self::$includes['js']['woof_' . $this->html_type . '_html_items'] = $this->get_ext_link() . 'js/' . $this->html_type . '.js';
        self::$includes['css']['woof_' . $this->html_type . '_html_items'] = $this->get_ext_link() . 'css/' . $this->html_type . '.css';
        self::$includes['js_init_functions'][$this->html_type] = 'woof_init_featured';
        self::$includes['js_lang_custom'][$this->index] = esc_html__('Featured products', 'woocommerce-products-filter');
    }
public function wp_head () {
self::$includes['js_lang_custom'][$this->index] = esc_html__('Featured products', 'woocommerce-products-filter');
}
    //settings page hook
    public function woof_print_html_type_options() {
        woof()->render_html_e($this->get_ext_path() . 'views' . DIRECTORY_SEPARATOR . 'options.php', array(
            'key' => $this->html_type,
           "woof_settings" => get_option('woof_settings', array())
                )
        );
    }
    public function parse_query($wp_query) {
        if (!isset($wp_query->query['post_type']) OR $wp_query->query['post_type'] != 'product') {
            //return $wp_query;
        }
        if (!empty($wp_query->tax_query) AND isset($wp_query->tax_query->queries)) {
            $request = woof()->get_request_data();
            if (isset($request["product_visibility"]) AND $request["product_visibility"] == 'featured') {
                $tax_query = $wp_query->tax_query->queries;
                $tax_query = $this->add_to_tax_query($tax_query);
                $wp_query->set('tax_query', $tax_query);
            }
        }
    }
    public function add_to_tax_query($tax_query) {
        $tax_query[] = array(
            'taxonomy' => 'product_visibility',
            'field' => 'name',
            'terms' => 'featured',
        );
        return $tax_query;
    }
    public function woof_get_tax_query($tax_query) {
        $request = woof()->get_request_data();
        if (isset($request["product_visibility"]) AND $request["product_visibility"] == 'featured') {
            $tax_query = $this->add_to_tax_query($tax_query);
        }
        return $tax_query;
    }
}
WOOF_EXT::$includes['html_type_objects']['by_featured'] = new WOOF_EXT_BY_FEATURED();

Hello

Please delete this code - https://share.pluginus.net/image/i20241111120041.png

Clear all cache and Ctrl+F5 and do a test

Hello, unfortunately, this does not work. In your code it says “Featured products” but on my website “featured” is displayed. It is not clear to me how your code should change this text.

It seems to me that the “featured” text is fetched via the url variable “product_visibility=featured” and therefore cannot be translated. If I write “product_visibility=ABCD” in the URL, then “ABCD” is displayed on the website where “featured” was.

 

Please drop me exact link to the issue

Unfortunately I can't show the site at the moment because it is under development.

But I have found another site that does the same thing:

https://at4.com/de/categorie-produit/chambres/?product_visibility=featured

Here, the same: “featured” is not translated and you can replace it with other text in the url that is then displayed. E.G:

https://at4.com/de/categorie-produit/chambres/?product_visibility=1234

Any idea how to change/translate the “featured” text in such a case?

Hello

This element must be in the filter for correct display. I mean the featured checkbox should be displayed in the filter

Hello, thank you for your answer.

the featured checkbox (in German “Top Artikel”) is also displayed in the filter.

However, when selecting it, “featured” is displayed on the right and not “Top Artikel”.

Image: Screenshot-2024-11-12-122549 hosted at ImgBB — ImgBB

What do I have to change so that “Top Artikel” is also displayed on the right side?

Hello

What plugin version number are you using?

Hello,

Husky Plugin Version: Version 3.3.6.4

Woocommerce Version 9.4.1

Wordpress Version 6.7

Theme: Shoptimizer (newest Version)

Please paste your license key here - https://share.pluginus.net/image/i20230222134241.png -> https://share.pluginus.net/image/i20230222134511.png and  wp-admin+ftp access - https://share.pluginus.net/image/i20230222134615.png - I will check it

Hello, unfortunately we are currently unable to set up access.

Unfortunately, the problem persists. The “featured” text is not translated. What other solutions are there?

Thank you.

Hello

Please paste your license key here - https://share.pluginus.net/image/i20230222134241.png -> https://share.pluginus.net/image/i20230222134511.png

Thank you for your answer. I have added the key.

12