Code Help: Display Info ONLY If User Has Recurring Product

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

  1. scott_sm

    scott_sm New Member

    Joined:
    Aug 22, 2006
    Messages:
    26
    Hi. I have a piece of information that I would like to display on member.html ONLY if they have an active recurring product.

    I have tried this:
    Code:
    {foreach from=$payments item=p}
    {if $p.cancel_url} Show some text {/if}
    {/foreach}
    ... But if the user has 2 or more recurring products it shows 2 or more outputs of the text that I want shown.

    So I tried this to limit to only 1 output:
    Code:
    {foreach from=$payments item=p name=payment_loop} 
    {if $p.cancel_url} Show some text {/if}
    {if $smarty.foreach.payment_loop.iteration == 1}
    {php}break;{/php}
    {/if}
    {/foreach}
    ... But this only looks at one of their payments, which may miss an actual recurring product and thus give me the wrong output.

    What code can I use to determine if the user has ANY active recurring product, and then create a single output?
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Code mostly depends on payment system that you use. So what payment plugins you have enabled?
  3. scott_sm

    scott_sm New Member

    Joined:
    Aug 22, 2006
    Messages:
    26
    I am using the linkpoint plugin.
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    The simplest way is to test for {$user.data.cc} field.
    If user have active recurring product he have CC info in profile, if subscription is cancelled and expired CC info will be deleted so :
    {if $user.data.cc}
    do something
    {/if}

Share This Page