Лучший Ответ pholex315 , 10 April 2015 - 10:46
Сам все решил.
Добавил функцию:
/**
* Check is good availble for order
* @param $hash
* @return bool
*/
public function isAvail($hash)
{
$data = $this->getIndexData();
$mainHash = $this->_getHash();
if ($mainHash !== $hash)
{
foreach ($data as $variant)
{
if ($hash === $variant['hash'])
{
if ($variant['balance'] == 0)
{
return true;
}
if ($variant['balance'] == -1)
{
return false;
}
return true;
}
}
}
$mainBalance = $data[$this->_getHash()]['balance'];
if ($mainBalance == 0)
{
return true;
}
if ($mainBalance == -1)
{
return false;
}
return true;
}
и изменил немного ajaxAddToCart:
/**
* Ajax add to cart method
*/
public function ajaxAddToCart($quantity = 1, $params = array(), $hash = false)
{
$jbajax = $this->app->jbajax;
if (!$hash)
$hash = $this->_getHash(array(
'param1' => $params[1],
'param2' => $params[2],
'param3' => $params[3],
'description' => isset($params['desc']) ? $params['desc'] : '',
));
// echo $hash;
$quantity += $this->app->jbcart->getQuantityByHash($hash);
if ($this->isInStock($hash, $quantity))
{
$price = $this->_getPriceByHash($hash);
$item = $this->getItem();
$textParams = $this->_getFormatedParams($params);
$variations = $this->getIndexData();
if (isset($variations[$hash]) || (int) $this->config->get('adv_all_exists_show', 1))
{
$this->app->jbcart->addItem($item, array(
'hash' => $hash,
'sku' => $price['sku'],
'itemId' => $item->id,
'quantity' => (int) $quantity,
'price' => isset($price['total']) ? $price['total'] : '',
'currency' => $this->_getDefaultCurrency(),
'priceDesc' => isset($price['params']['description']) ? $price['params']['description'] : '',
'priceParams' => $textParams,
), true);
$this->app->jbajax->send(array(), true);
}
else
{
$this->app->jbajax->send(array('message' => JText::_('JBZOO_JBPRICE_ITEM_NOT_FOUND')), false);
}
}
else
//проверяем, какое сообщение выводить
{
if ($this->isAvail($hash))
{
$this->app->jbajax->send(array('message' => JText::_('JBZOO_JBPRICE_ITEM_NO_QUANTITY')), false);
}
else
{
$this->app->jbajax->send(array('message' => JText::_('JBZOO_JBPRICE_DILER')), false);
}
}
$jbajax->send(array('added' => 0, 'message' => JText::_('JBZOO_JBPRICE_NOT_AVAILABLE_MESSAGE')));
}
Перейти к сообщению


Тема закрыта








