Membership Type with Drop-Down

Discussion in 'Customization & add-ons' started by hauzer, Feb 22, 2010.

  1. hauzer

    hauzer New Member

    Joined:
    Nov 22, 2009
    Messages:
    15
    Hi there,

    On my web site I'm planning to sell digital products, therefore I will have a lot of products to sell. When I add a product to the list, the user gets to choose the product from the "Membership Type" list.

    The "Membership Type" type list is currently a click-able option, is it possible to have the options within a drop-down box? Rather than a long list. I believe it is possible, if so, how would I go about adding this? What part of which template do I need to modify?

    Kind regards.
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    If you are selling many one off digital products, I think a shopping cart would be more appropriate than a membership system.

    David
  3. hauzer

    hauzer New Member

    Joined:
    Nov 22, 2009
    Messages:
    15
    Hey David,

    Thanks for your response. I've been searching for a shopping cart system for my web site, however, aMember is the most intergrate-able in terms of looks with my current HTML/PHP web site.

    Do you think you could recommend me any shopping cart scripts? So far, aMember seems to be the best, unfortunately that's a membership type system.

    Again, appreciate your response. ;)

    Kind regards.
  4. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Just to clarify, what is "a lot of products" and are they easily grouped into smaller lists of products? If so, aMember may be an ok solution using the price_group filters.

    That being said, for true shopping cart environments, I've been fairly happy with CS-Cart
  5. hauzer

    hauzer New Member

    Joined:
    Nov 22, 2009
    Messages:
    15
    Hey skippybosco,

    In overall I will be selling 24 products, possibly more. These are all eGoods; which can be downloaded onto your computer the same day. They can be categorised in smaller lists of products but they won't be. As each product will be sold as a single stand alone product and not with other products.

    I'd like to stick with aMember, the only thing I need to know is how to change the "Membership Type" selection from options to a drop down. And if I do go with a shopping cart script, I'd like it so that I can integrate it with my current web site which is coded using HTML and php, aMember can do this easily.
  6. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    How about ejunkie?

    David
  7. erwinvdb

    erwinvdb aMember Pro Customer

    Joined:
    Aug 30, 2007
    Messages:
    264
    @ hauzer:

    replace the following code in templates/signup.html (lines 18-20)
    Code:
    <input class="required"  type="radio" id="product{$p.product_id}" name="product_id" value="{$p.product_id|escape}"
            {if $p.product_id == $smarty.request.product_id }checked="checked"{/if}
            />
    with this:
    Code:
    <select name="product_id" size="1">
        <option value="">#_TPL_MEMBER_SELECT#</option>
    {foreach from=$products_to_renew item=p}
        <option value="{$p.product_id}"
        {if $p.product_id == $smarty.request.product_id}selected="selected"{/if}>{$p.title} ({$p.terms}) 
        </option>
    
    Also make sure the select multiple products is switched off in aMember control panel.

    (This snippet of code comes from templates/member.html)
  8. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    nice code share erwinvdb!

    @hauzer: 24 is very manageable.. When I read "a lot", I was thinking hundreds of products..
  9. hauzer

    hauzer New Member

    Joined:
    Nov 22, 2009
    Messages:
    15
    Sorry for the late response everyone. I haven't got round to trying out the code you gave me erwinvdb, but I'm sure it'll work. If it does, then all my problems have been answered. A great thanks, if you want me to add a link back to your web site then I will do so to show my appreciation. ;)

    Also, sorry for not describing my situation in detail skippybosco, I guess I shouldn't have used the "a lot" term for describing my products, however, thanks for replying.

    Also, a great thanks to everyone who replied. ;)
  10. hauzer

    hauzer New Member

    Joined:
    Nov 22, 2009
    Messages:
    15
    Sorry for the bump, however, erwinvdb that code doesn't seem to work.

    The error I receive:

    Code:
    ERROR [256] Smarty error: [in signup.html line 24]: syntax error: mismatched tag {/if}. expected {/foreach} (opened line 20). (Smarty_Compiler.class.php, line 2198) in line 1102 of file /home/skinsbuy/public_html/customer/smarty/Smarty.class.php 
    
  11. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Add one line at the end of code provided by erwinvdb
    {/foreach}
  12. hauzer

    hauzer New Member

    Joined:
    Nov 22, 2009
    Messages:
    15
    Thanks for your reply, however, when I do what erwinvdb provided, thereafter adding your (alexander) code, it gives me another error. I currently have 15 products, each with it's own bullet point (known as 'radio' type input field) instead of a drop-down which I want. After applying the code(s) it gives me 15 different drop-downs:

    [​IMG]

    Each with no content in, it just states "** Select Product **" in all drop downs.

    I've tried to make the bullet points a drop-down myself, unfortunately no success, this is what I did:

    in templates/signup.html find

    Code:
        {foreach from=$products item=p} 
        {if count($products)>1}
        {if $config.select_multiple_products}
        <input class="required" type="checkbox" id="product{$p.product_id}" name="product_id[]" value="{$p.product_id|escape}"
            {if in_array($p.product_id, (array)$smarty.request.product_id)}checked="checked"{/if}
            />
        {else}
    <input class="required"  type="radio" id="product{$p.product_id}" name="product_id" value="{$p.product_id|escape}"
            {if $p.product_id == $smarty.request.product_id }checked="checked"{/if}
            />
        {/if}{* end if $config.select_multiple_products *}
        {else}
        <input type="hidden" id="product{$p.product_id}" name="product_id" value="{$p.product_id}" />
        {/if}   
            <label for="product{$p.product_id}"><b>{$p.title}</b> ({$p.terms})<br />
            <span class="small">{$p.description}</span></label><br />
        {if $p.price <= 0.0 }     {assign var="paysys_id_not_required" value="1"}    {/if}        
        {/foreach}
    
    then I replaced this with:

    Code:
    {if $config.member_select_multiple_products}
        {foreach from=$products_to_renew item=p} 
        <input type="checkbox" id="product{$p.product_id}" name="product_id[]" value="{$p.product_id|escape}"
            {if in_array($p.product_id, (array)$smarty.request.product_id)}checked="checked"{/if}
            />
            <label for="product{$p.product_id}"><b>{$p.title} ({$p.terms})</b><br />
            <span class="small">{$p.description}</span></label><br /><br />
        {if $p.price <= 0.0 }
        {assign var="paysys_id_not_required" value="1"}
        {/if}        
        {/foreach}
    {else}
    <select name="product_id" size="1">
        <option value="">#_TPL_MEMBER_SELECT#</option>
    {foreach from=$products_to_renew item=p}
        <option value="{$p.product_id}"
        {if $p.product_id == $smarty.request.product_id}selected="selected"{/if}>{$p.title} ({$p.terms}) 
        </option>
        {if $p.price <= 0.0 }
        {assign var="paysys_id_not_required" value="1"}
        {/if}        
    {/foreach}
    </select>
    {/if}
    {if $paysys_id_not_required }
          <input type="hidden" name="paysys_id_not_required" value="for javascript" />
    {/if}
    
    This seemed to work perfectly, however, it just gave me a drop-down with only one selectable option, "** Select Product **"

    P.S. If this drop-drop option eventually works, I still need to have the "Signup Link Wizard" working intact. So that I can automatically make a user select a product.
  13. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Well I cehck code that was provided before and it is incorrect you right.
    here is what you need to do edit signup.html template and find this:
    Code:
      {foreach from=$products item=p}.
        {if count($products)>1}
        {if $config.select_multiple_products}
        <input class="required" type="checkbox" id="product{$p.product_id}" name="product_id[]" value="{$p.product_id|escape}" 
            {if in_array($p.product_id, (array)$smarty.request.product_id)}checked="checked"{/if} 
            />
        {else}
        <input class="required"  type="radio" id="product{$p.product_id}" name="product_id" value="{$p.product_id|escape}" 
            {if $p.product_id == $smarty.request.product_id }checked="checked"{/if} 
            />
        {/if}{* end if $config.select_multiple_products *}
        {else}
        <input type="hidden" id="product{$p.product_id}" name="product_id" value="{$p.product_id}" />
        {/if}
            <label for="product{$p.product_id}"><b>{$p.title}</b> ({$p.terms})<br />
            <span class="small">{$p.description}</span></label><br />
        {if $p.price <= 0.0 }     {assign var="paysys_id_not_required" value="1"}    {/if}
        {/foreach} 
    
    
    change that block to:
    Code:
        <select name='product_id'>
        {foreach from=$products item=p}.
        {if count($products)>1}
          <option value='{$p.product_id}'> <b>{$p.title}</b> ({$p.terms})</option>
        {else}
        <input type="hidden" id="product{$p.product_id}" name="product_id" value="{$p.product_id}" />
        {/if}
            
        {if $p.price <= 0.0 }     {assign var="paysys_id_not_required" value="1"}    {/if}
        {/foreach} 
        </select>
    
    
  14. hauzer

    hauzer New Member

    Joined:
    Nov 22, 2009
    Messages:
    15
    Hey alexander,

    Thanks for your response, that seems to fix the radio type input fields into drop-downs perfectly, however, there is a problem unfortunately. And, the only problem I was worried about.

    When I pre-select the product, I want the user to have the product I chose. When I create a link, it just seems to only select the first option. For example, when I give a person this URL: http://www.example.com/signup.php?product_id=15&hide_paysys=paypal_r It is set to choose the product 15 for them automatically, however, using this drop-down, it automatically (no matter what URL I give them) selects the first option on the drop-down for them. I would like this "Setup Link Wizard" to work, if possible.

    Thanks, if not, then I guess I could still use the radio type buttons, but I rather wish I didn't have to.

    Thank you so far for all response. ;)
  15. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Change this line in my code:
    Code:
     <option value='{$p.product_id}'> <b>{$p.title}</b> ({$p.terms})</option>
    
    to
    Code:
     <option value='{$p.product_id}' {if $smarty.request.product_id==$p.product_id}selected{/if}> <b>{$p.title}</b> ({$p.terms})</option>
    
    I just forgot about this.
  16. erwinvdb

    erwinvdb aMember Pro Customer

    Joined:
    Aug 30, 2007
    Messages:
    264
    Sorry for my late response, I couldn't visit the forum any sooner.
    BUT... I see that Alexander came to save the day ;)
  17. hauzer

    hauzer New Member

    Joined:
    Nov 22, 2009
    Messages:
    15
    WOW! Thank you so much, more than words can describe. Thank you! It works more than perfect.

Share This Page