+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Sitefinity 7 setting product price with OptionDetails.TotalDeltaPrice

Sitefinity 7 setting product price with OptionDetails.TotalDeltaPrice

9 posts, 1 answered
  1. David
    David avatar
    29 posts
    Registered:
    28 Apr 2009
    08 May 2014
    Link to this post

    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: http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/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?

  2. David
    David avatar
    29 posts
    Registered:
    28 Apr 2009
    08 May 2014 in reply to David
    Link to this post

    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. 

  3. James B.
    James B. avatar
    24 posts
    Registered:
    17 Jan 2011
    09 May 2014
    Link to this post

    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.

  4. David
    David avatar
    29 posts
    Registered:
    28 Apr 2009
    12 May 2014
    Link to this post

    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. 

    Answered
  5. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    07 Dec 2016
    13 May 2014
    Link to this post
    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
     
  6. David
    David avatar
    29 posts
    Registered:
    28 Apr 2009
    13 May 2014 in reply to Svetoslav Manchev
    Link to this post

    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.

  7. ben
    ben avatar
    2 posts
    Registered:
    19 Jul 2010
    19 Aug 2014 in reply to David
    Link to this post

    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"

  8. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    07 Dec 2016
    19 Aug 2014
    Link to this post
    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
     
  9. ben
    ben avatar
    2 posts
    Registered:
    19 Jul 2010
    19 Aug 2014 in reply to Svetoslav Manchev
    Link to this post

    Excellent!  

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

    Thanks.

9 posts, 1 answered