Synchro all calendars and filter by date and price

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Appointment Synchro all calendars and filter by date and price

Viewing 4 reply threads
  • Author
    Posts
    • #82988
      m.loreaux
      Participant

      Hi,

      Firstly thanks for these plugins they are really top for what I’m looking to do.

      I use the plugin woocommerce appointment and would like to know if there is a solution to synchronize the calendars of all products set up by the seller?

      And what is there a solution to put in the filters, filtering by date and by price? As that provides in the plugin WooCommerce appointment

      Thx

    • #83331
      WCFM Forum
      Keymaster

      Hi,

      You are welcome 🙂

      Well, all these works as per WC Appointments plugin’s default behavior.

      Thank You

    • #83500
      m.loreaux
      Participant

      Hi,

      Ok I did Because the synchronization did not work. So for synchronization between the calendars of products from a vendor :

      add_action( ‘woocommerce_order_status_processing’, ‘woocommerce_order_add_all_synchro_appointment’, 10, 1 );
      add_action( ‘woocommerce_order_status_completed’, ‘woocommerce_order_add_all_synchro_appointment’, 10, 1 );
      function woocommerce_order_add_all_synchro_appointment( $order ) {
      global $wpdb, $WCFM;

      $order = wc_get_order($order);

      foreach( $order->get_items() as $item_id => $item ){
      $product_id = $item->get_product_id();
      $vendor_id = wcfm_get_vendor_id_by_post( $product_id );
      $products_objs = $WCFM->wcfm_vendor_support->wcfm_get_products_by_vendor( $vendor_id );

      $appointment_id = WC_Appointment_Data_Store::get_appointment_ids_from_order_item_id( $item_id );
      $appointment = new WC_Appointment( $appointment_id[0] );

      $date_time_start = explode(“,”, $appointment->get_start_date(“Y-m-d”, “, H:i”));
      $date_time_end = explode(“,”, $appointment->get_end_date(“Y-m-d”, “, H:i”));
      $date_start = $date_time_start[0];
      $date_end = $date_time_end[0];
      $time_start = $date_time_start[1];
      $time_end = $date_time_end[1];

      foreach($products_objs as $product_obj){

      $is_exist = $wpdb->get_row(
      $wpdb->prepare(
      “SELECT ID
      FROM {$wpdb->prefix}wc_appointments_availability
      WHERE kind_id = %d
      AND from_range = %s
      AND to_range = %s
      AND from_date = %s
      AND to_date = %s”,
      $product_obj->ID, $time_start, $time_end, $date_start, $date_end
      ),
      OBJECT
      );

      if(empty($is_exist)){
      $wpdb->insert(
      $wpdb->prefix . ‘wc_appointments_availability’,
      array(
      ‘kind’ => ‘availability#product’,
      ‘kind_id’ => $product_obj->ID,
      ‘title’ => ”,
      ‘range_type’ => “custom:daterange”,
      ‘from_range’ => $time_start,
      ‘to_range’ => $time_end,
      ‘from_date’ => $date_start,
      ‘to_date’ => $date_end,
      ‘appointable’ => “no”,
      ‘priority’ => “1”,
      ‘ordering’ => “0”,
      ‘rrule’ => “”,
      ‘date_created’ => current_time( ‘mysql’ ),
      ‘date_modified’ => current_time( ‘mysql’ ),
      )
      );
      }

      }
      }

      }

      add_action( ‘woocommerce_order_status_cancelled’, ‘woocommerce_order_delete_synchro_appointment’, 10, 1 );
      add_action( ‘woocommerce_order_status_refunded’, ‘woocommerce_order_delete_synchro_appointment’, 10, 1 );
      add_action( ‘woocommerce_order_status_failed’, ‘woocommerce_order_delete_synchro_appointment’, 10, 1 );
      add_action( ‘woocommerce_trash_order’, ‘woocommerce_order_delete_synchro_appointment’, 10, 1 );
      add_action( ‘woocommerce_delete_order’, ‘woocommerce_order_delete_synchro_appointment’, 10, 1 );
      function woocommerce_order_delete_synchro_appointment( $order ) {
      global $wpdb, $WCFM;

      $order = wc_get_order($order);

      foreach( $order->get_items() as $item_id => $item ){
      $product_id = $item->get_product_id();
      $vendor_id = wcfm_get_vendor_id_by_post( $product_id );
      $products_objs = $WCFM->wcfm_vendor_support->wcfm_get_products_by_vendor( $vendor_id );

      $appointment_id = WC_Appointment_Data_Store::get_appointment_ids_from_order_item_id( $item_id );
      $appointment = new WC_Appointment( $appointment_id[0] );

      $date_time_start = explode(“,”, $appointment->get_start_date(“Y-m-d”, “, H:i”));
      $date_time_end = explode(“,”, $appointment->get_end_date(“Y-m-d”, “, H:i”));
      $date_start = $date_time_start[0];
      $date_end = $date_time_end[0];
      $time_start = $date_time_start[1];
      $time_end = $date_time_end[1];

      foreach($products_objs as $product_obj){

      $wpdb->delete(
      $wpdb->prefix . ‘wc_appointments_availability’,
      array(
      ‘kind’ => ‘availability#product’,
      ‘kind_id’ => $product_obj->ID,
      ‘range_type’ => “custom:daterange”,
      ‘from_range’ => $time_start,
      ‘to_range’ => $time_end,
      ‘from_date’ => $date_start,
      ‘to_date’ => $date_end,
      ‘appointable’ => “no”,
      ‘priority’ => “1”,
      )
      );
      }
      }
      }

    • #83756
      WCFM Forum
      Keymaster

      Hi,

      Is this code working for you and fulfill your requirement?

      Actually, this code is for “Availability Manage”, not for calendar sync!

      Thank You

    • #84045
      m.loreaux
      Participant

      Hi

      Yes he do.

      When I talk sync between calendars, it’s with the reservation calendars in a product, with the woocommerce appointment plugin

Viewing 4 reply threads
  • The topic ‘Synchro all calendars and filter by date and price’ is closed to new replies.