Using product attributes as multiplier faults product standard price

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
Hello!

I've changed additionalCharge in "PriceCalculationService.cs" to " * " instead of " + " as it's easier to maintain different prices with percentages. This works great in general except for one issue. When viewing products in categories the price shows up as 0. When entering a specific product the prices are shown as they should with the pre-selected attribute having a price of "1".

So basically. A product has the standard price of lets say 10. The pre-selected attribute has a value of 1. The rendered price results in a value of 10 for the specific product. All fine and dandy. How come it renders the price as 0 when viewing the product in categories?

If any1 can point me in the direction of the code where the products are displayed in categories I'll be forever grateful. I've already searched CatalogControllers.cs without luck.

Thanks // Johan
8 years ago
Hello Johan

currently the additional charge of product will be added to price with "+" and as you said you have changed it to "*" multiplier to make it as percentage then i think it will work fine on backend.

but when you choose attribute on product detail page it will still try to use "+" from javascript to display final price on detail page.
so i think you need to find that javascript in product\ProductAttribute.cshtml file as all things is calculated on that end.

if possible can you share the product link where you are getting this issue ??
8 years ago
Hello Vipul!

I'm currently only testing this out in development. I will start searching for an answer in the area you described! My initial thoughts on your comment is still.

If the javascript is making the calculations for the front-end and it is using "+" as you say. Shouldn't the price then turn up as 10+1 = 11 instead of 0?

Thanks for the reply either way! :)
8 years ago
m
8 years ago
Rojiva wrote:


If the javascript is making the calculations for the front-end and it is using "+" as you say. Shouldn't the price then turn up as 10+1 = 11 instead of 0?


yes i have same question but i forgot to mention it.
it should but somethings is doing wrong on javascript level b'coz of but i think as you have changed the logic on priceCalculation it affect on javascript level as well.

may be you can check the javascript console to check if anythings is crashing
8 years ago
I'm stuck at the moment!

_ProductBox.cshtml gets both old-price and price from ProductOverviewModel.cs who picks it up from DB. There are no calcualtions whatsoever what I can see. On the back-end all the calculations works fine. Have I found some kind of bug? = )
8 years ago
No its normal behaviour on productbox.cshtml it will just display current & old price.
b'coz on productbox there is not any selection of attributes so i think it will not calculate attribute price and show on front end.
8 years ago
Yes, that is the same assumption that I made. So how come that changing additionalCharge calculation from + to * makes the current price from_ProductBox end up as zero?

I can't see the connection and yet it occurs. That's why I thought that maybe it is a bug?
If I set the product to have an old price it shows correctly either way. Where is the connection between additionalCharge from back-end to frontend? The only logical connection both have is the DB. Thought it should not be incorporating any calculations.
It feels like a bug to me :P

// Johan
8 years ago
I got some kind of response now when I tried to use divide "/" instead of multiply "*". When entering a category which includes products the PriceCalculationService.cs somehow fires. Breaking at " price = price / additionalCharge;" Telling me that It cannot divide by zero.

When entering the Productview +, - and * calculations works. Now to the big question. Why and more importantly where?

// Johan
8 years ago
I've tested it some more and I'm starting to realise that this is not working as I suspected in my last reply. So ignore that post.

Thanks
// Johan
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.