}
sub best_price {
- min_by { $_->price } grep { $_->price > 0 } grep { $_ } map { $_->best_price } $_[0]->all_price_sources;
+ min_by { $_->price } max_by { $_->priority } grep { $_->price > 0 } grep { $_ } map { $_->best_price } $_[0]->all_price_sources;
}
sub best_discount {
- max_by { $_->discount } grep { $_->discount } grep { $_ } map { $_->best_discount } $_[0]->all_price_sources;
+ max_by { $_->discount } max_by { $_->priority } grep { $_->discount } grep { $_ } map { $_->best_discount } $_[0]->all_price_sources;
}
sub empty_price {
use parent 'SL::DB::Object';
use Rose::Object::MakeMethods::Generic (
scalar => [ qw(discount description spec price_source invalid missing) ],
+ 'scalar --get_set_init' => [ qw(priority) ],
);
require SL::DB::Helper::Attr;
"source: @{[ $_[0]->source ]}, discount: @{[ $_[0]->discount ]}, description: @{[ $_[0]->description ]}"
}
+sub init_priority {
+ 3
+}
+
1;
__END__
A ref to the creating algorithm.
+=item C<priority>
+
+OPTIONAL. Discounts may supply a numerical priority. Higher will trump over lower, even when
+supplying lower discounts. Defaults to 3 (as in middle of 1-5).
+
=item C<missing>
OPTIONAL. Both indicator and localized message that the discount with this spec
use parent 'SL::DB::Object';
use Rose::Object::MakeMethods::Generic (
scalar => [ qw(price description spec price_source invalid missing) ],
+ 'scalar --get_set_init' => [ qw(priority) ],
);
require SL::DB::Helper::Attr;
"source: @{[ $_[0]->source ]}, price: @{[ $_[0]->price ]}, description: @{[ $_[0]->description ]}"
}
+sub init_priority {
+ 3
+}
+
1;
__END__
A ref to the creating algorithm.
+=item C<priority>
+
+OPTIONAL. Prices may supply a numerical priority. Higher will trump over lower, even when
+supplying higher prices. Defaults to 3 (as in middle of 1-5).
+
=item C<missing>
OPTIONAL. Both indicator and localized message that the price with this spec
price => $self->price_for_rule($rule),
spec => $rule->id,
description => $rule->name,
+ priority => $rule->priority,
price_source => $self,
(invalid => t8('This Price Rule is no longer valid'))x!!$rule->obsolete,
)
discount => $rule->discount / 100,
spec => $rule->id,
description => $rule->name,
+ priority => $rule->priority,
price_source => $self,
(invalid => t8('This Price Rule is no longer valid'))x!!$rule->obsolete,
)