How to add new field on customer register ?

Discussion in 'Customization & Integration Showcase and Discussion' started by Linh Ho, May 9, 2015.

  1. Linh Ho

    Linh Ho Kilo Poster

    Messages:
    28
    Hello,

    I followed the instruction of PBAs document about add new field on Customer Register with Placeholder.
    I already restarted PBAs service.
    But i don't know why it doesn't show on web shop view.

    I added new code in /var/opt/hspc-root/custom/EV/PlaceHolder.pm

    PHP:
    package HSPC::Custom::EV::PlaceHolder;
    use 
    HSPC::PluginToolkit::General qw(
        
    string
        argparam
        log_debug
        log_warn
    );

    use 
    strict;

    use 
    constant PLACEHOLDERS=>{
        
    customer.customextattribute=>{
              
    method=>ext_attr,
              
    explain=>'Placeholder for custom extended attribute'
              
    is_vector=>0,
              
    obj_type_id=>'HSPC::MT::Core::Customer',
              
    def_value=>'test_value'
        
    }
    }

    sub ext_attr {
        
    my $account shift;
        
    my $name 'custom_ext_attribute';
        
    log_debug("**** CALL ME ****");
        require 
    HSPC::MT::Core::ExtAttrFactory;
        
    my $value HSPC::MT::Core::ExtAttrFactory->find_ext_attr(
            
    obj_type=>$account->obj_type_id(),
            
    obj_id =>$account->id(),
            
    name =>$name
        
    );
        return 
    $value;
    Is there anyone can fix it ?

    Thanks.
     
  2. FedorK

    FedorK Mega Poster

    Messages:
    224
  3. Linh Ho

    Linh Ho Kilo Poster

    Messages:
    28
    Hello,

    Thank you for your support :)

    I have some question ?
    Where can i put this code ? Is this sample code for one-time run, to add new attribute to database ?
    And how can i add default custom extended attribute for all new customer ?

    Thanks
     
  4. FedorK

    FedorK Mega Poster

    Messages:
    224
    Yes it is one time script.

    By default you set up:
    $ext_attr_type->obj_types( [
    {'obj_type' => &SW_OBJTYPE_CORE_HSP,
    'default_value' => 'superboss'
    },
     
  5. Linh Ho

    Linh Ho Kilo Poster

    Messages:
    28
    Cool

    Thanks so much
     
  6. Linh Ho

    Linh Ho Kilo Poster

    Messages:
    28
    Hello,

    How could i show ext attributes on this form?

    [​IMG]

    Thanks and best regards.
    Linh.Ho
     

Share This Page