Okay
  Public Ticket #2805929
Adding event to personal calendar
Closed

Comments

  • breakrocks started the conversation

    Hi, we have a personal calendar assigned to each user once they complete registration.  

    The users would have access to another calendar which shows all events that are being offered.  

    Once the user purchases the ticket to the event, I would like the event to show up on his/her personal calendar.  How do I go about implementing this?

  •  799
    Zhivko replied

    Hi,

    Unfortunately events can reside only in one calendar at a time.

    As an alternative I could suggest you to duplicate the event to the user's personal calendar once the booking order is completed.

    This can be achieved with custom hook.

    I've attached the required code. 

    The code should be placed in your theme or child-theme functions.php file.


    Stachethemes Developer

  • breakrocks replied

    Thanks for your replying

    But I am a little bit comfuse about "the booking order is completed". Do you mean buy ticket or buy the producet linked to the event or aomething else?

  •  799
    Zhivko replied

    When the order containing the event ticket is set as "completed" from your WooCommerce -> Orders menu.


    Stachethemes Developer

  • breakrocks replied

    Thanks for answering

    do you know how can I set the order for buying tickets to auto approve, so the event ticket will be set to "completed" right away after purchase (which I don't need to set it to "completed" manually)

  •  799
    Zhivko replied

    Yes, it's possible with custom filter.

    Place the code in your theme or child-theme functions.php file:

    add_action('woocommerce_thankyou', function($order_id) {
        if (!$order_id) {
            return;
        }     $order                         = wc_get_order($order_id);
        $contains_calendar_ticket      = false;
        $contains_non_calendar_product = false;
        $items                         = $order->get_items();     foreach ($items as $item) {         $item_data  = $item->get_data();
            $product_id = filter_var($item_data['product_id'], FILTER_VALIDATE_INT);         if (!$product_id) {
                continue;
            }         $product = wc_get_product($product_id);         if ($product && '1' === $product->get_meta('stec_bookable')) {
                $contains_calendar_ticket = true;
            } else {
                $contains_non_calendar_product = true;
            }
        }     if (true === $contains_calendar_ticket && false == $contains_non_calendar_product) {
            if ($order->get_status() === 'processing') {
                $order->update_status('completed');
            }
        }
    }, 10, 1);

    Stachethemes Developer

  • breakrocks replied

    Hi,

    Thanks sop much for your answering, help a lot

    I also wonder can all these functions be implemented on purchasing the woocommerce product that contained in the event(woocommerce product added to the event).

  • breakrocks replied

    Hi,

    Just want to know how is going so far, didn't get reply for a while.

    Thanks