1

I am working on a site that sells books. There is one book that should be discounted for students of an affiliated college program. However only active students in the class can have access to the pricing. The desired scenario is:

  • website someclass.edu has a page someclass.edu/getbookcheap
  • this page is limited to current students only (behind a log in)
  • that page has a URL to a landing page examplebookstore.com/getbookcheap
  • that page will show the reduced price for the book
  • users who try to access example bookstore.com/getbookcheap from anywhere but someclass.edu/getbookcheap will get redirected to the page for the book where it is listed at full price

my questions:

  • what is the best way to implement this using CartTHrob (shopping cart used)? I could use a coupon code, but those are global and not item/page specific. We could list the book twice, the second being only listed on this special landing page.
  • are there any EECMS methods of limiting traffic based on referer? Would we have to use htaccess?

It must work if the buyer is not logged in or logged in. Limiting access based on member group is not an option at this point.

1

What you are after are conditional statements based on IF someone is entitled to discounts or not.

Would the discount remain the same overall or vary? eg. 50% off for all. Or 10%, 20% and 30% off in variations.

You'd use one page per book title and load the page using EE's conditional statements for displaying information based on user group. You can read more about conditional statements in the Docs here:

http://ellislab.com/expressionengine/user-guide/templates/globals/conditionals.html

In a book title's template page, you would declare conditions that if the logged in user group is "Student" then display this pricing only. If else, then display full retail price. This way a visitor who is not registered or logged in is still able to access the page and view pricing.

As an example, if you had two types of students (fulltime and casual) and their user group id's were 1 and 2 then you would use this code within the template:

{if in_group('1|2')}
 Discount student price
 {if:else}
 Retail Price
{/if} 

If the student is logged out they will see the full retail pricing as anyone else will. The price listed using this will be passed in through the form to Cart Throb based on what is displayed with this method. This same conditional if:else statement can also allow you to display information on any page if the user is logged in. If they are logged in and on the front page you could use the statement to advise of a discount promotion or any information specific to that user group.

You can discount the price on the page using PHP which will then be passed through the form in to the cart. This method allows you to control the pricing on a page rather than on the final order confirmation page.

Consider that if you look at most book stores, they apply discount on order confirmation pages. This allows coupon codes to be added to the sale. This could allow a student to obtain a further discount on a book. Secondary discounts are an option to boost sales during festive times.

If discount prices vary then you would still display the correct pricing using the above conditional statements but would need to declare in a custom field in the channel entry of each book using either -

  • the exact discount eg. custom field - {stdiscount_off} allowing control over book discount per channel entry and display using the if:else or
  • create tier levels of applied discounts custom field - {stdiscount_off_1}, {stdiscount_off_2}, {stdiscount_off_3} and display based on user group identification in the conditional.

If you wanted to have a page that is solely for students (for eg. './studentbooks') then you could use a conditional at the top of your page template to redirect them to another page that is for full retail pricing ('./books') like this:

{if logged_out}
 {redirect='books/'} 
{/if}

But this increases the number of pages you are handling by having separate pages for users. Not the best practice approach to use.

I guess you first have to let the client decide for their business website if they wish to "force" and "apply" a discount for a user too.

3
  • I can't use member groups.
    – Doug
    Sep 4 '13 at 18:26
  • If you can't use member groups or use EE to identify a visitor's status, the only way would be to limit access through .htaccess rules which may indirectly disallow people. I have done something similar in the past to exclude/redirect visitors but have found it too risky as people can use a VPN or Tor browser to visit the site and possibly be directed incorrectly via the rules set. Sep 6 '13 at 4:58
  • There is a great book written on using htaccess with extensive examples, www.htaccessbook.com You'll find some ideas about redirection in there. Sep 6 '13 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.