1. Home
  2. ReHub Theme
  3. User submit, memberships, profiles
  4. How to assign currency to number fields in frontend submit

How to assign currency to number fields in frontend submit

When you create deal site and added frontend form, sometimes, you will need to assign currency to price field and make this field as number field. This will prevent cases, when users place text in price field which makes price as not correct. So, for this, when you create price field, make it as Number type instead of text, then, enable Prefix or Postfix field and add there your currency. This will add your currency automatically to price. Also, choose your price pattern in theme option – localization

If you need some advance things for price, you can use next hook (only for developers)

 

and add next snippet to functions.php

add_action('wpfepp_form_actions', 'currency_change_custom');
function currency_change_custom($data){
    if ( !empty( $_POST['rehub_offer_product_price'] ) ) {
        $priceclean = $_POST['rehub_offer_product_price'];
        $priceclean = $currency.$priceclean;
        update_post_meta( $data['post_id'], 'rehub_offer_product_price', esc_html( $priceclean ) );
    }       
}

 

Was this article helpful to you? Yes No

How can we help?