Time limited special offer

Discussion in 'Setting-up protection' started by halmaclean, Feb 7, 2018.

  1. halmaclean

    halmaclean aMember Pro Customer

    Aug 30, 2013
    Hi - I am trying to offer a time limited special offer product that is available only when another product has expired for a user.

    For example, they have a subscription for a year, but it does not renew - I want to reveal an offer to a product in the shop, but make it visible to that user for only 1 month. If during the month they purchase the special product, then they get it for the duration set by the product. If, after the one month of the offer they have not purchased, then I want to automatically remove the product from their view, leaving it visible to others who are still within the 'offer period'.

    I can easily set access rules for the product so it only appears when a product expires, but I cannot see a way to limit the time it appears in the shop for. Each user's subscription may expire on different days, so the special offer product must appear for a month to each user from the point of expiry of the main product.

    Is there a way to achieve this?
  2. caesar

    caesar aMember Pro Developer Staff Member

    Oct 16, 2009

    I am afraid aMember has not such feature by default but aMember is quite flexible and allow to add almost any feature with small piece of code. And more important - aMember allow to do it in upgrade proof way.

    In order to achieve your aim you need to set standard Product Availability rule for your offer product to allow user purchase it only if he has expired subscription to another product. I assume you already did it.

    Then you need to edit site.php and put the following code:

    Am_Di::getInstance()->hook->add(Am_Event::SIGNUP_FORM_GET_PRODUCTS, function(Am_Event $e) {

    $product_expire_id 1;
    $product_limited_offer_id 2;

        if (
    $user $e->getDi()->auth->getUser()) {
    $expire $user->getExpire($product_expire_id);
            if (
    $expire && sqlDate('now') > sqlDate("$expire + 1 month")) {
    $products $e->getReturn();
                foreach (
    $products as $k => $product) {
                    if (
    $product->pk() == $product_limited_offer_id) {


    You need to replace 1 and 2 with correct ids of your products. It is column # at
    aMember CP -> Products -> Manage Products

    You can test this code the following way:
    1. create new test user
    aMember CP -> User -> Add User
    and login as this user to check signup form

    2. then manually add him access to product with expire date in past
    You should see your offer on renew form

    3. change expire date for this product to more then 1 month to past
    Product should disappear from form.

    I hope it help you.

    Best Regards.
    relapse likes this.

Share This Page