Is That Possible To Add Data Update Upon Payment

Discussion in 'Customization & add-ons' started by nyksjqi, Jun 5, 2003.

  1. nyksjqi

    nyksjqi Guest

    Hello, Alex

    We need to add an extra column in both membmembers table and membproducts table. It's an additional feature of the product: "max_search". If user choose different product, they are given a different number of search.

    Is that possible to add a function to update the max_search column upon successful payment?

    Thank you.
  2. alex-adm

    alex-adm Guest

    Here is example of code you requested:

    file amember/site.inc.php (create if not exists):
    Code:
    <?
    
    add_member_field('max_search', 'Max Search', 'text', '');
    add_product_field('max_search', 'Max Search', 'text', '');
    
    function ums($payment_id){
        global $db;
        $p = $db->get_payment($payment_id);
        $c = 0;
        foreach ($db->get_user_payments($p['member_id'], 1) as $p){
            $pr = $db->get_product($p['product_id']);
            $c  += $pr['max_search'];
        }
        $u = $db->get_user($p['member_id']);
        $u['data']['max_search'] = $c;
        $db->update_user($u['member_id'], $u);
    }
    
    setup_plugin_hook('finish_waiting_payment', 'ums');
    
    ?>
    something like that...
  3. nyksjqi

    nyksjqi Guest

    I'll try that. Alex, your support is premium.

Share This Page