/**
  * Function: updatecart updates the cart and also calculates the tax and shipping charges
  *
  * @return  json
  *
  * @since  1.0.0
  */
 public function update_cart_item()
 {
     $comquick2cartHelper = new comquick2cartHelper();
     $input = JFactory::getApplication()->input;
     $post = $input->post;
     $data = $post->get('formData', '', 'STRING');
     $cart_item_id = $post->get('cart_item_id', '', 'INT');
     $item_id = $post->get('item_id', '', 'INT');
     // Get parsed form data
     parse_str($post->get('formData', '', 'STRING'), $formData);
     // Load cart model
     /*$item = Array
     					(
     						[id] => 17
     						[parent] => com_quick2cart
     						[item_id] => 8 if item_id present then no need of id and parent fields
     						[count] => 1
     						[options] => 24,23,22,19
     					)
     					<pre>$userdata = Array
     									(
     										[23] => Array
     											(
     												[itemattributeoption_id] => 23
     												[type] => Textbox
     												[value] => qqq
     											)
     
     										[24] => Array
     											(
     												[itemattributeoption_id] => 24
     												[type] => Textbox
     												[value] => www
     											)
     
     									)
     					* */
     $itemFromattedDet = array();
     $itemFromattedDet['item_id'] = $item_id;
     $userdata = array();
     if (!empty($formData['cartDetail']) && !empty($cart_item_id)) {
         $newItemDetails = $formData['cartDetail'][$cart_item_id];
         $itemFromattedDet['count'] = $newItemDetails['cart_count'];
         $itemFromattedDet['options'] = '';
         // If not empty attribute details
         if (!empty($newItemDetails['attrDetail'])) {
             $attrDetail = $newItemDetails['attrDetail'];
             foreach ($attrDetail as $key => $attr) {
                 if ($attr['type'] == 'Textbox' && !empty($attr['value'])) {
                     $userkey = $attr['itemattributeoption_id'];
                     $userdata[$userkey] = $attr;
                     $itemFromattedDet['options'] .= $attr['itemattributeoption_id'] . ',';
                 } else {
                     $itemFromattedDet['options'] .= $attr['value'] . ',';
                 }
             }
         }
     }
     $path = JPATH_SITE . "/components/com_quick2cart/models/cart.php";
     $comquick2cartHelper->loadqtcClass($path, 'Quick2cartModelcart');
     $Quick2cartModelcart = new Quick2cartModelcart();
     // Remove last comma
     if (!empty($itemFromattedDet['options'])) {
         $tempArray = explode(',', $itemFromattedDet['options']);
         $tempArray = array_filter($tempArray, "strlen");
         $itemFromattedDet['options'] = implode(',', $tempArray);
     }
     // Get formated product details  (internal)
     $prod_details = $Quick2cartModelcart->getProd($itemFromattedDet);
     // If option present
     if (!empty($prod_details[1])) {
         // Add user field detail to options
         $AttrOptions = $prod_details[1];
         $prod_details[1] = $comquick2cartHelper->AddUserFieldDetail($AttrOptions, $userdata);
     }
     // Update the cart
     $result = $Quick2cartModelcart->putCartitem('', $prod_details, $cart_item_id);
     // Validate Result. If added successfully.
     if (is_numeric($result) && $result == 1) {
         $msg['status'] = true;
         $msg['successCode'] = 1;
         //$msg['message'] = JText::sprintf('COM_QUICK2CART_COMPACT_MSG', $prod_details[0]['name'], $item_count);
     } else {
         $msg['status'] = false;
         $msg['successCode'] = 0;
         $msg['message'] = $result;
     }
     echo json_encode($msg);
     jexit();
 }