Unexpected getRebate() value
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Unexpected getRebate() value
I'm trying to get the rebate value of the variant of a selection product (its value is 5.00 in mshop_price) with :
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)!
Code: Select all
$product->getPrice()->getRebate();
----
returned value : 0.00
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)!
Re: Unexpected getRebate() value
Is this the case after you've added the product to the basket or when does it occur?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Unexpected getRebate() value
Thank you a lot for your answer.
It happens indeed after the product is in the basket.
Ok I found this post, explaining everything !
topic847.html
Sorry for the inconvenience.
It happens indeed after the product is in the basket.
Ok I found this post, explaining everything !
topic847.html
Sorry for the inconvenience.
Re: Unexpected getRebate() value
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!
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!
Re: Unexpected getRebate() value
In which places you want to show the original rebate value?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Unexpected getRebate() value
In the user account "my orders" page.
Re: Unexpected getRebate() value
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.
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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Unexpected getRebate() value
I prefer the second option because indeed the rebate amount could change in the time. Thank you very much !
Re: Unexpected getRebate() value
Hello,
I am also facing the same problem, the original rebate value is not accessible in the basket /shop/basket.
I am looking at the mshop_order_base and planning to add an original_rebate database migration but I can't find the current order I'm making. Is the order stored in a session before its complete?
What is the correct way to get the rebate that the product was added to the cart with?
I am also facing the same problem, the original rebate value is not accessible in the basket /shop/basket.
I am looking at the mshop_order_base and planning to add an original_rebate database migration but I can't find the current order I'm making. Is the order stored in a session before its complete?
What is the correct way to get the rebate that the product was added to the cart with?
aimeos wrote: ↑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.
Re: Unexpected getRebate() value
Yes, it's stored in the mshop_order_basket table until the customer clicks on "Buy now" at the end of the checkout process.
1.) Create a migration file:
https://aimeos.org/docs/latest/infrastr ... ing-tables
2.) Overwrite this method in the order product item:
https://github.com/aimeos/aimeos-core/b ... #L741-L773
3.) Overwrite this method in the order product manager to use the new item:
https://github.com/aimeos/aimeos-core/b ... 1091-L1103
4.) Configure your new order product manager so it will be used:
Code: Select all
mshop/order/manager/base/product/name = '<my new manager name>'
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star