Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Return a formatted price of the given course, with currency prefix.
- * It will return 'Free' for courses with no price.
- *
- * @param int $post_id
- * @return string
- */
- function bboss_learndash_course_price( $post_id ){
- $options = get_option( 'sfwd_cpt_options' );
- $currency = null;
- if ( !is_null( $options ) ) {
- if ( isset( $options[ 'modules' ] ) && isset( $options[ 'modules' ][ 'sfwd-courses_options' ] ) && isset( $options[ 'modules' ][ 'sfwd-courses_options' ][ 'sfwd-courses_paypal_currency' ] ) )
- $currency = $options[ 'modules' ][ 'sfwd-courses_options' ][ 'sfwd-courses_paypal_currency' ];
- }
- if ( is_null( $currency ) ) {
- $currency = 'USD';
- }
- $course_options = get_post_meta( $post_id, "_sfwd-courses", true );
- $price = $course_options && isset( $course_options[ 'sfwd-courses_course_price' ] ) ? $course_options[ 'sfwd-courses_course_price' ] : __( 'Free', 'boss-learndash' );
- if ( $price == '' ) {
- $price .= __( 'Free', 'boss-learndash' );
- }
- if ( is_numeric( $price ) ) {
- if ( $currency == 'USD' ) {
- $price = '$' . $price;
- } else {
- $price .= ' ' . $currency;
- }
- }
- return $price;
- }
Add Comment
Please, Sign In to add comment