I used the price table to offer discounts on quantities that exceed a certain amount, for instance price X for 100-1000, and Y for 1000-unlimited, then if I added 1 item, it would wrongly assign the price of the last item or of the price row with unlimited defined in it. To tackle the issue, in the method 'commerce_price_table_get_amount_qty' in 'commerce_price_table.module', I replaced:
// Handle the unlimited qty.
foreach ($items as $item) {
if ($item['max_qty'] == -1) {
return $item;
}
}
// We fallback to the higher one if no match was found.
return end($items);
with
// Handle the unlimited qty.
foreach ($items as $item) {
if ($quantity >= $item['min_qty'] && $item['max_qty'] == -1) {
return $item;
}
}
// We fallback to the higher one if no match was found.
return false;
But this should also take into account if the actual/base price is disabled, which it doesn't for now. I would have probably made validation checks to see if quantities covered 1-unlimited if base price was disabled beforehand.
Comments
Comment #1
Cybso CreditAttribution: Cybso commentedTry to add an 1..n item with the default price. commerce_price_table's behaviour on incomplete intervals is some kind of undefined. You may try the patch in http://drupal.org/node/1897824#comment-6983682, which gives you a setting that adds an error if the user enters gapping or overlapping items.