Coupon only purchase

Discussion in 'Payments processing' started by chrisgormlie, Apr 20, 2007.

  1. chrisgormlie

    chrisgormlie New Member

    Joined:
    Apr 17, 2007
    Messages:
    6
    Is it possible to set up a product that can ONLY be purchased by a coupon code?

    My perfect setup would be....


    • Product a: free signup... limited access to site (no problems setting up)
    • Product b: 3 months membership to site bought with paypal (again no probs)
    • product c: Date ended membership available only to 'club' members paid for by a unique coupon.

    Maybe implementation of option 3 is staring me in the face, but short of making an unreasonably high high price with a 100% discount, I cannot see it.

    Any help would be gratefully appreciated
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    It is possible with little code customization. Please contact us via helpdesk.
  3. chrisgormlie

    chrisgormlie New Member

    Joined:
    Apr 17, 2007
    Messages:
    6
    Thanks... its working like a charm.
  4. tony121

    tony121 New Member

    Joined:
    Aug 22, 2006
    Messages:
    54
    Why not post the mod for everyone to take a look at. Maybe there's someone else who might like to do the same.
  5. chrisgormlie

    chrisgormlie New Member

    Joined:
    Apr 17, 2007
    Messages:
    6
    in signup.php

    add

    PHP:
    if(($vars[product_id] == 3) && !$vars[coupon]){
        
    $error [] = 'You must have a VALID coupon code for this product';
        }
    where 3 was my product id.
  6. idream

    idream New Member

    Joined:
    Jan 15, 2008
    Messages:
    4
    where does this code go in signup.php?
  7. idream

    idream New Member

    Joined:
    Jan 15, 2008
    Messages:
    4
    figured it out. you can see the code in the middle down here. i added the requirement for 3 different products:

    if (!strlen($vars['pass0'])){
    $error[] = _SIGNUP_PLEASE_ENTER_PSWD;
    } elseif (strlen($vars['pass0']) < $config['pass_min_length']){
    $ll = $config[pass_min_length];
    $error[] = sprintf(_SIGNUP_INVALID_PASS_1,$ll);
    }
    if ($vars['pass0'] != $vars['pass1']){
    $error[] = _SIGNUP_INVALID_PASS_2;
    }
    if(($vars[product_id] == 3) && !$vars[coupon]){
    $error [] = 'You must have a VALID coupon code for this product';
    }
    if(($vars[product_id] == 4) && !$vars[coupon]){
    $error [] = 'You must have a VALID coupon code for this product';
    }
    if(($vars[product_id] == 5) && !$vars[coupon]){
    $error [] = 'You must have a VALID coupon code for this product';
    }
    $error = array_merge($error, plugin_validate_signup_form($vars));
    return !count($error);
    }

    ###############################################################################
    # SHOW_PAYMENT_FORM
    #
    # get vars from database and plugins
    # display $GLOBAL[error] if it set
    # substitute previous entered parameters using Smarty
    #
    function show_payment_form(){
  8. pamelahazelton

    pamelahazelton New Member

    Joined:
    Feb 4, 2009
    Messages:
    6
    I tried this today and it worked like a charm. Thanks for the detailed info!

    Pamela
  9. marysenatori

    marysenatori New Member

    Joined:
    Nov 18, 2011
    Messages:
    20
    Does this work with version 4.2.15? If not, can you let me know how it can be adapted? Thank you.
  10. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
  11. marysenatori

    marysenatori New Member

    Joined:
    Nov 18, 2011
    Messages:
    20
    Will this be in effect for every signup form? What if we have created a special signup form for this particular product? The form is only accessible via a 'secret' URL. We want to share that link with some people and allow them free and instant access via a coupon code.
  12. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    yes this hook will be applied to all forms.
    But inside your hook you have an access to $form object so can check it type etc...
  13. marysenatori

    marysenatori New Member

    Joined:
    Nov 18, 2011
    Messages:
    20
    Thank you. Does this mean I can add the form's 'secret code' to the site.php file to make the validation only apply to it? Where does it go if so? And is making the coupon field the one to validate as simple as changing 'email' in your linked example to 'coupon'?

Share This Page