Skip to content

Instantly share code, notes, and snippets.

@bentasm1
Last active June 8, 2017 01:04
Show Gist options
  • Save bentasm1/88225fd5d382a925e62c to your computer and use it in GitHub Desktop.
Save bentasm1/88225fd5d382a925e62c to your computer and use it in GitHub Desktop.
Add custom fields to shop settings
add_action('wcvendors_settings_after_paypal', 'pv_add_custom_merchant_id_field');
function pv_add_custom_merchant_id_field() {
?>
<div class="pv_merchant_id_container">
<p><b><?php _e( 'Merchant ID', 'wc_product_vendor' ); ?></b><br/>
<?php _e( 'Your Checkout.fi merchant ID.', 'wc_product_vendor' ); ?><br/>
<input type="text" name="pv_merchant_id" id="pv_merchant_id" placeholder="1234" value="<?php echo get_user_meta( get_current_user_id(), 'pv_merchant_id', true ); ?>" />
</p>
</div>
<?php
}
add_action( 'wcvendors_admin_after_commission_due', 'pv_admin_user_info' );
function pv_admin_user_info( $user ) {
?>
<tr>
<th><label for="pv_merchant_id"><?php _e( 'Merchant ID', 'wc_product_vendor' ); ?></label></th>
<td><input type="text" name="pv_merchant_id" id="pv_merchant_id" value="<?php echo get_user_meta( $user->ID, 'pv_merchant_id', true ); ?>" class="regular-text"></td>
</tr>
<?php
}
add_action( 'wcvendors_shop_settings_saved', 'pv_save_merchant_id' );
add_action( 'wcvendors_update_admin_user', 'pv_save_merchant_id' );
function pv_save_merchant_id( $user_id )
{
if ( isset( $_POST['pv_merchant_id'] ) ) {
update_user_meta( $user_id, 'pv_merchant_id', $_POST['pv_merchant_id'] );
}
}
@juancarlosqr
Copy link

Just wanted to mention, for PRO plugin the right action is:

add_action( 'wcv_pro_store_settings_saved', 'SAVING_FUNCTION_NAME_HERE' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment