interchange / Dancer-Plugin-Interchange6

Dancer Plugin for Interchange6 shop machine
4 stars 1 forks source link

Cart item price assignment goes away #32

Closed murwiz closed 10 years ago

murwiz commented 10 years ago

This seems to be a bug:

In Dancer::Plugin::Interchange6::Cart::BUILD, when a cart-product is retrieved from the database, the "price" field is ignored:

price            => $record->product->price,

Thus, if you have a custom price assigned (e.g., due to a discount), even though it gets stored in the table, the internal representation of the cart has the original products.price value.

In my case, I am repeating the custom calculation:

price            => $self->calculate_price($record->product, undef, $record->quantity),

as it seems safest not to rely on the stored price at all -- for instance, the quantity might have been changed elsewhere, or the user may have changed identities (logging in, or changing a coupon in force, etc.). Alternatively you could take the less paranoid approach and:

price            => $record->price,
murwiz commented 10 years ago

Ignore this. I'm working with a local copy of Cart and got confused.