Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#6338 by sixbynine
05 Jul 2018, 11:28
I'm trying to get the rebate value of the variant of a selection product (its value is 5.00 in mshop_price) with :

Code: Select all$product->getPrice()->getRebate();
----
returned value : 0.00


Here's a part of the dump of my $product Object. Curiously the rebate is 0.00 (the returned value) in Aimeos\MShop\Price\Item\Standard but 5.00 (the expected value) in Aimeos\MShop\Common\Item\Base.

Is this a bug or do i miss something?

["values":"Aimeos\MShop\Price\Item\Standard":private]=> array(20) {
["price.id"]=> string(3) "213"
["price.siteid"]=> string(1) "1"
["price.typeid"]=> string(1) "3"
["price.currencyid"]=> string(3) "EUR"
["price.domain"]=> string(7) "product"
["price.label"]=> string(0) ""
["price.quantity"]=> string(1) "1"
["price.value"]=> string(4) "3.00"
["price.costs"]=> string(4) "1.00"
["price.rebate"]=> string(4) "0.00"
["price.taxrate"]=> string(4) "6.00"
["price.status"]=> string(1) "1"
["price.mtime"]=> string(19) "2018-06-27 18:40:02"
["price.editor"]=> string(22) "user"
["price.ctime"]=> string(19) "2018-05-26 00:20:50"
["price.type"]=> string(7) "default"
["price.typename"]=> string(8) "Standard"
["currencyid"]=> string(3) "EUR"
["price.taxflag"]=> int(0)
["price.tax"]=> string(6) "0.1800"
}

["bdata":"Aimeos\MShop\Common\Item\Base":private]=> array(19) {
["price.id"]=> string(3) "213"
["price.siteid"]=> string(1) "1"
["price.typeid"]=> string(1) "3"
["price.currencyid"]=> string(3) "EUR"
["price.domain"]=> string(7) "product"
["price.label"]=> string(0) ""
["price.quantity"]=> string(1) "1"
["price.value"]=> string(4) "3.00"
["price.costs"]=> string(4) "1.00"
["price.rebate"]=> string(4) "5.00"
["price.taxrate"]=> string(4) "6.00"
["price.status"]=> string(1) "1"
["price.mtime"]=> string(19) "2018-06-27 18:40:02"
["price.editor"]=> string(22) "user"
["price.ctime"]=> string(19) "2018-05-26 00:20:50"
["price.type"]=> string(7) "default"
["price.typename"]=> string(8) "Standard"
["currencyid"]=> string(3) "EUR"
["price.taxflag"]=> int(0)
}

Thank you a lot (as always)!
#6345 by aimeos
05 Jul 2018, 16:33
Is this the case after you've added the product to the basket or when does it occur?
#6361 by sixbynine
06 Jul 2018, 09:14
So, I read everything about this case.

And I used the ->getPrice()->getRawValues() to get the original rebate.

But I would also like to keep and store the original price rebate value and if I well understand, the field "rebate" in mshop_order table after the order is inserted is used to store the coupons rebate.

What is the best way to store also the original rebate (total only) in the table?
I guess I probably need to add a new field originalrebate in the mshop_order table?

Where do i need to add/write it in the checkout process?

Thank you a lot in advance!
#6393 by aimeos
09 Jul 2018, 09:08
If you need it only there, the easiest option would be to write a decorator for the account history component that walks over the ordered products of an order and fetch the products with their prices to calculate the rebate amount dynamically. Disadvantage: The rebate amount changes depending on the rebate in the product.

A durable solution would be to calculate the rebate in the order base manager (fetching the products with prices) and storing the rebate amount in a new column in the mshop_order_base table. Then you have to extend the order base item to return that value.