HomeHome Product Discus... Product Discus...RazorCartRazorCartCheckout price update customization issue.Checkout price update customization issue.
Previous
 
Next
New Post
1/9/2019 1:05 PM
 
First, RazorCart out of the box works fine. The breakage is caused by some of the customizations we are making for this particular (B2B) instance of RazorCart.

We are creating a B2B site and each customer can have one of two prices. The prices are per item and table-driven, there is no mathematical formula that allows us to go from the MSRP to the correct price in any instance.

I use the OnAddToCartComplete override to update the ShoppingCart record with the correct UnitPrice and it shows up properly in the Mini-cart and the Checkout page.

When the Mini-Cart plus or minus is clicked, or "Update Quantities" is clicked on the Checkout page, the price reverts back to MSRP (or the product sale price if there is one). It looks like when it recalculates the price it goes back to the product record for the unit cost. I wish it would use the UnitCost field in the shopping cart record and am wondering if perhaps it should.

The Update Quantities button on the checkout page runs to Smith-proprietary code so I can't get any insight itno how I might fix the Update Quantities issue (for us in this project. Again, it works fine and properly in stock RazorCart and in our other RazorCart stores). First, is there any event I can override to replace the Update Quantities functionality (and the add/subtract in the mini-cart)? Or do you have any thoughts on how I can get this running right with what I have available to me?

Thank you,
G









 
New Post
1/15/2019 3:00 PM
 
Hi George,

We have many features that could effect the item price after you added it to the shopping cart, for instance the discount by quantity which will re-calculate the price on quantity change, also discount by roles and this would also recalculate in cart items if you add another item (that adds user roles) to the shopping cart.
To handle this you can override the method "RazorCart.Core.ActionPipeline.CalculateSubTotal" which should run after item update complete, loop through context.CartList and commit your changes then call base.Execute to run the core method CalculateSubTotal.

protected override PipelineAction[] ListCalculatorPipelineActions()
{
    return new PipelineAction[]
    {
        new MyCalculateSubTotal(),
        new CalculateOrderDiscount(),
        new CalculateCouponDiscount(),
        new CalculateShipping(),
        new CalculateHandling(),
        new CalculateTax(),
        new CalculateFinal()
    };
}
class MyCalculateSubTotal : CalculateSubTotal
{
    public override PipelineAction Clone() { return new MyCalculateSubTotal(); }
    public override int ActionID() { return 1; }
    public override string ActionName() { return "Custom.MyCalculateSubTotal()"; }
    public override bool IsDisposable() { return false; }
    public override ActionEndResult Execute(VATContext context)
    {
        foreach (var item in context.CartList)
        {
            item.UnitCost = 1.99M;
            RazorCart.Service.Data.Repository.Instance.UpdateShoppingCartItem(
                PersistBehavior.Machine,
                System.Web.HttpContext.Current.Request.Cookies["_RazorCart-GUID"].Value,
                DotNetNuke.Entities.Portals.PortalSettings.Current.UserInfo.Username,
                item.CartID, item.Quantity, item.UnitCost, context.StoreID,
                DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId);
        }
        return base.Execute(context);
    }
}
Regards,
Wael
 
New Post
1/17/2019 12:57 PM
 
Thank you. This worked beautifully and I learned things from your code example. Problem solved, much appreciated!

G
 
New Post
1/17/2019 12:57 PM
 
Thank you. This worked beautifully and I learned things from your code example. Problem solved, much appreciated!

G
 
New Post
1/17/2019 2:45 PM
 
You're welcome George, just one more thing, it's necessary that your custom method is inherited from the base/core method, I edited my reply which I made a mistake to inherit from CalculateTax instead of CalculateSubTotal.
 
Previous
 
Next
HomeHome Product Discus... Product Discus...RazorCartRazorCartCheckout price update customization issue.Checkout price update customization issue.