Okay
  Public Ticket #2655288
How to access service/event description which is placed in woocommerce order
Closed

Comments

  •  10
    michiiee started the conversation

    Hi,

    because Amelia doesnt provide invoices, we linked it with woocommerce. We are now using a plugin to create the invoices. Due to german law, we need to write the service description into the invoices.

    We see that for a Amelia/Woocommerce Order, some information is stored in the order. See picture below.

    Could you tell me how we can access that data?

    Is that data stored in a table in the database? Or is that information Order-Item-Meta-Data? If yes, which meta_keys are used for it?

    Regards,

    Michael

  • [deleted] replied

    Hi Michael,

    The meta_key is "ameliabooking", some of the data are saved in the order itself, and some of it is taken from the database, from the amelia tables, using queries, based on the entity ID that are saved in Meta Data.

    If you have any other questions or concerns feel free to open a new ticket and we will gladly help out.


  • Ahmad Abdullahi Ahmad replied

    Hi Marija,

    I am having the same issue with him, and I think you did not get him.

    we need the order details to be on our invoices exactly not only product name on the invoice.

  •  10
    michiiee replied

    Doesnt seem to work, the metadata for the products are empty.

    What data shoudl the meta key ameliabooking contain?

    Regards,

    Michael

  • [deleted] replied

    Helo Michael, 

    I forwarded this question to one of our developers, so I will get back to you as soon as I get some feedback from them.


  • [deleted] replied

    Hello Michael, 

    I got a feedback from our developer regarding this matter

    The data is saved in the Order Item Meta Data, and you can get this data this way: 

    wc_get_order_item_meta($item_id, 'ameliabooking')

    So, you would need to add metaData that is got using this method to the template for the invoice created. 



  •  10
    michiiee replied

    Hi again,

    well i can display my data in the invoice now, but the order item meta data is really weird in its structure and content. See down below.

    I just want to display everything between the first <br> and the last <br>. Is there any shortcode for that? 

    Or can you offer a php script which i can add to functions.php which would adjust the data so that only the relevant stuff is displayed by the shortcode?

    I think i am not the only one who wants to access the amelia data for invoices, so a solution would be really great.


    This is the stuff which is displayed by the shortcode. Everything from "a:19" to the first <br> is uselss.

    a:19:{s:4:"type";s:11:"appointment";s:9:"serviceId";i:39;s:10:"providerId";i:1;s:10:"locationId";i:1;s:4:"name";s:31:"Impuls - Coaching -Telefonisch ";s:8:"couponId";s:0:"";s:10:"couponCode";s:0:"";s:12:"bookingStart";s:16:"2021-03-04 11:15";s:10:"bookingEnd";s:16:"2021-03-04 11:45";s:6:"status";s:7:"pending";s:14:"dateTimeValues";a:1:{i:0;a:2:{s:5:"start";s:16:"2021-03-04 11:15";s:3:"end";s:16:"2021-03-04 11:45";}}s:18:"notifyParticipants";i:1;s:8:"bookings";a:1:{i:0;a:7:{s:10:"customerId";i:2;s:8:"customer";a:6:{s:5:"email";s:28:"[email protected]";s:10:"externalId";i:2;s:9:"firstName";s:7:"Michael";s:2:"id";i:2;s:8:"lastName";s:4:"Hahm";s:5:"phone";s:11:"+4917575785";}s:7:"persons";i:1;s:6:"extras";a:0:{}s:6:"status";s:7:"pending";s:9:"utcOffset";N;s:12:"customFields";a:1:{i:2;a:3:{s:5:"label";s:12:"Terminoption";s:5:"value";s:49:"Zoom - Meeting / techn. Ausrüstung vorausgesetzt";s:4:"type";s:5:"radio";}}}}s:7:"payment";a:4:{s:7:"gateway";s:2:"wc";s:12:"gatewayTitle";s:24:"Direkte Banküberweisung";s:6:"amount";i:0;s:6:"status";s:4:"paid";}s:9:"recurring";a:0:{}s:7:"package";a:0:{}s:28:"uploadedCustomFieldFilesInfo";a:0:{}s:6:"labels";s:411:"<br/>Termin-Info<br/><hr><br />
    <br />
    <strong>Lokale Uhrzeit:</strong> 4. März 2021 11:15<br />
    <br />
    <strong>Service:</strong> Impuls - Coaching -Telefonisch <br />
    <br />
    <strong>Mitarbeiter:</strong> Dominique Becker<br />
    <br />
    <strong>Gesamtanzahl Personen:</strong> 1<br />
    <br />
    <strong>Benutzerdefinierte Felder:</strong><br />
    <br />
    Terminoption: Zoom - Meeting / techn. Ausrüstung vorausgesetzt";s:9:"processed";b:1;}

  • [deleted] replied

    Hi Michael, 

    There isn't a shortcode for that and we don't have a php script that you could use to achieve that, unfortunately. That would be customization, and that is not covered by our support, so we can't help with this any more than we did, unfortunately. I will add it to our feature requests list, and forward it, so it can be considered for the future versions of Amelia. I assume we will work on adding some improvements to the WooCommerce integration in the future, so this can be considered, but for now we can't say if and when it could be implemented, unfortunately. 

    If you have any other questions or concerns feel free to open a new ticket and we will gladly help out.

  • Ahmad Abdullahi Ahmad replied

    How where you able to add the meta data please?

  • Ahmad Abdullahi Ahmad replied

    please how do i use this for my invoice? i want my pdf invoice to be as detailed as the email invoice : 

    wc_get_order_item_meta($item_id, 'ameliabooking')
    
  • Ahmad Abdullahi Ahmad replied

    below are the attachments. Urgently please

  • [deleted] replied

    Hello Ahmad Abdullahi Ahmad,

    Like I mentioned earlier, WooCommerce integration in Amelia is done for WooCommerce only so you can use the email invoice option in WooCommerce for this purpose. We can't say how this integration will work with any additional WooCommerce plugins/add-ons , unfortunately, and with the current integration that can't be affected from Amelia's side.

    That would be customization, and that is not covered by our support, so we can't help with this any more than we did, unfortunately. You can suggest this as a feature request here, or check if there is such request and vote for it.

    If you have any other questions or concerns feel free to open a new ticket and we will gladly help out.


  • Ahmad Abdullahi Ahmad replied

    Anyway, I was able to work on it.

  • [deleted] replied

    Great, glad to see that you managed to achieve what you need. Thank you for letting us know. 

    If you have any other questions or concerns feel free to open a new ticket and we will gladly help out.

  •  10
    michiiee replied

    Hi Ahmad,


    what invoice plugin are you using? 

    And have you written some custom code? Would be great if you could share it!

    Regards,

    Michael

  • Ahmad Abdullahi Ahmad replied

    we are using PDF invoice by webtofee

    Add this to you active theme function.php

    add_filter('wf_pklist_add_product_meta', 'wt_pklist_additional_product_meta_fields', 10, 5);
    function wt_pklist_additional_product_meta_fields($addional_product_meta, $template_type, $_product, $order_item, $order)
    {
    if($template_type=='invoice')
    {
    $order_id=$order_item->get_id();
    $meta=wc_get_order_item_meta($order_id, 'ameliabooking',true);
    if(isset($meta) && isset($meta['labels']))
    {
    $info=$meta['labels'];
    $addional_product_meta.='<small>'.$info.'</small>';
    }
    }
    return $addional_product_meta;
    }

  •  10
    michiiee replied

    Hi again,

    i finally have the solution for WooCommerce Germanized in combination with Amelia:


    //Folgenden Shortcode in Germanized Rechnungsvorlage einfügen: [document_item_reference data="my_product_attribute"]
    add_filter( 'storeabill_document_item_reference_data_shortcode_result', 'my_child_adjust_document_item_product_shortcode', 10, 4 );
    function my_child_adjust_document_item_product_shortcode( $result, $atts, $document, $shortcode_obj ) {
        
    if ( $atts['data'] !== 'my_product_attribute' ) {
          return $result;
        }else{

    $order_item = $shortcode_obj->get_document_item_reference();
    if(isset($order_item) AND $order_item != false ){
    $meta = $order_item->get_meta( 'ameliabooking' );
    }

    if(isset($meta) && isset($meta['labels']))
    {
    $info = $meta['labels'];
    $addional_product_meta.='<small>'.$info.'</small>.';

    //br und hr entfernen
    $amelia_info = str_replace(array("<br />","<hr>"), "", $addional_product_meta);
    //Termin-Info umformatieren
    $amelia_info2 = str_replace(array("Termin-Info"), "<b>Termin-Info:</b>", $amelia_info);
    }
    return $amelia_info2;
    }
    }


  • Ahmad Abdullahi Ahmad replied

    Help with the output result please

  • [deleted] replied

    Hi Ahmad, Michael,

    Thank you for sharing your solutions!

    If you have any other questions or concerns feel free to open a new ticket and we will gladly help out.