Add fields in products

Discussion in 'Customization & add-ons' started by DotHellas, Feb 15, 2006.

  1. DotHellas

    DotHellas New Member

    Joined:
    Nov 7, 2003
    Messages:
    5
    Hello,

    I want to know if there is a plan for adding extra fields to product table. It's good that this option is available in profile table, but I think that it's also good to be available to product too.

    Is anybody out there, who tried to modify the code on this way?

    Thanks
  2. alex

    alex Well-Known Member Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    It is easy to do - there are some code examples (add to amember/site.inc.php):

    PHP:
                add_product_field(
                            
    'is_recurring''Recurring Billing',
                            
    'select''should user be charged automatically<br>
                             when subscription expires'
    ,
                            
    '',
                            array(
    'options' => array(
                                
    '' => 'No',
                                
    1  => 'Yes'
                            
    ));
                
    add_product_field('trial1_days'
                    
    'Trial 1 Duration',
                    
    'period',
                    
    'trial period duration'
                    
    );
  3. DotHellas

    DotHellas New Member

    Joined:
    Nov 7, 2003
    Messages:
    5
    hmmm... is it bad to say that I didn't understood it Alex? Or maybe I wasn't clear in my post. What I mean is:
    Every product record, has id, duration, price etc... I want to add some other fields in every record (that's why I talked about tables). eg to add a field named event_type with, droplist, with values "Type1, Type2...."

    Thanks
    Chris
  4. alex

    alex Well-Known Member Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Create a file amember/site.inc.php with the following content

    PHP:
    <?php
    add_product_field
    (
                            
    'event_type''Event Type',
                            
    'select''choose a value',
                            
    '',
                            array(
    'options' => array(
                                
    '' => '',
                                
    'Type1'  => 'Type 1',
                                
    'Type2'  => 'Type 2',
                                
    'Type3'  => 'Type 3',
                            ));
    ?>
    then visit aMember CP -> Manage Products and you will see this field.
  5. coderxo

    coderxo New Member

    Joined:
    Mar 1, 2009
    Messages:
    16
    Hello Alex,

    A couple of questions:


    1: The data 'Type1' is stored in the db when saved in the admin?
    2: Each product as many as 200, has a unique Type1. How can one
    put this in, without manually using an array with 200 key/value pairs?


    Thanks in advance.

Share This Page