Display Shopping Cart Item Based On IP Address

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
dave@givemore.com
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Jan 13, 2009 11:11 am

Display Shopping Cart Item Based On IP Address

Post by dave@givemore.com » Tue Feb 09, 2010 10:31 am

I want to display a shopping cart shipping estimator based on ip address. Basically, only our in-house team should see this feature, but I don't want to require them to login to see it.

How would I do this? Here is the code that spits out the shipping estimator.

Code: Select all

<%-- <label class="cartlabels">Estimate shipping: </label> --%>
<uc1:BasketShippingEstimate ID="BasketShippingEstimate1" runat="server" />
Or, is there a better way to only display content to our shipping team without them having to login?

Thanks!
Give More Media
http://www.givemore.com/

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

Re: Display Shopping Cart Item Based On IP Address

Post by mazhar » Tue Feb 09, 2010 11:03 am

I guess you should set the shipping zones for those regions where you can ship your orders. This will not allow shipping to persons who have address not falling within configured zones.

Secondly you could use the IP banning feature to not allow customers from specific IP addresses.

Lastly if you are looking for some show/hide shipping estimator feature based on IP then it could be something like

Code: Select all

    
protected void Page_Load(object sender, EventArgs e)
    {
            string clientIPAddress = Request.ServerVariables["REMOTE_ADDR"];
            this.Visible = IsValidIP(clientIPAddress);
    }

    protected bool IsValidIP(string ipAddress)
    {
        bool isValid = true;

        //YOUR CUSTOM IP VALIDATION CODE HERE FOR EXAMPLE
        isValid = (ipAddress != "---.---.---.---");

        return isValid;
    }
Where these changes will be made to ConLib/BasketShippingEstimate.cs file. But I think that setting shipping zones will be a better option. The reason is that you don't need to make any code change. No need to worry about future upgrades becuase those are configurations and you will make no code change.

dave@givemore.com
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Jan 13, 2009 11:11 am

Re: Display Shopping Cart Item Based On IP Address

Post by dave@givemore.com » Mon Feb 15, 2010 11:47 am

Mazhar, you solution was very helpful! I was able to remove the estimate shipping functionality. Thanks for the quick and helpful response.
Give More Media
http://www.givemore.com/

Post Reply