Displaying Shipping Total in Shopping Cart Widget.....
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
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
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
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>
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;
Regards,
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
Hello Paramasivan,
In your template SimpleShopCart.ascx add a label with that ID like so:
<
asp:Label
runat
=
"sever"
ID
=
"totalShippingLabel"
/>
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?