Collect personalization information in Marketplace

I'm creating a website for an author who wants to offer autographed copies of his book. I want to collect the name of the person he should write the inscription to. How can I collect that information?

  • James Morris
    • WordPress Enthusiast

    Hello Sj,

    I hope you are well today.

    I'm afraid it's not possible with the current version of MarketPress to add custom fields out of the box. Something like that would take custom development.

    However, if you don't mind re-purposing the "Company" checkout field, there's a solution. You can use the following custom code as a Must Use plugin (mu-plugin) to collect this data and store is at the company name field.

    add_filter( 'mp_checkout/address_fields_array', function( $address_fields, $type ) {
    	$elements_names_placeholders = array(
    		'billing[first_name]' => 'Insert your first name',
    		'billing[last_name]' => 'Insert your last name',
    		'billing[email]' => 'Insert your email',
    		'billing[company_name]' => 'Insert your desired inscription'
    	if( is_array( $address_fields ) ) {
    		foreach( $address_fields as $field_key => $address_field ) {
    			if( isset( $address_field[ 'subfields' ] ) ) {
    				if( ! is_array( $address_field[ 'subfields' ] ) ){
    				foreach ( $address_field[ 'subfields' ] as $sub_key => $sub_field ) {
    					if( isset( $sub_field['name'] ) && isset( $elements_names_placeholders[ $sub_field['name'] ] ) ){
    						$address_fields[ $field_key ]['subfields'][ $sub_key ]['atts']['placeholder'] = $elements_names_placeholders[ $sub_field['name'] ];
    						$address_fields[ $field_key ]['subfields'][ $sub_key ]['label'] = '';
    				if( isset( $address_field['name'] ) && isset( $elements_names_placeholders[ $address_field['name'] ] ) ){
    					$address_fields[ $field_key ]['atts']['placeholder'] = $elements_names_placeholders[ $address_field['name'] ];
    					$address_fields[ $field_key ]['label'] = '';
    	return $address_fields;
    }, 10, 2 );

    Just save that code as a php file and upload it to your wp-content/mu-plugins/ folder and it will update the address form on checkout. See screenshot:

    Let us know if you have any further questions. We'll be happy to help! :slight_smile:

    Best regards,

    James Morris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.