• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Easy Digital Downloads a2z

Easy Digital Downloads a2z

Easy Digital Downloads a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / edd_render_price_field() – Price Section

You appear to be a bot. Output may be restricted

Description

Price Section

If variable pricing is not enabled, simply output a single input box. If variable pricing is enabled, outputs a table of all current prices. Extensions can add column heads to the table via the edd_download_file_table_head hook, and actual columns via edd_download_file_table_row

Usage

edd_render_price_field( $post_id );

Parameters

$post_id
( mixed ) required –

Returns

void

Source

File name: easy-digital-downloads/includes/admin/downloads/metabox.php
Lines:

1 to 85 of 85
function edd_render_price_field( $post_id ) {
  $price              = edd_get_download_price( $post_id );
  $variable_pricing   = edd_has_variable_prices( $post_id );
  $prices             = edd_get_variable_prices( $post_id );
  $single_option_mode = edd_single_price_option_mode( $post_id );

  $price_display      = $variable_pricing ? ' style="display:none;"' : '';
  $variable_display   = $variable_pricing ? '' : ' style="display:none;"';
  $currency_position  = edd_get_option( 'currency_position', 'before' );
  ?>
	<p>
		<strong><?php echo apply_filters( 'edd_price_options_heading', __( 'Pricing Options:', 'easy-digital-downloads' ) ); ?></strong>
	</p>

	<p>
		<label for="edd_variable_pricing">
			<input type="checkbox" name="_variable_pricing" id="edd_variable_pricing" value="1" <?php checked( 1, $variable_pricing ); ?> />
			<?php echo apply_filters( 'edd_variable_pricing_toggle_text', __( 'Enable variable pricing', 'easy-digital-downloads' ) ); ?>
		</label>
	</p>

	<div id="edd_regular_price_field" class="edd_pricing_fields" <?php echo $price_display; ?>>
		<?php
      $price_args = array(
        'name'  => 'edd_price',
        'value' => isset( $price ) ? esc_attr( edd_format_amount( $price ) ) : '',
        'class' => 'edd-price-field'
      );
    ?>

		<?php if ( $currency_position == 'before' ) : ?>
			<?php echo edd_currency_filter( '' ); ?>
			<?php echo EDD()->html->text( $price_args ); ?>
		<?php else : ?>
			<?php echo EDD()->html->text( $price_args ); ?>
			<?php echo edd_currency_filter( '' ); ?>
		<?php endif; ?>

		<?php do_action( 'edd_price_field', $post_id ); ?>
	</div>

	<?php do_action( 'edd_after_price_field', $post_id ); ?>

	<div id="edd_variable_price_fields" class="edd_pricing_fields" <?php echo $variable_display; ?>>
		<input type="hidden" id="edd_variable_prices" class="edd_variable_prices_name_field" value=""/>
		<p>
			<?php echo EDD()->html->checkbox( array( 'name' => '_edd_price_options_mode', 'current' => $single_option_mode ) ); ?>
			<label for="_edd_price_options_mode"><?php echo apply_filters( 'edd_multi_option_purchase_text', __( 'Enable multi-option purchase mode. Allows multiple price options to be added to your cart at once', 'easy-digital-downloads' ) ); ?></label>
		</p>
		<div id="edd_price_fields" class="edd_meta_table_wrap">
			<div class="widefat edd_repeatable_table">

				<div class="edd-price-option-fields edd-repeatables-wrap">
					<?php
            if ( ! empty( $prices ) ) :

              foreach ( $prices as $key => $value ) :
                $name   = ( isset( $value['name'] ) && ! empty( $value['name'] ) ) ? $value['name']   : '';
                $index  = ( isset( $value['index'] ) && $value['index'] !== '' )   ? $value['index']  : $key;
                $amount = isset( $value['amount'] ) ? $value['amount'] : '';
                $args   = apply_filters( 'edd_price_row_args', compact( 'name', 'amount' ), $value );
                ?>
								<div class="edd_variable_prices_wrapper edd_repeatable_row" data-key="<?php echo esc_attr( $key ); ?>">
									<?php do_action( 'edd_render_price_row', $key, $args, $post_id, $index ); ?>
								</div>
							<?php
              endforeach;
            else :
          ?>
						<div class="edd_variable_prices_wrapper edd_repeatable_row" data-key="1">
							<?php do_action( 'edd_render_price_row', 1, array(), $post_id, 1 ); ?>
						</div>
					<?php endif; ?>

					<div class="edd-add-repeatable-row">
						<div class="submit" style="float: none; clear:both; background:#fff; padding: 4px 4px 0 0;">
							<button class="button-secondary edd_add_repeatable"><?php _e( 'Add New Price', 'easy-digital-downloads' ); ?></button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div><!--end #edd_variable_price_fields-->
<?php
}
 

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 13th March 2021

Primary Sidebar

Information

Function name: edd_render_price_field
Plugin ref: Easy Digital Downloads
Version: 2.11.6
Sourcefile: includes/admin/downloads/metabox.php
File ref: includes/admin/downloads/metabox.php
Deprecated?: No
API Letters: E,F,P,R

Footer

Easy Digital Downloads a2z
Easy Digital Downloads a2z
Easy Digital Downloads a2z
WordPress 5.9.3
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  edd.wp-a2z.org
© Copyright Easy Digital Downloads a2z 2014-2022. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites