Page 1 of 1

how do I show the shipping rate with tax included?

Posted: Sun May 10, 2009 7:41 am
by ozlighting
Hi,

I need to show the shipping rate (fixed rate of $15) with the tax included (gst requirements in Australia). Because this is a taxable item the rate is set to $13.64 in the Admin->Configure->Shipping Methods screen. This ensures that at checkout, the total tax amount displayed includes the tax for the shipping.

However, during the checkout process, on ~/Checkout/ShipMethod.aspx the shipping rate is displayed as "Fixed rate ($13.64)". I need to show this as "Fixed rate ($15.00)".

I have had a look in the ShipMethodPage.ascx and ShipMethodPage.ascx.cs files and found the bit of code that displays the shipping rate but I don't know how to change it to show the tax inclusive amount. The piece of code is:

Code: Select all

<asp:Label ID="ShipMethodRate" runat="server" Text='<%#Eval("TotalRate"," ({0:ulc})") %>' Visible='<%#((LSDecimal)Eval("TotalRate") > 0)%>' />
I can't figure out where "TotalRate" is derived from - is it a fixed variable in the CommerceBuilder.Shipping api? is there any documentation that can help with the other available fields. I'm new to .Net and not a full time programmer, so any help would be greatly appreciated.

Cheers,

Lance

Re: how do I show the shipping rate with tax included?

Posted: Sun May 10, 2009 8:11 pm
by ozlighting
ok, I downloaded the free version of Visual Web Developer Express and opened the file CommerceBuilder.dll from the bin directory. I found a class called ShipRateQuote in the CommerceBuilder.Shipping namespace (not sure if the terminology is correct). there is a variable called "TotalRate" and one called "Name" which is obviously where the values are coming from in the code snippet posted above.

So my question is, what is the correct syntax to take this value and multiply it by 1.1 (our GST tax rate is fixed at 10%). If I can do this then I can get the result I'm looking for.

Cheers,

Lance

Re: how do I show the shipping rate with tax included?

Posted: Mon May 11, 2009 3:47 am
by mazhar
Add following method to ShipMethodPage.ascx.cs file

Code: Select all

protected string GetGSTIncluded(Object dataItem) 
    {
        LSDecimal result;
        ShipRateQuote shipRateQuote = (ShipRateQuote)dataItem;
        result = shipRateQuote.TotalRate * 1.1;
        return result.ToString("ulc");
    }
and now update

Code: Select all

<asp:Label ID="ShipMethodRate" runat="server" Text='<%#Eval("TotalRate"," ({0:ulc})") %>' Visible='<%#((LSDecimal)Eval("TotalRate") > 0)%>' />
to look like

Code: Select all

<asp:Label ID="ShipMethodRate" runat="server" Text='<%#GetGSTIncluded(Container.DataItem) %>' Visible='<%#((LSDecimal)Eval("TotalRate") > 0)%>' />

Re: how do I show the shipping rate with tax included?

Posted: Tue May 12, 2009 7:15 pm
by ozlighting
Hi Mazhar,

thanks for that, however I'm getting this error msg
Operator '*' cannot be applied to operands of type 'CommerceBuilder.Common.LSDecimal' and 'double'

Re: how do I show the shipping rate with tax included?

Posted: Tue May 12, 2009 7:54 pm
by ozlighting
Hi Mazhar,

I figured it out - just needed to explicitly convert the number 1.1 to a decimal:
protected string GetGSTIncluded(Object dataItem)
{
LSDecimal result;
LSDecimal shippingtaxrate = (decimal)1.1;
ShipRateQuote shipRateQuote = (ShipRateQuote)dataItem;
result = shipRateQuote.TotalRate * shippingtaxrate;
return result.ToString("ulc");
}

Thanks so much for your help - I really appreciate it.