Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > I have a bit of a problem customizing the display of product prices View modes: 
User avatar
Member
Member
magnus-tenk - 6/15/2012 8:51:44 PM
   
I have a bit of a problem customizing the display of product prices
As the picture shows I have added a radiogroup to the ShoppingCartMiniPreview in the top part of the page. There I can select if the prices should be shown with or without tax.

I have tried to achieve this by adding a custom field in User/ShoppingCart-tables to store the user preferences. Then I have a custom SKUInfoProvider that overrides the GetSKUPriceInternal that check for this preference.

The problem is that I can't find a way to get the product prices to update on the radiobuttons change event.

When OnCheckChange fires. The Sub-Page containing the products will be rendered before I get to save the new setting (in ShoppingCartMiniPreview), so the prices will not update correctly. I would really appreciate some input/guidance here.

/Magnus

User image

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 6/18/2012 6:25:14 AM
   
RE:I have a bit of a problem customizing the display of product prices
Hi,

1. You could read data from your custom shopping cart field. Then page reload to the same page will be probably need.

You can change method GetSKUFormattedPrice to take two arguments, i.e. GetSKUFormattedPrice(bool discounts, bool taxes)

The method you can find here: file:///<preject>\App_Code\CMSModules\Ecommerce\EcommerceFunctions.cs

The taxes value you can read from your custom table

2. Alternative option is to read data from a query parameter which you will add to the page url when selection is changed. Then you can use QueryHelper class to read data.

3. Another option is to store value in session. Then you could use SessionHelper class to read/store data.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
magnus-tenk - 6/18/2012 8:31:11 AM
   
RE:I have a bit of a problem customizing the display of product prices
Thank you for your input.

What I ended up doing was letting the CartPreview sit in an update panel. Then on the radiobutton change events I registered a Scripthelper that performed a client side reload. It might not be the most elegant of solutions, but it's simple and seem to work :)

/Magnus

User avatar
Member
Member
magnus-tenk - 6/25/2012 5:04:23 PM
   
RE:I have a bit of a problem customizing the display of product prices
Hi again :) the first "reload-fix" had unfortunate side effects so we are back on square one. I have extended the ShoppingCart with a field and that works nice. It's the Kentico Portal Page Lifecycle I have some problems with.

I do not want to implement some essentially unnecessary but "better" reload technique. I have dug deeper into the code and it seem to me that there is something not right about how the (Corporate Sites) Product List Transformation get executed.

I have overridden GetSKUPriceInternal and modified it to take my bool priceWithTax into consideration. When I debug the code it's clear to me that this method is getting called Twice. Apparently the Transformation code in the Products List get run twice, but the Values only the values from the First execution are used (the wrong ones)

The "pseudo"-trace of me checking the unchecked <asp:checkbox> will thus be the following:

1: ShoppingCartMiniPreview Client side withpriceWithTax.checked = true ;
2: Product List Transformation call to GetSKUPriceInternal -> returns price WITHOUT tax
3: ShoppingCartMiniPreview Processing the checked event saving priceWithTax = true;
4: Product List Transformation repeat call to GetSKUPriceInternal -> returns price WITH tax
5: The transformation renders prices from the first execution and discards the second correct values.

I really want to make the code in the ShoppingCartMiniPreview (embedded in the Master page) to run BEFORE the Transformation code (that get used) of the Product List or any other web part embedded in the subcontent page.

/Magnus

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 7/6/2012 9:51:02 PM
   
RE:I have a bit of a problem customizing the display of product prices
For readers of this thread:

Magnus-tenk managed to go around the problem for now by moving code from the Transformation to the product web part and by removing the update panel from the Corporate Themes ShoppingCartMiniPreview.

Best regards,
Ivana Tomanickova