0.00  View Cart

Support Easy Booking: Google Calendar [Resolved] How to get the quantity of an order item ?

This topic contains 6 replies, has 2 voices, and was last updated by  fla2paris 1 month, 3 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #5818

    fla2paris
    Participant

    Hello,

    I’m trying to create filter description but It seems not working, I’m not a specialist in coding, so please if someone could help me…

    Here is the filter I’m trying to make :

    add_filter( ‘easy_booking_calendar_event_description’, ‘add_custom_event_description’, 10, 3 );
    function add_custom_event_description( $description, $order_item, $order ) {

    $description = “Waiting for ” . ($order_item->get_quantity()) . ‘ x ‘ . $order_item->get_name();
    return $description;
    }

    I think my “get_quantity() ” function is not good.

    Any idea ?

    Thanx for your help

     

    #5819

    Ashanna
    Plugin's author

    Hello,

    The function get_quantity() is ok.

    Can you try this with the right quote symbols:

    add_filter( 'easy_booking_calendar_event_description', 'add_custom_event_description', 10, 3 );
    
    function add_custom_event_description( $description, $order_item, $order ) {
    
        $description = 'Waiting for ' . $order_item->get_quantity() . ' x ' . $order_item->get_name();
        return $description;
    
    }

    Did you place the code in your theme’s functions.php (child theme if you use one)?

    Regards,
    Natasha

    #5821

    fla2paris
    Participant

    Many thanx natasha, it works great 😉

    and do you think it is possible in this same filter, to had the variable of the woocommerce additional informations field of the order?

    the one you can find before validate/pay the order?

    Is there a function for that?

    thanx a lot

    #5823

    Ashanna
    Plugin's author

    What kind of information are you talking about? Can you give me an example?

    Is it information linked to the order or the order items?

    #5824

    fla2paris
    Participant

    It is the informations link to the order (not the item), it is a woocommerce text area where the customers can write additionnal informations for the order, just before proceed payment.

    #5825

    Ashanna
    Plugin's author

    Ah allright, sorry I misunderstood.

    This should work:

    $order->get_customer_note();

    If you want to include it to the above code, do something like this:

    add_filter( 'easy_booking_calendar_event_description', 'add_custom_event_description', 10, 3 );
    
    function add_custom_event_description( $description, $order_item, $order ) {
    
        $description = 'Waiting for ' . $order_item->get_quantity() . ' x ' . $order_item->get_name() . ' - Customer note: ' . $order->get_customer_note();
        return $description;
    
    }

    #5826

    fla2paris
    Participant

    It works perfect thank you very much ….

    BUT

    I realize unfortunatly this beta version causes dysfunctionality in woocommerce/wordpress back-end, I will give détails in an other topics…

    Many thanx for your help

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘[Resolved] How to get the quantity of an order item ?’ is closed to new replies.