Sitefinity 7 setting product price with OptionDetails.TotalD

Posted by Community Admin on 04-Aug-2018 20:40

Sitefinity 7 setting product price with OptionDetails.TotalDeltaPrice

All Replies

Posted by Community Admin on 08-May-2014 00:00

I have a section of my website that allows users to pay on their current statements. In order to allow this I have a "Statement" product in the eCommerce module that has its price set to 0 and does not track inventory. When a user checks out I modify the OptionDetails.TotalDeltaPrice to set the price of the statement product to the balance of their current statement. The code I am using I got from the assistance provided on a previous thread: www.sitefinity.com/.../change-product-price-during-checkout-

This code worked great on 6.3 but now I would like to move to 7 and in my testing this method of setting the price no longer works and my product is added to the cart with a cost of 0. Does anyone know how to accomplish this in sf 7?

Posted by Community Admin on 08-May-2014 00:00

I did a bunch of digging and managed to track down the root of the problem, but I haven't been able to come up with a solution. When I started looking at some of the changes made in 7.0 i noticed that there is a method in the OrdersManager class called UpdateProductInformationInCartDetails. This method is called by the shopping cart widget and the checkout widget and updates all of the product information for products in the cart. In sitefinity 6.3 it actually updated all of the information except the DeltaPrice, but in 7 a call to a new method UpdateCartDetailDeltaPrice is called which also updates the delta price or sets it to 0 if there are no product variations. So when i use the code i mentioned previously to pass in a custom price for the product this method wipes it out. It feels like this may be a bug fix in 7 and the code I was using previously was actually just exploiting the bug. 

 This section of my website is absolutely critical and I can not move to a new version of sitefinity if i can not maintain this functionality. So is there an appropriate way in sf 7 to set a custom price on a product when adding it to the cart? I am trying to avoid creating custom shopping cart and checkout widgets to bypass the problem. 

Posted by Community Admin on 09-May-2014 00:00

I also need to add dynamic price to a "placeholder" ecom product thru code and plan to utilize the default cart and checkout widgets. I will also be creating detail and order custom fields to pass along if any of that logic has changed since 6.2.

Posted by Community Admin on 12-May-2014 00:00

This is the reply i got from Telerik

 "The problem comes from the fact that in Sitefinity 7.0 was made significant code refactoring making not possible your case.

I have consulted also with our developers from Sitefinity eCommerce who explained that an internal method in OrdersManager (UpdateProductInformationInCartDetails) re-calculates all cart details and total price for the shopping cart. It is called in ShoppingCart widget, ShoppingCartSummary and CheckoutWorker on the first step of the checkout process. In other words the three widgets should be re-written to skip this call and call a custom one.

I am sorry for the inconvenience caused."

I ended up overriding the InitializeControls method in the ShoppingCart and Checkout wedgets. In those methods i called a helper method to extract any custom prices from the deltaprice on all items in the cart then called base.InitializeControls. Then I called a second helper method to reapply all the custom pricing and recalculate the cart total. Everything seems to work great. I also ended up having to modify the layout for the orders list as it was pulling the product price from the eCommerce product instead of the order. 

Posted by Community Admin on 13-May-2014 00:00

Hello David,

Thank you for the shared information with the community. In addition, there is idea to be handled that scenario as a Custom or Donation product type which will allows to change the price during the checkout process. There is a feature request logged in the Feedback portal where it could be voted. Most voted items are developed with higher priority.

Regards,
Svetoslav Manchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 13-May-2014 00:00

Thanks for sharing that, i have voted for it. That is something I hadn't thought about. I could add an item to my Types of Products for custom pricing then in my overridden widgets only prevent the update of pricing on those product types. That would be cleaner than my current solution which still uses delta pricing and could cause issues if i started using product variations.

Posted by Community Admin on 19-Aug-2014 00:00

How would I go about overriding the InitializeControls method on shopping cart etc?  I tried inheriting from the Telerik.Sitefinity.Modules.Ecommerce.Orders.Web.UI.ShoppingCart.ShoppingCart class, but then my widget said "not allowed here as it does not extend System.Web.UI.UserControl"

Posted by Community Admin on 19-Aug-2014 00:00

Hi Ben,

I have successfully inherited Shopping Cart and override InitializeControles method by creating a class and register it by Sitefinity Thunder: Below is the code used in my case under folders ~/Examples/Widgets:

using Telerik.Sitefinity.Modules.Ecommerce.Orders.Web.UI;
 
namespace SitefinityWebApp.Examples.Widgets
    public class CustomShoppingCart : ShoppingCart
    
        protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
        
            base.InitializeControls(container);
        
    

Regards,
Svetoslav Manchev
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 19-Aug-2014 00:00

Excellent!  

Turns out I wasn't registering my Widget correctly in the toolbox.

Thanks.

This thread is closed