Displaying Shipping Total in Shopping Cart Widget.....

Posted by Community Admin on 05-Aug-2018 11:02

Displaying Shipping Total in Shopping Cart Widget.....

All Replies

Posted by Community Admin on 19-Jun-2013 00:00

Hi All,

I am a beginner of Sitefinity exploring new  things daily in this.

Here i am trying to waive off Shipping based on the Quantity . So i have created a Shipping method of Shipping method type Custom here i have set the Shipping price based on the Quantity.

This rule is getting affected in Check out. Is it Possible to imply this Shipping information based on quantity in Shopping Cart Widget??

Kindly let me know the Possible work around for this.

Thanks
Paramasivan.G

Posted by Community Admin on 20-Jun-2013 00:00

Hello Paramasivan,

Thanks for reaching out and I'd like to extend a welcome to the Sitefinity dev community!

We have a way of implementing what you are referring to, but first i wanted to ask a quick question. Basically the reason why shipping rates are displayed at the point they are is because we are not aware of the customer's address before they fill it in. And since shipping rates can vary by country/state/zip code, then we need to know the exact address before we calculate the price.

Therefore if you want to display items in the shopping cart we would have to:
- Have some sort of conventioin where we know that there is either a flatter rate(for example - we support shipping only for one country and the rates are flat by state)  or
- Ask for address before checkout - which could result into higher dropout rates potentially - people don't want to provide their address unless they have to. 
- Use geolication to determine the city/state programatically and show an approximation of the rate(if the geolocation was not correct - we can add a small note that this is where we think they are, but shipping rates may vary)
- Calculate just a base shipping rate based on some heuristic or assumption and then show a note stating something like "This rate does not apply for international shipping" or something like that.


Essentially all these can be done at the level of the shopping cart widget by adding a bit of code to this widget, but it depends which route you pick and how important the address consideration is for your business case.

Please let me know if any of the following make sense and if I can provide any more details on a specific scenario!

 
Regards,
Svetla
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 Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 20-Jun-2013 00:00

Hi Svetla,

Thanks for your valuable reply. The below are my requirement.
We have basic/constant shipping price for all the purchases that has to be visible and added to total price in cart page. Also the shipping price is not related to user's shipping address.
Along with that, one of the other requirement is - If user select more than 6 quantity then the shipping cost is free. If the quantity of purchase is less than 6 then we need to add a basic/constant shipping price to total purchase cost in cart section.

Hope you are clear in-terms of requirement. Please help me to implement this with cart widget available in sitefinity.

Thanks,
Paramasivan.G

Posted by Community Admin on 25-Jun-2013 00:00

Hi Paramasivan,

Thanks for your feedback on the use case!

You can practically add any information and logic to the shopping cart and this has an easy solution. A quick solution is this:

Add a label to the shopping cart's widget template from Design>Widget Templates. This can be anywhere, but it makes sense to add it where the totals are displayed:

<div class="sfTotalRowWrp">
<asp:Label ID="productTotalQuantity" runat="server" />
<asp:Label ID="subTotalLabel" runat="server" Text='<%$Resources:OrdersResources, SubtotalWithDiscounts %>' CssClass="sfTxtLbl" />: 
<div>
Estimated Total Shipping: <asp:Label ID="totalShippingLabel" runat="server" />
</div>

Now we are going to inherit the shopping cart and only display the expected price based on a flat calculation. You can actually get any control from a template if you override elements of ecommerce by using Container.GetControl. Here we are inheriting the shopping cart and modifying the IntiializeControls method as following.

public class CustomShoppingCart : ShoppingCart
   
       protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
       
           base.InitializeControls(container);
 
           //get the control that is responsible for displaying the total
           var ShippingControl = this.Container.GetControl<Label>("totalShippingLabel", true);
           var totalShipping = this.CalculateTotalShipping();
ShippingControl.Text = "$" + totalShipping;
       
 
       private object CalculateTotalShipping()
       
           var totalQuantity = CartOrder.Details.Sum(s => s.Quantity);
 
           if (totalQuantity > 6)
               return 0;
            
 
           else
           //just applying a flat rate of 0.5 dollars per pound
               return CartOrder.Weight * 0.5;
       
   

Now all that's left to do is to register the overridden shopping card in the toolbox and use it instead of the regular widget. Since it's inheirted it will behave exactly the same with the only difference that it will display shipping. 

Optionally you may want to update the actual total price to reflect the addition of the shipping, but I would add a different label below it stating: total with shipping or something like that .

Hope this helps!

 

Regards,
Svetla
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 Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 04-Jul-2013 00:00

Hi SVETLA,

Thanks very much for your consideration..

I tried following your instructions and added a Label as specified in the post in the templated and also added a class that inherits Shoppingcart and added the Code snippet provided. But i'm getting the following error..

A required control was not found in the template for
"~/SfCtrlPresentation/_SFCT_/b7086ef6d9f51bc85b04620443b1223dcff47f88/SimpleShopCart.ascx".
The control must be assignable from type
"System.Web.UI.WebControls.Label" and must have ID "totalShippingLabel".

Can you identify the problem and if so what is the workaround for this.

Thanks

Paramasivan.G

Posted by Community Admin on 05-Jul-2013 00:00

Hello Paramasivan,

 In your template SimpleShopCart.ascx add a label with that ID like so:

<asp:Label runat="sever" ID="totalShippingLabel"/>

Regards,
Patrick Dunn
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 Public Issue Tracking system and vote to affect the priority of the items

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

Dumb question, but how does this actually change the shipping and total amounts in the cart? Aren't you just showing some calculated values in labels? Or is this logic already implemented in the checkout widget?

This thread is closed