vtmin_format_money_element

The VarkTech Minimum Purchase for WooCommerce vtmin format money element function.

Description

vtmin_format_money_element( $price ); 

Parameters (1)

0. $price
The price.

Usage

  1. if ( !function_exists( 'vtmin_format_money_element' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'varktech-minimum-purchase-for-woocommerce/woo-integration/vtmin-parent-functions.php'; 
  3.  
  4. // The price. 
  5. $price = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = vtmin_format_money_element($price); 
  9.  

Defined (1)

The function is defined in the following location(s).

/woo-integration/vtmin-parent-functions.php  
  1. function vtmin_format_money_element($price) {  
  2. //from woocommerce/woocommerce-core-function.php function woocommerce_price 
  3. $return = ''; 
  4. $num_decimals = (int) get_option( 'woocommerce_price_num_decimals' ); 
  5. $currency_pos = get_option( 'woocommerce_currency_pos' ); 
  6. $currency_symbol = get_woocommerce_currency_symbol(); 
  7. $decimal_sep = wp_specialchars_decode( stripslashes( get_option( 'woocommerce_price_decimal_sep' ) ), ENT_QUOTES ); 
  8. $thousands_sep = wp_specialchars_decode( stripslashes( get_option( 'woocommerce_price_thousand_sep' ) ), ENT_QUOTES ); 
  9.  
  10. $price = apply_filters( 'raw_woocommerce_price', (double) $price ); 
  11. $price = number_format( $price, $num_decimals, $decimal_sep, $thousands_sep ); 
  12.  
  13. if ( get_option( 'woocommerce_price_trim_zeros' ) == 'yes' && $num_decimals > 0 ) 
  14. $price = woocommerce_trim_zeros( $price ); 
  15.  
  16. //$return = '<span class="amount">' . sprintf( get_woocommerce_price_format(), $currency_symbol, $price ) . '</span>';  
  17.  
  18. $current_version = WOOCOMMERCE_VERSION; 
  19. if( (version_compare(strval('2'), strval($current_version), '>') == 1) ) { //'==1' = 2nd value is lower  
  20. $formatted = number_format( $price, $num_decimals, stripslashes( get_option( 'woocommerce_price_decimal_sep' ) ), stripslashes( get_option( 'woocommerce_price_thousand_sep' ) ) ); 
  21. $formatted = $currency_symbol . $formatted; 
  22. } else { 
  23. $formatted = sprintf( get_woocommerce_price_format(), $currency_symbol, $price ); 
  24.  
  25. return $formatted;