• Resolved befla.net

    (@beflanet)


    Hi.

    Thanks for this great plugin. Can you provide a snippet for to get the first (oldest) Order Note – Content, please? Thank you very much.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor bartjaskulski

    (@bartj)

    Hi @beflanet!

    How would you like to use this? We’ve already have event Order – Note Added which provides access to order note content and author. With the help of filters, I guess you would be able to target only the original note (if retrieving the first one is really necessary).

    Best regards,
    Bartek

    Thread Starter befla.net

    (@beflanet)

    Hi @bartj

    The first note of each order contains the ID of the order which I want to output in emails.
    I can see find my ID (from a POS) in the database in the table posts as a post excerpt, in the postmeta as an array (meta_key = _op_order, meta_value = note) and in the table comments. I think the best option will be the postmeta but honestly I don´t know how to write the snippet for an array.

    • This reply was modified 7 months, 2 weeks ago by befla.net.
    Plugin Contributor bartjaskulski

    (@bartj)

    Hi @beflanet

    Is it something that placeholder {{ order.meta }} can handle? If it’s stored in postmeta table related to the order, I guess it would be possible to use {{ order.meta | key:’_op_order’ }} to get the value.

    Let me know if this helps.

    Best regards,
    Bartek

    Thread Starter befla.net

    (@beflanet)

    Hi.

    Thank you very much for your replay. With {{ order.meta | key: ‘_op_order’ }} I´m just getting the output “Array”.

    Plugin Contributor bartjaskulski

    (@bartj)

    Hi @beflanet!

    I see. In such case it would be the best to write a custom placeholder yourself which will be able to get a value from array returned in _op_order meta value.

    You can look up how to create placeholders in our documentation: https://docs.shopmagic.app/article/174-adding-custom-placeholders

    Thread Starter befla.net

    (@beflanet)

    Hi @bartj .

    Thank you very much for your help. If I create a custom placeholder like

    public function value( array $parameters ) {
    		return $this->is_order_provided() ? $this->get_order()->_op_order : '';
    	}

    I will not get the meta_value “note” of the meta_key “_op_order”.

    Plugin Contributor bartjaskulski

    (@bartj)

    Hi @beflanet!

    Sorry for the late response.

    For what you suggested, data in “_op_order” is an array, so you have to do two following things – firstly call to retrieve actual meta value (not dynamic property, as you’ve tried with $this->get_order()->_op_order), then get the value from array.
    I assume that you should create method body similar to:

    
    public function value( array $parmeters ) {
      return $this->is_order_provided() ? $this->get_order()->get_meta('_op_order')['note'] : '';
    }
    

    This may not be fully functioning, and you have to tailor it to your needs basing on your knowledge.

    Best regards,
    Bartek

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Order Note – Content’ is closed to new replies.