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
PO Box and UPS
Re: PO Box and UPS
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.
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: PO Box and UPS
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));
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
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
Re: PO Box and UPS
I managed to get this working with Regular Expressions and the Custom Validator
OnePageCheckout.aspx
OnePageCheckout.aspx.cs
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" />
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;
}
}