Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to add custom fields to the Shop as Client PRO add-on ajax call
/* Add this to you (child-)theme functions.php file */
add_filter( 'shop_as_client_pro_customer_data', 'my_shop_as_client_pro_customer_data', 10, 3 );
function my_shop_as_client_pro_customer_data( $data, $customer = null, $order = null ) {
if ( $customer ) {
//Getting a customer object
//Custom field billing_xpto
$data['billing']['xpto'] = $customer->get_meta( 'billing_xpto' );
//Custom field shipping_xpto
$data['shipping']['xpto'] = $customer->get_meta( 'shipping_xpto' );
//Custom field whatever loaded into whatever billing field
$data['billing']['whatever'] = $customer->get_meta( 'whatever' );
//Custom field that is neither from billing nor shipping
$data['custom']['field_id'] = $customer->get_meta( 'custom_field_meta' );
//Return the data
} elseif ( $order ) {
//Getting a order object
//Custom field, from order, that is neither from billing nor shipping
$data['custom']['field_id'] = $order->get_meta( 'custom_field_meta' );
return $data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.