• 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 / Files / includes/admin/discounts/edit-discount.php


Lines:

1 to 100 of 217
<?php

/**
 * Edit Discount Page
 *
 * @package     EDD
 * @subpackage  Admin/Discounts
 * @copyright   Copyright (c) 2015, Pippin Williamson
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       1.0
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;

if ( ! isset( $_GET['discount'] ) || ! is_numeric( $_GET['discount'] ) ) {
  wp_die( __( 'Something went wrong.', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 400 ) );
}

$discount_id       = absint( $_GET['discount'] );
$discount          = edd_get_discount( $discount_id );
$product_reqs      = edd_get_discount_product_reqs( $discount_id );
$excluded_products = edd_get_discount_excluded_products( $discount_id );
$condition         = edd_get_discount_product_condition( $discount_id );
$single_use        = edd_discount_is_single_use( $discount_id );
$flat_display      = edd_get_discount_type( $discount_id ) == 'flat' ? '' : ' style="display:none;"';
$percent_display   = edd_get_discount_type( $discount_id ) == 'percent' ? '' : ' style="display:none;"';
$condition_display = empty( $product_reqs ) ? ' style="display:none;"' : '';
?>
<h2><?php _e( 'Edit Discount', 'easy-digital-downloads' ); ?></h2>

<?php if ( isset( $_GET['edd_discount_updated'] ) ) : ?>
	<div id="message" class="updated">
		<p><strong><?php _e( 'Discount code updated.', 'easy-digital-downloads' ); ?></strong></p>

		<p><a href="<?php echo esc_url( admin_url( 'edit.php?post_type=download&page=edd-discounts' ) ); ?>"><?php _e( '&larr; Back to Discounts', 'easy-digital-downloads' ); ?></a></p>
	</div>
<?php endif; ?>

<form id="edd-edit-discount" action="" method="post">
	<?php do_action( 'edd_edit_discount_form_top', $discount_id, $discount ); ?>
	<table class="form-table">
		<tbody>
			<?php do_action( 'edd_edit_discount_form_before_name', $discount_id, $discount ); ?>
			<tr>
				<th scope="row" valign="top">
					<label for="edd-name"><?php _e( 'Name', 'easy-digital-downloads' ); ?></label>
				</th>
				<td>
					<input name="name" required="required" id="edd-name" type="text" value="<?php echo esc_attr( stripslashes( $discount->post_title ) ); ?>" />
					<p class="description"><?php _e( 'The name of this discount', 'easy-digital-downloads' ); ?></p>
				</td>
			</tr>
			<?php do_action( 'edd_edit_discount_form_before_code', $discount_id, $discount ); ?>
			<tr>
				<th scope="row" valign="top">
					<label for="edd-code"><?php _e( 'Code', 'easy-digital-downloads' ); ?></label>
				</th>
				<td>
					<input type="text" required="required" id="edd-code" name="code" value="<?php echo esc_attr( edd_get_discount_code( $discount_id ) ); ?>" pattern="[a-zA-Z0-9-_]+" />
					<p class="description"><?php _e( 'Enter a code for this discount, such as 10PERCENT. Only alphanumeric characters are allowed.', 'easy-digital-downloads' ); ?></p>
				</td>
			</tr>
			<?php do_action( 'edd_edit_discount_form_before_type', $discount_id, $discount ); ?>
			<tr>
				<th scope="row" valign="top">
					<label for="edd-type"><?php _e( 'Type', 'easy-digital-downloads' ); ?></label>
				</th>
				<td>
					<select name="type" id="edd-type">
						<option value="percent" <?php selected( edd_get_discount_type( $discount_id ), 'percent' ); ?>><?php _e( 'Percentage', 'easy-digital-downloads' ); ?></option>
						<option value="flat"<?php selected( edd_get_discount_type( $discount_id ), 'flat' ); ?>><?php _e( 'Flat amount', 'easy-digital-downloads' ); ?></option>
					</select>
					<p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'easy-digital-downloads' ); ?></p>
				</td>
			</tr>
			<?php do_action( 'edd_edit_discount_form_before_amount', $discount_id, $discount ); ?>
			<tr>
				<th scope="row" valign="top">
					<label for="edd-amount"><?php _e( 'Amount', 'easy-digital-downloads' ); ?></label>
				</th>
				<td>
					<input type="text" class="edd-price-field" required="required" id="edd-amount" name="amount" value="<?php echo esc_attr( edd_get_discount_amount( $discount_id ) ); ?>" />
					<p class="description edd-amount-description flat"<?php echo $flat_display; ?>><?php printf( __( 'Enter the discount amount in %s', 'easy-digital-downloads' ), edd_get_currency() ); ?></p>
					<p class="description edd-amount-description percent"<?php echo $percent_display; ?>><?php _e( 'Enter the discount percentage. 10 = 10%', 'easy-digital-downloads' ); ?></p>
				</td>
			</tr>
			<?php do_action( 'edd_edit_discount_form_before_products', $discount_id, $discount ); ?>
			<tr>
				<th scope="row" valign="top">
					<label for="edd-products"><?php printf( __( '%s Requirements', 'easy-digital-downloads' ), edd_get_label_singular() ); ?></label>
				</th>
				<td>
					<p>
						<?php echo EDD()->html->product_dropdown( array(
              'name'        => 'products[]',
              'id'          => 'products',
              'selected'    => $product_reqs,
              'multiple'    => true,
              'chosen'      => true,
[1] [2] [3] Next »

 View on GitHub View on Trac

Called by

    Invoked by

      Calls

      1 to 17 of 17
      • edd_discount_is_single_use() – Is the discount limited to a single use per customer?
      • edd_get_currency() – Get the store’s set currency
      • edd_get_discount_amount() – Retrieve the discount amount.
      • edd_get_discount_code() – Retrieve the discount code.
      • edd_get_discount_excluded_products() – Retrieve the products the discount canot be applied to.
      • edd_get_discount_expiration() – Retrieve the discount code expiration date.
      • edd_get_discount_max_uses() – Retrieve the maximum uses that a certain discount code.
      • edd_get_discount_min_price() – Retrieve the minimum purchase amount for a discount.
      • edd_get_discount_product_condition() – Retrieve the product condition.
      • edd_get_discount_product_reqs() – Retrieve the discount product requirements.
      • edd_get_discount_start_date() – Retrieve the discount code start date.
      • edd_get_discount_type() – Retrieve the discount type
      • edd_get_discount() – Get Discount.
      • edd_get_label_plural() – Get Plural Label
      • edd_get_label_singular() – Get Singular Label
      • edd_is_discount_not_global() – Check if a discount is not global.
      • EDD() – The main function for that returns Easy_Digital_Downloads

      Call hooks

      1 to 14 of 14
      • edd_edit_discount_form_before_amount – action
      • edd_edit_discount_form_before_code – action
      • edd_edit_discount_form_before_excluded_products – action
      • edd_edit_discount_form_before_expiration – action
      • edd_edit_discount_form_before_max_uses – action
      • edd_edit_discount_form_before_min_cart_amount – action
      • edd_edit_discount_form_before_name – action
      • edd_edit_discount_form_before_products – action
      • edd_edit_discount_form_before_start – action
      • edd_edit_discount_form_before_status – action
      • edd_edit_discount_form_before_type – action
      • edd_edit_discount_form_before_use_once – action
      • edd_edit_discount_form_bottom – action
      • edd_edit_discount_form_top – action
      File name: includes/admin/discounts/edit-discount.php
      Plugin ref: Easy Digital Downloads
      Version: 2.11.6
      Deprecated?: No
      API Letters: A,D,E,I

      Published: 26th November 2019 | Last updated: 26th November 2019

      Primary Sidebar

      Information

      File name: includes/admin/discounts/edit-discount.php
      Plugin ref: Easy Digital Downloads
      Version: 2.11.6
      Deprecated?: No
      API Letters: A,D,E,I

      includes/admin/discounts

      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