You are here

function uc_cart_ajax_handler in Ubercart AJAX Cart 5

1 string reference to 'uc_cart_ajax_handler'
uc_ajax_cart_menu in ./uc_ajax_cart.module

File

./uc_ajax_cart.module, line 146

Code

function uc_cart_ajax_handler() {
  $formID = $_REQUEST['form_id'];
  $nid = str_replace('uc_product_add_to_cart_form_', '', $_REQUEST['form_id']);
  $formValues = $_REQUEST;
  $formValues['nid'] = $nid;
  if (is_numeric($nid) && $nid > 0) {
    $node = node_load($nid);
    if (!is_object($node)) {
      return;
    }
    if (is_object($node) && uc_product_is_product($node)) {
      $qty = $_REQUEST['qty'];
      uc_cart_add_item($nid, $qty, module_invoke_all('add_to_cart_data', $formValues), null, false, false);
    }
  }
  $output = "";
  $output .= theme('uc_cart_block_content');
  $data = array(
    'form_id' => $formID,
    'content' => $output,
  );
  print json_encode($data);
}