public static
setRevertOriginalPrice
(mixed $productId, mixed $bulkId, mixed $priceOriginal, mixed $params)
public static function setRevertOriginalPrice($productId, $bulkId, $priceOriginal, $params)
{
$newPrice = $priceOriginal;
$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_original';
$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 != $priceOriginal) {
// Set new price
$query = 'UPDATE #__phocacart_products SET price_original = ' . $db->quote($newPrice) . ' WHERE id = ' . (int) $productId;
$db->setQuery($query);
$db->execute();
}
return $newPrice;
}