function uc_ajax_cart_handler_kit in Ubercart AJAX Cart 6
1 call to uc_ajax_cart_handler_kit()
File
- ./
uc_ajax_cart.module, line 525
Code
function uc_ajax_cart_handler_kit() {
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Datum in der Vergangenheit
$formID = $_REQUEST['form_id'];
$nid = $_REQUEST['pnid'];
$formValues = $_REQUEST;
$formValues['nid'] = $nid;
$result = array();
if (isset($_REQUEST['uc-ajax-cart-callback'])) {
$formID = $_REQUEST['uc-ajax-cart-callback'];
}
$products = $_REQUEST['products'];
if (isset($products) && is_array($products)) {
foreach ($products as $key => $val) {
$tResult = array_merge(module_invoke_all('add_to_cart', $val['nid'], $val['qty'], $val));
if (is_array($tResult)) {
foreach ($tResult as $rRes) {
$result[] = $rRes;
}
}
}
}
if (count($result) > 0) {
uc_ajax_cart_create_ajax_msg($formID, $result);
exit;
}
if (is_numeric($nid) && $nid > 0) {
$node = node_load($nid);
if (is_object($node) && $node->type == 'product_kit') {
if (!isset($_REQUEST['qty']) && is_numeric($_REQUEST['qty'])) {
$qty = 1;
}
else {
$qty = (int) $_REQUEST['qty'];
}
$result = uc_product_kit_add_to_cart($nid, $qty, $val, false, false);
}
}
if (true == variable_get('uc_ajax_cart_del_cache', false)) {
uc_cart_get_contents(null, 'rebuild');
}
$output = "";
if (true == variable_get('uc_ajax_cart_rebuild', false)) {
uc_cart_get_contents(null, 'rebuild');
}
$cart = uc_cart_block('view');
$output = $cart['content'];
$data = array(
'success' => true,
'form_id' => $formID,
'content' => $output,
);
print drupal_to_js($data);
exit;
}