Hallo,
ich nutze die Version 2.1.9.
Habe das Problem aber mittlerweile gelöst über drei zusätzliche Funktionen in der Checkout.php
ich liste hier mal den Code auf:
PHP-Code:
public function getStockUpdateInfo($arrItem){
$arrStock = array();
foreach($arrItem as $a){
$arrHelp = array(
'id' => $a->product_id,
'quantity' => $a->quantity
);
array_push($arrStock, $arrHelp);
}
return $arrStock;
}
public function updateProductStock($arrItem){
$arrItem = $this->getStockUpdateInfo($arrItem);
foreach($arrItem as $a){
$this->Database->prepare("UPDATE tl_iso_product
SET stock = stock - ?
WHERE id = ?")->execute($a['quantity'], $a['id']);
$this->checkStock($a['id']);
}
}
public function checkStock($id){
$stock = $this->Database->prepare("SELECT sku, name, stock FROM tl_iso_product WHERE id = ?")->execute($id)->fetchAllAssoc();
if($stock[0]['stock'] == 0){
$to = "email@mail.com";
$subject = 'blub!';
$from = 'From: blubblub';
$message = "Achtung! \nDas Produkt ".$stock[0]['name']." (Sku: ".$stock[0]['sku'].") ist ausverkauft. Bitte füllen Sie das Lager wieder auf.";
mail($to, $subject, uft8_decode($message), $from);
}
}
Die letzte Funktion gibt noch eine Warnmail an den Shopinhaber heraus falls das Produkt ausverkauft ist.
der Funktionsaufruf erfolgt folgendermaßen ab Zeile 138 in der Checkout.php
PHP-Code:
if ($objOrder->checkout() && $objOrder->complete()) {
$this->updateProductStock($objOrder->getItems());
\Controller::redirect(\Haste\Util\Url::addQueryString('uid=' . $objOrder->uniqid, $this->orderCompleteJumpTo));
}
Lesezeichen