• Resolved mroussev

    (@mroussev)


    Hello All,

    I am using TranslatePress on this website https://nedanacheva.com/, wich WOOCS plugin and PHP script in functions.php for automatic change of currency with language change, English->EUR, Bulgarian-> BGN.

    $lang=get_locale();
    global $WOOCS;
    switch($lang){
     case 'bg_BG':
          $WOOCS->current_currency='BGN';
          $WOOCS->storage->set_val('woocs_current_currency', 'BGN');
       break;
     case 'en_GB':
          $WOOCS->current_currency='EUR';
          $WOOCS->storage->set_val('woocs_current_currency', 'EUR');
       break;
      default:
          $WOOCS->current_currency='EUR';
          $WOOCS->storage->set_val('woocs_current_currency', 'EUR');
      break;
    }

    It works, but i think this script is a little outdated because i have issue with Elementor because of it, and in error_log i have this errors:

    [01-Oct-2020 17:16:49 UTC] PHP Warning:  Creating default object from empty value in /home/nedanach/public_html/wp-content/themes/bridge-child/functions.php on line 17
    [01-Oct-2020 17:16:49 UTC] PHP Fatal error:  Uncaught Error: Call to a member function set_val() on null in /home/nedanach/public_html/wp-content/themes/bridge-child/functions.php:18

    which are exactly the lines for automatic currency switch with language.

    Also because of those lines, i cannot get Elementor to work, when this code is active, Elementor cannot load edit mode.

    Please help me what must be change to code to continue work and Elemntor to work without errors.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support mediawebster

    (@mediawebster)

    Hello

    Try to wrap this code in a condition

    if(class_exists('WOOCS')){
    //your  code
    }
    Thread Starter mroussev

    (@mroussev)

    Hello,

    Thanks for fast answer!
    Can you paste me full edited code that i have to replace. Sorry that i didnt mention this, but i have ZERO php skills, the code was taken from thread here in the forum, but was like 4 years old, i just replace the currencies.

    • This reply was modified 4 years, 5 months ago by mroussev.
    Thread Starter mroussev

    (@mroussev)

    Never mind i manage to make it. Seems to work fine now, Elementor loads and no error_log generated. Thanks!!

    • This reply was modified 4 years, 5 months ago by mroussev.
    Plugin Support mediawebster

    (@mediawebster)

    Hello
    Ok! Great!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Currency change with language TranslatePress’ is closed to new replies.