Hallo zusammen,
ich möchte in einer Galerie die Möglichkeit haben Artikel über einen Ajax Aufruf in den Warenkorb hinzuzufügen. Dafür habe ich folgende zwei relevante Codestellen:
JavaScript/JQuery
jQuery.ajax({
url: ‘/shopUpdate/index.php?cl=photogalleryOxViewConfig&fnc=addToCart’,
type: ‘POST’,
data: {
amount: $(’#numbPrint_’+id).val(),
digital: $(’#digCopy_’+id).is(’:checked’),
id: id
},
success: function(response) {
console.log(“Succeed”);
console.log(response);
},
error: function(response) {
console.log(“Error”);
console.log(response);
},
complete: function(response) {
}
});
PHP Modul
<?php
$root = realpath($_SERVER[“DOCUMENT_ROOT”]) . “”;
include_once “$root/inc/UniteGallery.php”;
class photogalleryOxViewConfig extends photogalleryOxViewConfig_parent {
public function getGallery() {
$galleries = array(
array("Abenddokumentation","abi18-doku",""),
array("Setfotos", "abi18-sets", "")
);
return UniteGallery::create($galleries, "fotografie");
//return "Test123";
}
public function addToCart($amount, $digital, $id) {
$digitalAmount=0;
print_r("Working");
$config = $this->getConfig();
$session = $config->getSession();
$basket = $session->getBasket();
$content = $basket->getContents();
$info = array("/img.png");
if($digital) {
$digitalAmount=1;
}
$basket->addToBasket("dc188b0d914bb3993f1911156144e5a6",$amount, null, $info);
$basket->addToBasket("dbc63500fda8b45cc4ae1f7999ad4c11",$digitalAmount, null, $info);
return "done";
}
}
Diese ist in der metadata.php registriert:
'extend' => array(
'oxviewconfig' => 'photogallery/controllers/photogalleryoxviewconfig'
),
Wenn ich nun den AJAX Aufruf des Javascript ausführe bekomme ich aber leider immer eine 302 zurück mit der ich auf die Startseite weitergeleitet werde. Kann mir da jemand behilflich sein?
HTTP Verlauf:
302 POST /shopUpdate/index.php?cl=photogalleryOxViewConfig&fnc=addToCart
200 GET index.php?force_sid=138ed1cc11b6953b799a9ccb49e75ec9&cl=start&redirected=1
Vielen Dank schonmal! Wenn ihr noch mehr Infos braucht, gebt Bescheid.