Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinruscoe/1776ec2ccc8985e5ac75c5e5c61e1e1e to your computer and use it in GitHub Desktop.
Save kevinruscoe/1776ec2ccc8985e5ac75c5e5c61e1e1e to your computer and use it in GitHub Desktop.
protected function updateQuantityRelative($item, $key, $value){
if (preg_match('/\-/', $value) == 1) {
$value = floatval(str_replace('-', '', $value));
if (($item[$key] - $value) > 0) {
$item[$key] -= $value;
}
} elseif (preg_match('/\+/', $value) == 1) {
$item[$key] += floatval(str_replace('+', '', $value));
} else {
$item[$key] += floatval($value);
}
return $item;
}
protected function updateQuantityNotRelative($item, $key, $value)
{
$item[$key] = floatval($value);
return $item;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment