Home / Admin / Custom fields to vendor settings page
Duplicate Snippet

Embed Snippet on Your Site

Custom fields to vendor settings page

Code Preview
php
<?php
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="wcv_custom_settings_pv_merchant_id" id="wcv_custom_settings_pv_merchant_id" placeholder="1234" value="<?php echo get_user_meta( get_current_user_id(), 'wcv_custom_settings_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="wcv_custom_settings_pv_merchant_id"><?php _e( 'Merchant ID', 'wc_product_vendor' ); ?></label></th>
    <td><input type="text" name="wcv_custom_settings_pv_merchant_id" id="wcv_custom_settings_pv_merchant_id" value="<?php echo get_user_meta( $user->ID, 'wcv_custom_settings_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['wcv_custom_settings_pv_merchant_id'] ) ) {
    update_user_meta( $user_id, 'wcv_custom_settings_pv_merchant_id', $_POST['wcv_custom_settings_pv_merchant_id'] );
  }
}

Comments

Add a Comment