Add cancel link to product listing on dashboard

Discussion in 'Templates customization' started by bfritton, Oct 7, 2010.

  1. bfritton

    bfritton Certified aMember Developer

    Joined:
    Oct 26, 2009
    Messages:
    54
    Hi all,
    I tried to steal the code from the payments_history template,

    PHP:
    <a href="{$p.cancel_url}target=top onclick="return confirm('#_TPL_MEMBER_CANCEL_SUBSCR#')">#_TPL_MEMBER_CANCEL#</a>
    and put it in the <li> of the member dashboard template where it lists the active subscriptions. The link, when clicked, brings up the alert box asking if I really want to cancel, but if I click okay, it just redirects back to the dashboard and doesn't cancel the product.

    Can I get some help on how to do this? I'm guessing it has something to do with the {$p.cancel_url} and where that's placed in the {foreach} statement of member_main.html.

    Thanks!:eek:
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Do you have an example active user for whom the cancel link is active on the payment history page?

    Chances are you can copy the URL thats given there to other parts of the site.

    David
  3. bfritton

    bfritton Certified aMember Developer

    Joined:
    Oct 26, 2009
    Messages:
    54
    Unfortunately that doesn't work. It generates some variables that I suppose I could grab with a little bit of code.

    https://domain.com/members/plugins/...ecurring&payment_id=85&member_id=100527&v=xxx

    The v=xxx part at the end I believe is the session key which I can get, i can get the payment_id most likely??? and definitely the member_id, but you can also see that it's choosing the cc_core as the payment type so what if someone paid via a PayPal billing agreement?
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Have a look to example from member.php:
    PHP:
            $paysys get_paysystem($v['paysys_id']);
            
    $product $db->get_product($v['product_id']);      
           if (
    $paysys['recurring']
                && (
    $pay_plugin = &instantiate_plugin('payment'$v['paysys_id']))
                && 
    $product['is_recurring']
                && 
    method_exists($pay_plugin'get_cancel_link')){
                
    $payments[$k]['cancel_url'] =
                    
    $pay_plugin->get_cancel_link($v['payment_id']);
            }
    So all you need to do is to get payment plugin class and use get_cancel_link method for each payment.

Share This Page