2

We're writing a reporting API and for the sake of speed have been using custom views and pulling the data with the query tag. It's all going quite well, save for one thing.. parsing the modifiers tag.

I've parsed the base64 below using php parsed on template output.. how do I convert it into some sort of html or usable info? (JSON Array?)

{exp:query backspace="1" sql="SELECT * FROM exp_store_orders LEFT JOIN exp_store_order_items...

    <?php
    $str = '{modifiers}';
    echo base64_decode($str);
    ?>

but that leaves me with an object

2

In Store 1.x, the modifiers array is stored as a base64 encoded, serialized PHP array. To decode it, you need to use the following:

$modifiers = unserialize(base64_decode($str));

In Store 2, the modifiers array is simply stored as JSON. This makes life much easier. To decode it into a PHP array, simply use:

$modifiers = json_decode($str, true);
0

If you happen to be working with a db that has both, parsing php on output will allow you to make a mixed report work in either case. (Apologies for terrible php)

{exp:query..

"item_qty": "{item_qty}",
"modifiers":
<?php
$str = '{modifiers}';
if ($str[0]!="Y")
    {echo $str;}
else
    {
        $str2 =  unserialize(base64_decode($str));
        $str3 = json_encode($str2);
        echo $str3;
    }
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.