public static
setRevertPrice
(mixed $productId, mixed $bulkId, mixed $price, mixed $params)
public static function setRevertPrice($productId, $bulkId, $price, $params)
{
$newPrice = $price;
$db = Factory::getDBO();
$wheres = array();
$wheres[] = ' p.product_id = ' . (int) $productId;
$wheres[] = ' p.bulk_id = ' . (int) $bulkId;
$wheres[] = ' p.type = 2';
$q = 'SELECT p.current_price';
$q .= ' FROM #__phocacart_product_price_history AS p';
$q .= ' WHERE ' . implode(' AND ', $wheres);
$q .= ' ORDER BY p.id';
$q .= ' LIMIT 1';
$db->setQuery($q);
$newPrice = $db->loadResult();
if ($newPrice != $price) {
// Set new price
$query = 'UPDATE #__phocacart_products SET price = ' . $db->quote($newPrice) . ' WHERE id = ' . (int) $productId;
$db->setQuery($query);
$db->execute();
}
return $newPrice;
}