I added a checkbox into add to cart form. I would like to pass this input data to order details table. I found this thread in the forum but no luck. Everything looks OK but when order is placed, data is not saving.
http://forum.cs-cart.com/topic/41264-how-to-attach-extra-information-to-order-item/
Selection_003.png
Use hooks in the fn_add_product_to_cart function (app/functions/fn.cart.php) to save required data in the extra array
function fn_my_addon_post_add_to_cart(&$product_data, &$cart, &$auth, &$update) {
$behalf = $_REQUEST['behalf'];
foreach ($_SESSION['cart']['products'] as $key => $value) {
$_SESSION['cart']['products'][$key]['extra']['behalf'] = $behalf;
}
}
function fn_my_addon_create_order_details(&$order_id, &$cart, &$order_details, &$extra) {
if (!empty($cart['products'])) {
foreach ((array)$cart['products'] as $k => $v) {
if (empty($v['product_id'])) {
continue;
}
$extra['behalf'] = $v['extra']['behalf'];
$order_details['extra'] = serialize($extra);
}
}
}
I tried couple things. This is the non working code.
Our engineers can perform necessary modifications on the paid basis, if you are interested.