• Resolved Mimergt

    (@mimergt)


    hello, Please can you help me with this meta. I try a lot of ways to unserialize but nothing works.

    This is an example meta of a one order, comes form WooFood plugin.

    {
    “extra_options”: {
    “Meet”: [
    {
    “id”: 2672,
    “price”: “Q0.00”,
    “price_float”: 0,
    “category”: “carne favorita”,
    “name”: “Premium Blend”,
    “hide_prices”: false
    }
    ],
    “extra option”: [
    {
    “id”: 3211,
    “price”: “Q0.00”,
    “price_float”: 0,
    “category”: “tu complemento”,
    “name”: “Curly Fries”,
    “hide_prices”: false
    }
    ],
    “bebida”: [
    {
    “id”: 1684,
    “price”: “Q0.00”,
    “price_float”: 0,
    “category”: “tu bebida”,
    “name”: “Rosa de Jamaica”,
    “hide_prices”: false
    }
    ]
    },
    “extra_options_price”: 0,
    “original_price”: “55”
    }

    ON Specific i just need the “name” value.

    Tnks on advice and Regards.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @mimergt,

    Please can you help me with this meta. I try a lot of ways to unserialize but nothing works.

    This is actually JSON, so you can use a custom PHP function that utilizes the json_decode() function to export this data: https://www.wpallimport.com/documentation/export/pass-data-through-php-functions/.

    Here is an example function that you can modify as needed (it was only tested on the data you sent, and it returns a comma-delimited list of names):

    function my_output_names( $data ) {
    	if ( empty( $data ) ) return;
    	$data = json_decode( $data, 1 );
    	
    	if ( ! isset( $data['extra_options'] ) ) return;
    	if ( ! is_array( $data['extra_options'] ) ) return;
    	$return = array();
    	
    	foreach ( $data['extra_options'] as $option => $values ) {
    		if ( ! empty( $values ) ) {
    			$return[] = $values[0]['name'];
    		}
    	}
    	
    	if ( ! empty( $return ) ) {
    		return implode( ', ', $return );
    	}	
    }
    Plugin Author WP All Import

    (@wpallimport)

    Hi @mimergt,

    I’m going to mark this as resolved since we haven’t heard from you in a while. You can follow up in this thread if you still have questions.

    Anyone else, please open a new topic.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Userialize Custom Order Meta’ is closed to new replies.