Displaying Payment Options with radio buttons

Discussion in 'Customization & add-ons' started by bjk68, Nov 22, 2008.

  1. bjk68

    bjk68 New Member

    Joined:
    Nov 15, 2008
    Messages:
    24
    Hi Alex,

    Please can you help me with this. :confused:

    I am trying to modify the members.html template to show the payment options with radio buttons (as on the signup page).
    I copied the code from signup.html and made some small alterations.

    Original lines of member.html to show the payment options as pulldown list:
    Code:
    {if count($paysystems_select) > 1 }
    ...
        <select name="paysys_id" size="1">
        <option value=''>#_TPL_MEMBER_SELECT2#</option>
        {html_options options=$paysystems_select selected=$smarty.request.paysys_id}
        </select>
    ...
    {else}
    {foreach from=$paysystems_select item=p key=i}
        <input type="hidden" name="paysys_id" value="{$i|escape}" />
    {/foreach}
    {/if}
    
    My modification (with bugs) of member.html to show the payment options with radio buttons:
    Code:
        {foreach from=$paysystems_select item=p key=i} 
            {if count($paysystems_select)>1}
            <input type="radio" id="paysys_id{$i}" name="paysys_id" value="{$i|escape}"
                {if $i eq $smarty.request.paysys_id }checked{/if} />
            {else}            
            <input type="hidden" id="paysys_id{$i}" name="paysys_id" value="{$i|escape}" />
            {/if}<label for="paysys_id{$i}"><b>{$p.title}</b>
                <span class="small">{$p.description}</span></label><br /><br />
        {/foreach}
    
    After my modification the title and description of the paysystems now only show the first character of the paysystem. :(

    Can you help me to get this working?

    Regards, Bart
  2. bjk68

    bjk68 New Member

    Joined:
    Nov 15, 2008
    Messages:
    24
    Member.php transfers not enough data to member.html

    The paysystem properties 'title' and 'description' are not present in the array $paysystems_select. This is because the way the $paysystems_select array is created in member.php:

    Code:
    $paysystems = get_paysystems_list();  
    $pp = array();  
    foreach ($paysystems as $p)   
        if ($p['public'])   
            $pp[ $p['paysys_id'] ] = $p['title'] ;  
    $t->assign('paysystems', $pp);  
      
    $pp1 = $pp;      
    //remove free paysystem from select  
    if (count($pp1) > 1)  
        foreach ($pp1 as $k=>$p)  
            if ($k == 'free') unset($pp1[$k]);   
    $t->assign('paysystems_select', $pp1); 
    As you can see, not all properties are copied from the $paysystems array to the $pp and $pp1 arrays. The $pp1 array is made available to the member.html page. The $paysystems array is not.

    This explains why trying to show other properties of the paysystems failed. :(

    I can of course fix this problem in my member.php file. When I have created the fix, I will post it here. :)
  3. bjk68

    bjk68 New Member

    Joined:
    Nov 15, 2008
    Messages:
    24
    Payment options on member page as radio buttons

    I managed to display the payment options on the member page as radio buttons :) Below the adapted section in \templates\member.html

    Code:
    <!-- paysystem selection code -->
    {if $config.product_paysystem}{else}
    {if count($paysystems_select) > 1 }
    <tr>
        <th>#_TPL_SIGNUP_PAYSYS# *</th>
        <td>
    {foreach from=$paysystems_select item=p key=i}
        <input type="radio" id="paysys_id{$i}" name="paysys_id" value="{$i|escape}"
            {if $i eq $smarty.request.paysys_id }checked{/if} />
        <label for="paysys_id{$i}"><b>{$p}</b></label><br /><br />
    {/foreach}
        </td>
    </tr>
    {else}            
    {foreach from=$paysystems_select item=p key=i}
    <input type="hidden" id="paysys_id{$i}" name="paysys_id" value="{$i|escape}" />
    {/foreach}
    {/if}
    {/if}
    
  4. bjk68

    bjk68 New Member

    Joined:
    Nov 15, 2008
    Messages:
    24
    Product list with radio buttons on member page

    And if you would like to use radio buttons for your products list as well on the member page, you can use the following code section on templates\member.html :)

    Code:
    <!-- product selection code -->
    <tr>    
        <th>#_TPL_SIGNUP_MEMB_TYPE# *</th>
        <td>
        {foreach from=$products_to_renew item=p} 
        {if count($products_to_renew)>1}
        {if $config.member_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}
        {if $paysys_id_not_required }
        <input type="hidden" name="paysys_id_not_required" value="for javascript" />
    		{/if}
        </td>
    </tr>
    
  5. taichiterry

    taichiterry New Member

    Joined:
    Aug 30, 2008
    Messages:
    2
    Showing as link

    Hi,

    Can you please let me know how i can show it not as a radio button or drop down but simply as a link. The reason is that i have one of the product as an one time offer and i want to link it with this url is it even possible?

    can any one help?

    Thank you.

Share This Page