Specify multiple price_group on URL

Discussion in 'Customization & add-ons' started by skippybosco, Jun 9, 2009.

  1. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Before I dug into this, wanted to see if anyone had any out of the box tricks to specify more than one price_group to display on the signup and member page?

    To preselect multiple products it is easy:

    Code:
    amember/signup.php?price_group=1&product_id[]=1&product_id[]=2
    But the price_group equivalent displays a blank list:

    Code:
    amember/signup.php?price_group[]=1&price_group[]=2
    Any suggestions / ideas or is this a core code change to accomplish?
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Code in signup and member pages should be changed.
    For example here is how currently aMember check price group:
    Code:
            if ($vars['price_group']){
                if (!in_array($vars['price_group'], split(',',$v['price_group'])) )
                    unset($products[$k]);
            } elseif ($v['price_group'] < 0){
                unset($products[$k]);
            }
    
    
    this is from signup.php
  3. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Thanks Alexander.

    Found that, it is just not very evident where and how the foreach loop should be implemented to append the products list.

    Any assistance would be appreciated.

    Also, is there any technical reason this was not implemented as a core option similar to how the multiple product_id capability was? (want to make sure there is not a security, or other, issue that this introduces that is not evident)
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    I believe this should work:
    Code:
           if(is_array($vars['price_group'])){
                if(!array_inresect($vars['price_group'], split(',',$v['price_group'])))
                    unset($products[$k]);
      
           }elseif ($vars['price_group']){
                if (!in_array($vars['price_group'], split(',',$v['price_group'])) )
                    unset($products[$k]);
            } elseif ($v['price_group'] < 0){
                unset($products[$k]);
            }
    
    to make such urls possible:
    Code:
    amember/signup.php?price_group[]=1&price_group[]=2
    
  5. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    This worked perfect with one small typo change highlighted below:

    Can I recommend that this change be added into the core code (for signup.php and member.php) so that it is included in future releases. I suspect this is a feature that a number of aMember admins would appreciate.
  6. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    True, true... I can see the use for that too.

    Thanks for the code ;)
  7. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Thanks for suggestion. It was added to working copy.
  8. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    this modification doesn't seem to work in 3.2.3 anymore... at least it doesn't on member.php renewal tab page...

Share This Page