• Resolved abdullahihussein1995

    (@abdullahihussein1995)


    Hi.
    I am trying to use the Woocs functions in my functions.php file but I keep getting call to member function on null.

    Please assist.

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

    (@mediawebster)

    Hello

    Looks like you didn’t initialize the global variable or call the function when my plugin is not connected yet

    please drop me your code

    Thread Starter abdullahihussein1995

    (@abdullahihussein1995)

    function event_api_post_callback( $request ) {
    global $event;
    $event_data = array(
    ‘post_type’ => ‘tc_events’,
    ‘post_title’ => $request[‘event_name’],
    ‘post_content’ => $request[‘event_terms’],
    ‘post_status’ => ‘publish’

    );

    $events = new TC_Events();

    $event = wp_insert_post( $event_data );

    if( !is_wp_error($event_data) ) {
    $response[‘status’] = 200;
    $response[‘success’] = true;
    update_post_meta( $event, ‘event_location’, $request[‘event_location’]);
    update_post_meta( $event, ‘event_date_time’, $request[‘event_date_time’]);
    update_post_meta( $event, ‘event_end_date_time’, $request[‘event_end_date_time’]);
    update_post_meta( $event, ‘event_terms’, $request[‘genre’]);
    update_post_meta( $event, ‘event_logo’, $request[‘event_logo’]);
    wp_set_object_terms( $event, $request[‘event_category’], ‘event_category’ );
    get_post_meta( $event, ‘tc_speakers’);
    update_post_meta( $event, ‘tc_speakers’, $request[‘speaker_tags’]);
    update_post_meta( $event, ‘tc_speakers_show_type’, ‘shortcode’);
    update_post_meta( $event, ‘tc_speakers_view’, ‘tc_list’);
    update_post_meta($event, ‘tc_speakers_grid_show_cats’, ‘no’);
    update_post_meta($event, ‘event_datetime_utc’, $request[‘event_end_time_utc’]);
    update_post_meta($event, ‘event_logo_file_url’, $request[‘timezone’]);

    fifu_dev_set_image($event, ‘https://youbloomconnect.com/storage/event_photo/’.$request[‘event_logo’]);

    $permalink = get_permalink($event);

    $p_id = get_post($event);
    $status = ‘draft’;

    global $WOOCS;
    $currencies=$WOOCS->get_currencies();
    $converted_currency = $WOOCS->back_convert($request[‘price’],$currencies[$request[‘currency’]][‘rate’],0);

    $response[‘permalink’] = $converted_currency;
    $response[‘ID’] = $p_id;
    $response[‘converted_currency’] = $converted_currency;

    global $wpdb;
    $where = array( ‘ID’ => $event );
    $data = array(‘post_status’=>’draft’);
    $wpdb->update( $wpdb->posts, $data, $where );

    } else {
    $response[‘status’] = 200;
    $response[‘success’] = false;
    $response[‘data’] = get_post( $events );
    }

    return new WP_REST_Response($response);

    // }
    }

    Thread Starter abdullahihussein1995

    (@abdullahihussein1995)

    This is the error am getting

    2022-07-31T23:20:25+00:00 CRITICAL Uncaught Error: Call to a member function get_currencies() on null in /srv/users/libbloom/apps/libertybloom/lib_new/web/app/themes/parallax-pro/functions.php:1441

    On my local the code works but on the live site I get errors

    Thread Starter abdullahihussein1995

    (@abdullahihussein1995)

    Please help me.

    Plugin Support mediawebster

    (@mediawebster)

    Hello

    so you initialize the function when the plugin is not yet connected

    wrap this code( https://clip2net.com/s/4gioWp3) in a condition:

    if(class_exists(‘WOOCS’)) {

    }

    Thread Starter abdullahihussein1995

    (@abdullahihussein1995)

    Thanks for your reply.

    I did the corrections you sent me. I’m now not getting any errors, but however the variable doesn’t return anything. I need that variable to convert my currency into euros but it doesn’t work.

    I don’t know what I’m doing wrong. The plugin is active already.

    Thanks for your help.

    Plugin Author RealMag777

    (@realmag777)

    Hello

    That mean hook you wrapped the code is not right or too late, give me please screen in what hook wrapped function event_api_post_callback

    Also for more detailed investigation you can create ticket here: https://pluginus.net/support/forum/woocs-woocommerce-currency-switcher-multi-currency-and-multi-pay-for-woocommerce/

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Call to member function get_currencies on null’ is closed to new replies.