Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 5 of 5

Thread: Is it possible to offer discounts based on Email server or domain?

  1. #1
    omairkha is offline Member
    Join Date
    Aug 2011
    Posts
    89

    Question Is it possible to offer discounts based on Email server or domain?

    I've seen a few sites offering automatic discounts if users are registered using *@something.edu email address. I was wondering if its possible to do something similar with ASPDNSF?

    Thanks

    Using MS 9.1.0.1

  2. #2
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    Default

    Not done this before, but I would imagine one way to achieve this would be through customer levels and automatically assigning them those levels when they register. To perform this automatically I would put a trigger on the customer table to detect a registration, match their domain and update their customerlevelid.
    http://www.esedirect.co.uk
    --------------------------------------------------------------------------
    Using MS 9.2.0.0 with the following customisations:

    Lightbox/Fancybox enlarged images;
    Auto-suggest searchbox;
    Extra product information shown only to our IP Address (such as supplier info, costs, etc.);
    Failed transactions emailed via trigger;
    Custom app to show basket contents when customer online;
    Orders pushed through to accounting systems.

    All the above without source!

  3. #3
    omairkha is offline Member
    Join Date
    Aug 2011
    Posts
    89

    Question

    Hi esedirect,

    Thanks for your suggestion. I was also thinking that customer levels are probably the way to go but didn't know how a customer would be automatically added. My experience with SQL is very basic... I'll try to look up SQL Triggers. Would I need access to full source code to do this or is this something that can be accomplished without access to the full code?

  4. #4
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    Default

    No you don't need source code. The beauty of this suggestion is that it works on the database and not through .Net code. Some people find triggers confusing, but this is quit a simple solution so shouldn't be a problem.

    Code:
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TRIGGER [dbo].[tr_Customer] ON [dbo].[Customer]
    WITH EXECUTE AS CALLER
    AFTER INSERT, UPDATE
    AS
    BEGIN
    	-- SET NOCOUNT ON added to prevent extra result sets from
    	-- interfering with SELECT statements.
    	SET NOCOUNT ON;
    	
    	-- Do something if the customer actually registers
    	IF UPDATE(IsRegistered)
    	BEGIN
    		-- your code here
    		UPDATE Customer
    		SET CustomerLevelID=x
    		FROM inserted AS i
    		WHERE [Customer].[CustomerID] = [i].[CustomerID]
    		AND [i].[IsRegistered] = 1
    		AND [i].[Email] LIKE '%.edu'
    	END
    END
    This trigger will work on customer records only when they are being inserted/updated, that's the "AFTER INSERT, UPDATE" clause. And since there is the "IF UPDATE(IsRegistered)" test, it only acts on the customer record when IsRegistered is being changed.

    I've given an example of what you might want within test, which will need to be enhanced by yourself and thoroughly tested, for .edu and non-.edu customers alike.
    http://www.esedirect.co.uk
    --------------------------------------------------------------------------
    Using MS 9.2.0.0 with the following customisations:

    Lightbox/Fancybox enlarged images;
    Auto-suggest searchbox;
    Extra product information shown only to our IP Address (such as supplier info, costs, etc.);
    Failed transactions emailed via trigger;
    Custom app to show basket contents when customer online;
    Orders pushed through to accounting systems.

    All the above without source!

  5. #5
    omairkha is offline Member
    Join Date
    Aug 2011
    Posts
    89

    Default

    Great! Thanks for all the help! I'll try it out.