Page 1 of 1

OnePageCheckout Canada Message

Posted: Mon Feb 23, 2009 8:18 am
by William_firefold
We would like to have a small message that will appear on onepagecheckout whenever a user selects Canada as their country.
It only needs to be a hidden label, I just need help on where to put the Text.Visible=true; and the decision code.
I guess it would have to check for canada on page load as well because of user preferences.

Can anyone help me out with this?

Re: OnePageCheckout Canada Message

Posted: Mon Feb 23, 2009 9:58 am
by mazhar
You can the code in ContinueButton_Click method's very end and it would be something like

Code: Select all

foreach (BasketShipment bs in Token.Instance.User.Basket.Shipments)
                if (bs.Address.CountryCode == "US")
                    MessageLabel.Visible = true;

Re: OnePageCheckout Canada Message

Posted: Mon Feb 23, 2009 12:10 pm
by William_firefold
Thanks mazhar, this was a great help.

Complete code for anyone who wants it.

In the ascx.cs:

Code: Select all

foreach (BasketShipment bs in Token.Instance.User.Basket.Shipments)
if (bs.Address.CountryCode == "CA")
   canadaMessage.Visible = true;
And in the .ascx:

Code: Select all

<asp:PlaceHolder ID="canadaMessage" runat="server" EnableViewState="false" Visible="false">
<span style="color:#e00;">Attention Canadian Cutomers</span>: UPS Charges a duty fee on all shipments. All USPS shipments go thru Canada Duty free.
<a href="http://www.ups.com/content/ca/en/shipping/cost/zones/customs_clearance.html" style="color:#ff0;"> Click Here</a> for more details from UPS.
</asp:PlaceHolder>

Re: OnePageCheckout Canada Message

Posted: Tue May 05, 2009 3:21 pm
by AlanW
I want an international message to appear for all countries EXCEPT United States.
How would this change the code for the ascx.cs? I don't know the operator for "NOT EQUAL"
if (bs.Address.CountryCode ???NOT EQUAL??? "US")

I noticed when experimenting with the code, I am losing OnePageCheckout and the site defaults to ShipAddress.aspx. Is this because I broke the code for onepagecheckout.ascx?

Regards,
Alan

Re: OnePageCheckout Canada Message

Posted: Wed May 06, 2009 2:00 am
by mazhar
try

Code: Select all

if (bs.Address.CountryCode != "US")


Re: OnePageCheckout Canada Message

Posted: Wed May 06, 2009 8:17 am
by AlanW
Thank you Mazhar, that part is now working.

I'm still breaking the code for OnePageCheckout when I apply custom/OnePageCheckout.

I can load the custom OnePageCheckout by directly typing /Checkout/Default.aspx , but if I click through checkout links from basket page, the store defaults to multiple step checkout.

The loaded OnePageCheckout page looks fine when it loads....but it won't load automatically.

Here is the section from the .ascx

Code: Select all

<h2 class="sectionHeader">Shipping Method</h2>
                                    <asp:PlaceHolder ID="MultipleShipmentsMessage" runat="server" EnableViewState="false" Visible="false">
                                        <br />Your order contains items that must be sent in more than one shipment.  View the order details at the bottom of this page for the contents of each shipment.<br /><br />
                                    </asp:PlaceHolder>
<asp:PlaceHolder ID="InternationalMessage" runat="server" EnableViewState="false" Visible="false">
<font face="Arial" size="2"><b>Attention International Cutomers:</b> </font>
<font color="#FF0000"><b><span lang="en-us"><font face="Arial" size="2">S</font></span></b></font><font face="Arial" size="2"><span lang="en-us"><font color="#FF0000"><b>hipping charges are 
estimated shipping charges.</b></font> International orders usually require an adjustment to calculate actual shipping charges.<br>
You will receive an email with actual shipping charges. You must respond to this message and authorize the adjusted shipping charges for the order to continue to be processed.<br>
<br>
International customers are responsible for payment of any applicable duties at the time an order arrives at its destination.</span> <font color="#ff0000">
<b>Any applicable duty and/or taxes will be billed separately</b> </font>to the 
package recipient after going through your country's customs.<br>
<br>
<b><a href="http://www.practicerange.com/help_desk.aspx#International Shipping"><font color="#FF0000">Click Here</font></a></b> for more details.</font><br><br>
</asp:PlaceHolder>
                                    <asp:Repeater ID="ShipmentList" runat="server" OnItemDataBound="ShipmentList_ItemDataBound" EnableViewState="false">
                                        <ItemTemplate>
                                            <asp:PlaceHolder ID="ShipmentCounter" runat="server" Visible='<%# (ShipmentCount > 1) %>' EnableViewState="false"><b>Shipment <%# (Container.ItemIndex + 1) %>:&nbsp; </b></asp:PlaceHolder>
                                            <asp:Label ID="ShipMethodListLabel" runat="server" Visible='<%# (ShipmentCount == 1) %>' EnableViewState="false" Text="Select Method:" SkinID="FieldHeader"></asp:Label>&nbsp;
                                            <asp:DropDownList ID="ShipMethodList" runat="server" DataTextField="Name" DataValueField="ShipMethodId" EnableViewState="false" AutoPostBack="true"></asp:DropDownList><br />
                                            <asp:PlaceHolder ID="ShipMessagePanel" runat="server" Visible='<%# EnableShipMessage %>'>
                                                <asp:Label ID="ShipMessageLabel" runat="server" Text="Delivery Instructions?" SkinID="FieldHeader"></asp:Label>&nbsp;
                                                <asp:TextBox ID="ShipMessage" runat="server" Text="" MaxLength="200" Width="200px"></asp:TextBox>
                                            </asp:PlaceHolder>
Here's the section from ascx.cs

Code: Select all

protected void ContinueButton_Click(object sender, EventArgs e)
    {
        //Page.Validate();
        if (Page.IsValid)
        {
            if (this.EditBillingAddress)
            {
                if (!SaveBillingAddress()) return;
            }
            if (this.EditShippingAddress && this.HasShippableItems && UseShippingAddress.Checked)
            {
                if (!SaveShippingAddress()) return;
            }
            this.EditBillingAddress = false;
            this.EditShippingAddress = false;
            TogglePanels();
            RecalculateBasket();
        }
foreach (BasketShipment bs in Token.Instance.User.Basket.Shipments)
if (bs.Address.CountryCode != "US")
   InternationalMessage.Visible = true;
    }
Can you tell where I'm breaking the code?

Regards,
Alan

Re: OnePageCheckout Canada Message

Posted: Wed May 06, 2009 8:49 am
by mazhar
Take backup of your actual OnePageCheckout and then modify the ConLib/OnePageCheckout files instead of moving them under custom folder.

Re: OnePageCheckout Canada Message

Posted: Wed May 06, 2009 12:36 pm
by AlanW
Thank you Mazhar...that got OnePageCheckout working perfectly.