PO Box and UPS

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
derekz
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 38
Joined: Mon Nov 03, 2008 3:13 pm

PO Box and UPS

Post by derekz » Wed Feb 10, 2010 2:24 pm

I'm trying to restrict my customers from shipping to a PO Box. I've set up a regular expression in a custom validator for my Address1 text box on my checkout page. Unfortunately, AbleCommerce is not validating it correctly. I have the same regular expression in custom C# code and it is working perfectly.

Has anyone had any luck restricting PO Boxes?

If I can't restrict, I would at least like to limit the shipping methods based on the PO Box in the Address1 text box. Can that be done?

Thanks,
Derek

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: PO Box and UPS

Post by mazhar » Thu Feb 11, 2010 7:27 am

I guess you need to setup shipping zones. Create shipping zones for different regions and then mark shipping methods available to their respective zones. After this change customer belonging to one shipping zone will see shipping methods only available to that zone.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: PO Box and UPS

Post by jmestep » Thu Feb 11, 2010 8:13 am

We have filtered out shipping methods on the checkout page based on the customer having a PO Box in the address. You have to do it in the ShipmentList_ItemDataBound method before the
localQuotes.Add(new LocalShipRateQuote(quote.ShipMethodId, methodName, formattedRate));
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

derekz
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 38
Joined: Mon Nov 03, 2008 3:13 pm

Re: PO Box and UPS

Post by derekz » Thu Feb 11, 2010 12:33 pm

I managed to get this working with Regular Expressions and the Custom Validator

OnePageCheckout.aspx

Code: Select all

<asp:TextBox ID="BillToAddress1" runat="server" EnableViewState="false" Width="200px" MaxLength="100" ValidationGroup="OPC"></asp:TextBox> 
<asp:RequiredFieldValidator ID="BillToAddress1Required" runat="server"
    ErrorMessage="Billing address is required." Display="None" Text="*" ControlToValidate="BillToAddress1"
    EnableViewState="false" SetFocusOnError="false" ValidationGroup="OPC"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="BillToAddress1CustomValidator" runat="server"
    ControlToValidate="BillToAddress1" EnableViewState="false" Display="None" ValidationGroup="OPC"
    ErrorMessage="PO Boxes are not allowed." OnServerValidate="ValidateAddress" />
OnePageCheckout.aspx.cs

Code: Select all

    public void ValidateAddress(object sender, ServerValidateEventArgs args)
    {
        Regex reg = new Regex(@"[p|P][\s]*[o|O][\s]*[b|B][\s]*[o|O][\s]*[x|X][\s]*[a-zA-Z0-9]*|\b[P|p]+(OST|ost|o|O)?\.?\s*[O|o|0]+(ffice|FFICE)?\.?\s*[B|b][O|o|0]?[X|x]+\.?\s+[#]?(\d+)*(\D+)*\b");
        if (reg.IsMatch(args.Value))
        {
            args.IsValid = false;
        }
        else
        {
            args.IsValid = true;
        }
    }

Post Reply