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

FOX Currency Switcher 2.3.7.5 – PHP Fatal Error and Smart Designer Not Initialising

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.

Hello,

I'm using FOX Currency Switcher (WOOCS), version 2.3.7.5, on a WooCommerce website running WordPress 7.1.4.

We're experiencing two issues:

1. PHP Fatal Error

The plugin is generating an HTTP 500 error during an AJAX request.

The request is:

action: woocs_get_products_price_html

The products_ids parameter is being sent as an empty string.

The PHP error is:

Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, string given

File: /wp-content/plugins/woocommerce-currency-switcher/classes/woocs.php

Line: 4002

2. Smart Designer Not Loading in Elementor Mobile Menu

We have created a Smart Designer currency selector using shortcode [woocs sd=2].

The shortcode works correctly when placed on a normal Elementor page.

However, when inserted into an Elementor Mega Menu slide-out panel using an Elementor saved template, it remains stuck displaying the three loading dots.

The standard [woocs] shortcode works correctly in the same mobile menu.

Could you please advise:

  • Is there a fix for the PHP fatal error?
  • Is Smart Designer compatible with dynamically displayed Elementor mobile menus?
  • Is there a supported method of initialising Smart Designer when a slide-out menu opens?

We would prefer not to modify the plugin's core PHP files.

Many thanks.

Breda

Hello Breda

Thank you for the detailed report.

  1. PHP fatal error

This is fixed in current version (v.2.5.7) of FOX: the handler now checks that products_ids is an array and returns an empty answer when it is not. The best solution is to update FOX to the latest version available in your CodeCanyon downloads, where you purchased the plugin.

If you would rather not update right now, for example because you are worried something else might break, you can add this snippet to your child theme’s functions.php (or via the Code Snippets plugin). It does not touch the plugin files. It stops the request before FOX processes it whenever products_ids is not an array, and returns the same empty answer that newer versions return:

// Guard for FOX AJAX price redraw when products_ids is not an array
add_action( 'wp_ajax_woocs_get_products_price_html', 'my_woocs_products_ids_guard', 1 );
add_action( 'wp_ajax_nopriv_woocs_get_products_price_html', 'my_woocs_products_ids_guard', 1 );

function my_woocs_products_ids_guard() {
    if ( isset( $_REQUEST['products_ids'] ) && is_array( $_REQUEST['products_ids'] ) ) {
        return; // normal request, let FOX handle it
    }

    global $WOOCS;
    $currencies = $WOOCS->get_currencies();

    wp_send_json( array(
        'ids'              => array(),
        'current_currency' => $WOOCS->current_currency,
        'currency_data'    => $currencies[ $WOOCS->current_currency ],
    ) );
}
  1. Smart Designer in the Elementor mobile menu

Your observation is correct. A Smart Designer selector is initialised by JavaScript once, when the page finishes loading. Any [woocs sd=2] block that Elementor adds to the page after that moment, such as content of a slide-out panel or mega menu template displayed dynamically, is never initialised and stays on the loading dots. On a normal page the shortcode is already in the markup at load time, which is why it works there.

So for dynamically displayed menus please use the standard [woocs] shortcode, which you already confirmed works in the same mobile menu. It is rendered on the server side and does not need any JavaScript initialisation. Smart Designer can stay in places that are present when the page loads, such as the header or regular page content.

Best regards, Alex