function fn_exim_orders_set_extra($ids, $data) { $data = YAML_Parser::unserialize($data); if (is_array($data)) { $data = serialize($data); $insert = array('extra' => $data); db_query("UPDATE ?:order_details SET ?u WHERE order_id = ?i AND item_id = ?i", $insert, $ids['order_id'], $ids['item_id']); } return true; }
function fn_exim_set_extra_fields($data, $user_id, $lang_code) { $lang_code = 'EN'; $data = YAML_Parser::unserialize($data); if (is_array($data) && !empty($data)) { foreach ($data as $type => $_data) { foreach ($_data as $field => $value) { // Check if field is exist $field_id = db_get_field("SELECT object_id FROM ?:profile_field_descriptions WHERE description = ?s AND object_type = 'F' LIMIT 1", $field); if (!empty($field_id)) { $update = array('object_id' => $type == 'user' ? $user_id : db_get_field("SELECT profile_id FROM ?:user_profiles WHERE user_id = ?i LIMIT 1", $user_id), 'object_type' => $type == 'user' ? 'U' : 'P', 'field_id' => $field_id, 'value' => $value); db_query('REPLACE INTO ?:profile_fields_data ?e', $update); } } } return true; } return false; }
function fn_exim_orders_set_extra_fields($data, $order_id, $lang_code = CART_LANGUAGE) { $data = YAML_Parser::unserialize($data); if (!empty($data) && is_array($data)) { foreach ($data as $type => $_data) { foreach ($_data as $field => $value) { // Check if field is exist if ($type == 'billing' || $type == 'shipping') { $section = strtoupper($type[0]); $field_id = db_get_field("SELECT object_id FROM ?:profile_field_descriptions LEFT JOIN ?:profile_fields ON ?:profile_fields.field_id = ?:profile_field_descriptions.object_id WHERE description = ?s AND lang_code = ?s AND ?:profile_fields.section = ?s AND object_type = 'F' LIMIT 1", $field, $lang_code, $section); } else { $field_id = db_get_field("SELECT object_id FROM ?:profile_field_descriptions WHERE description = ?s AND object_type = 'F' AND lang_code = ?s LIMIT 1", $field, $lang_code); } if (!empty($field_id)) { $update = array('object_id' => $order_id, 'object_type' => 'O', 'field_id' => $field_id, 'value' => $value); db_query('REPLACE INTO ?:profile_fields_data ?e', $update); } } } return true; } return false; }
/** * Smarty plugin * ------------------------------------------------------------- * Type: modifier<br> * Name: yaml_unserialize<br> * Purpose: converts yaml string to array * Example: {$a|yaml_unserialize} * ------------------------------------------------------------- */ function smarty_modifier_yaml_unserialize($data) { fn_init_yaml(); return YAML_Parser::unserialize("{" . $data . "}"); }
function _serialize($array) { $result = array(); $int = false; if (is_array($array)) { foreach ($array as $k => $v) { if (is_int($k)) { $int = false; } if (!empty($v)) { if (is_array($v)) { $v = YAML_Parser::_serialize($v); $result[] = $k . ': ' . $v; } else { $result[] = $int == true ? $v : $k . ': "' . $v . '"'; } } } } return ($int ? '[' : '{') . implode(', ', $result) . ($int ? ']' : '}'); }