Forum

Thread tagged as: Question, Problem

parse perch2_shop_log logData

Hi, what is the best way to turn the logData into an array?

example snippet of logData "mc_gross=0.01&protection_eligibility=Eligible&address_status=confirmed&item_number1=1"

and access the variables like: logData['mc_gross']

and returns 0.01

tony

Tony Monckton

Tony Monckton 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Where is that from?

Hi, worked it out. orders_details_pre.php code below..

I need to put the options (sizes, colours), with the order list.

tony

$HTML       = $API->get('HTML');
$DB         = PerchDB::fetch();
$Orders     = new PerchShop_Orders($API);
$Order      = $Orders->find($_GET['id']);

$orderTxnID = $Order->orderTxnID();

$sql = "SELECT logData FROM perch2_shop_log WHERE logTransaction = '".$orderTxnID."'"; 
$gShopLog = $DB->get_rows($sql);

$a = explode('&',$gShopLog[0]["logData"]);
if (!empty($a))
{
    foreach ($a as $result) {
        $b = explode('=', $result);
        $shopLogArray[$b[0]] = $b[1];
    }
}

$message = false;

$Form = $API->get('Form', 'dispatch');

if ($Form->submitted()) {
    $Order->mark_as_dispatched();
    $message = $HTML->success_message('The order has been marked as dispatched.');
}