• Resolved anoukaveresch

    (@anoukaveresch)


    Hi,

    I’m having trouble unserializing the data from the postnl plugin (https://nl.wordpress.org/plugins/woo-postnl/).
    I want to get the delivery date. I can get all the delivery options, through the dropdown (https://imgur.com/X3zgENH), but it’s serialized data

    a:4:{s:4:”date”;s:10:”2019-11-19″;s:4:”time”;a:1:{i:0;a:7:{s:5:”start”;s:8:”13:15:00″;s:3:”end”;s:8:”15:45:00″;s:12:”collect_date”;N;s:5:”price”;a:2:{s:8:”currency”;s:3:”EUR”;s:6:”amount”;i:0;}s:13:”price_comment”;s:8:”standard”;s:7:”comment”;s:0:””;s:4:”type”;i:2;}}s:9:”signature”;i:0;s:14:”only_recipient”;i:0;}

    How can I get just the date (in this case ‘2019-11-19’) from this data?

    Thanks in advance!

    • This topic was modified 4 years, 4 months ago by anoukaveresch.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author algol.plus

    (@algolplus)

    hi

    please, open section “Misc Settings” and add following PHP code.
    thanks, Alex

    add_filter('woe_get_order_value__postnl_delivery_options', function ($value, $order, $fieldname) {
    	return $value['date'];
    }, 10, 3);
    Thread Starter anoukaveresch

    (@anoukaveresch)

    This didn’t work, as I get the wrong date..

    <Delivery_date>2019-11-29 23:23</Delivery_date>

    I get the date of today instead of the date that is stored in the unserialized array (2019-11-19).
    I’ve checked the preview as well as the exported version, but in both versions the date is wrong..

    • This reply was modified 4 years, 4 months ago by anoukaveresch.
    • This reply was modified 4 years, 4 months ago by anoukaveresch. Reason: sollution didn't worked as expected
    Thread Starter anoukaveresch

    (@anoukaveresch)

    deleted message

    • This reply was modified 4 years, 4 months ago by anoukaveresch.
    Plugin Author algol.plus

    (@algolplus)

    have this code solved your problem ?

    Thread Starter anoukaveresch

    (@anoukaveresch)

    No.. I’ll send you the mysql of the postnl plugin via the helpdesk right now

    Plugin Author algol.plus

    (@algolplus)

    correct code
    `add_filter(‘woe_get_order_value__postnl_delivery_options’, function ($value, $order, $fieldname) {
    $data = maybe_unserialize($value);
    if( is_array($data) )
    $value = $data[‘date’];
    return $value;
    }, 10, 3);

    Thread Starter anoukaveresch

    (@anoukaveresch)

    Thank you so much! It works perfectly.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Unserialize data from PostNL plugin’ is closed to new replies.