• 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_products_field() – Renders product field

You appear to be a bot. Output may be restricted

Description

Renders product field

Usage

edd_render_products_field( $post_id );

Parameters

$post_id
( mixed ) required –

Returns

void

Source

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

1 to 100 of 151
function edd_render_products_field( $post_id ) {
  $download         = new EDD_Download( $post_id );
  $type             = $download->get_type();
  $display          = $type == 'bundle' ? '' : ' style="display:none;"';
  $products         = $download->get_bundled_downloads();
  $variable_pricing = $download->has_variable_prices();
  $variable_display = $variable_pricing ? '' : 'display:none;';
  $variable_class   = $variable_pricing ? ' has-variable-pricing' : '';
  $prices           = $download->get_prices();
?>
	<div id="edd_products"<?php echo $display; ?>>
		<div id="edd_file_fields" class="edd_meta_table_wrap">
			<div class="widefat edd_repeatable_table">

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

				<div class="edd-bundled-product-select edd-repeatables-wrap">

					<?php if ( $products ) : ?>

						<div class="edd-bundle-products-header">
							<span class="edd-bundle-products-title"><?php printf( __( 'Bundled %s', 'easy-digital-downloads' ), edd_get_label_plural() ); ?></span>
						</div>

						<?php $index = 1; ?>
						<?php foreach ( $products as $key => $product ) : ?>
							<div class="edd_repeatable_product_wrapper edd_repeatable_row" data-key="<?php echo esc_attr( $index ); ?>">
								<div class="edd-bundled-product-row<?php echo $variable_class; ?>">
									<div class="edd-bundled-product-item-reorder">
										<span class="edd-product-file-reorder edd-draghandle-anchor dashicons dashicons-move"  title="<?php printf( __( 'Click and drag to re-order bundled %s', 'easy-digital-downloads' ), edd_get_label_plural() ); ?>"></span>
										<input type="hidden" name="edd_bundled_products[<?php echo $index; ?>][index]" class="edd_repeatable_index" value="<?php echo $index; ?>"/>
									</div>
									<div class="edd-bundled-product-item">
										<span class="edd-repeatable-row-setting-label"><?php printf( __( 'Select %s:', 'easy-digital-downloads' ), edd_get_label_singular() ); ?></span>
										<?php
                    echo EDD()->html->product_dropdown( array(
                      'name'       => '_edd_bundled_products[]',
                      'id'         => 'edd_bundled_products_' . $index,
                      'selected'   => $product,
                      'multiple'   => false,
                      'chosen'     => true,
                      'bundles'    => false,
                      'variations' => true,
                    ) );
                    ?>
									</div>
									<div class="edd-bundled-product-price-assignment pricing" style="<?php echo $variable_display; ?>">
										<span class="edd-repeatable-row-setting-label"><?php _e( 'Price assignment:', 'easy-digital-downloads' ); ?></span>
										<?php
                      $options = array();

                      if ( $prices ) {
                        foreach ( $prices as $price_key => $price ) {
                          $options[ $price_key ] = $prices[ $price_key ]['name'];
                        }
                      }

                      $price_assignments = edd_get_bundle_pricing_variations( $post_id );
                      if ( ! empty( $price_assignments[0] ) ) {
                        $price_assignments = $price_assignments[0];
                      }

                      $selected = isset( $price_assignments[ $index ] ) ? $price_assignments[ $index ] : null;

                      echo EDD()->html->select( array(
                        'name'             => '_edd_bundled_products_conditions['. $index .']',
                        'class'            => 'edd_repeatable_condition_field',
                        'options'          => $options,
                        'show_option_none' => false,
                        'selected'         => $selected
                      ) );
                    ?>
									</div>
									<span class="edd-bundled-product-actions">
										<a class="edd-remove-row edd-delete" data-type="file"><?php printf( __( 'Remove', 'easy-digital-downloads' ), $index ); ?><span class="screen-reader-text"><?php printf( __( 'Remove bundle option %s', 'easy-digital-downloads' ), $index ); ?></span></a>
									</span>
									<?php do_action( 'edd_download_products_table_row', $post_id ); ?>
								</div>
							</div>
							<?php $index++; ?>
						<?php endforeach; ?>

					<?php else: ?>

						<div class="edd-bundle-products-header">
							<span class="edd-bundle-products-title"><?php printf( __( 'Bundled %s:', 'easy-digital-downloads' ), edd_get_label_plural() ); ?></span>
						</div>
						<div class="edd_repeatable_product_wrapper edd_repeatable_row" data-key="1">
							<div class="edd-bundled-product-row<?php echo $variable_class; ?>">

								<div class="edd-bundled-product-item-reorder">
									<span class="edd-product-file-reorder edd-draghandle-anchor dashicons dashicons-move" title="<?php printf( __( 'Click and drag to re-order bundled %s', 'easy-digital-downloads' ), edd_get_label_plural() ); ?>"></span>
									<input type="hidden" name="edd_bundled_products[1][index]" class="edd_repeatable_index" value="1"/>
								</div>
								<div class="edd-bundled-product-item">
									<span class="edd-repeatable-row-setting-label"><?php printf( __( 'Select %s:', 'easy-digital-downloads' ), edd_get_label_singular() ); ?></span>
									<?php
                  echo EDD()->html->product_dropdown( array(
                    'name'       => '_edd_bundled_products[]',
                    'id'         => 'edd_bundled_products_1',
 
[1] [2] Next »

 View on GitHub View on Trac

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

Primary Sidebar

Information

Function name: edd_render_products_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