Search code examples
phpwordpresswoocommercewoocommerce-bookings

Call function of the class, which can't call other functions within the class


I'm trying to adjust WP Woocommerce bookings plugin and add functionality for getting events from Google calendar API.

There's class

Class WC_Bookings_Google_Calendar_Integration extends WC_Integration

, which provides token acquiring and authorization.

I added new function to the class

public function get_googlecal_bookings( $bookable_product, $min_date = 0, $max_date = 0 )

that suppose to retrieve all bookings in between min and max dates for certain product.

From my functions.php I'm calling it with

$existing_bookings = WC_Bookings_Google_Calendar_Integration::get_googlecal_bookings($bookable_product, $from, $to);

and this works with dummy data.

Although, when I try to use other class functions within function get_googlecal_bookings, like $api_url = $this->calendars_uri . $this->calendar_id . '/events/'; or $access_token = $this->get_access_token(); I get nothing.

I know I call them incorrectly, just need to point me in the right directions


Solution

  • you are calling it as a static function WC_Bookings_Google_Calendar_Integration::get_googlecal_bookings, but you are referencing $this, which won´t work, since there´s no instance.