Created
September 20, 2013 22:28
-
-
Save amdrew/6644774 to your computer and use it in GitHub Desktop.
Make Easy Digital Downloads' discount field show by default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Unhook default EDD discount field | |
*/ | |
remove_action( 'edd_checkout_form_top', 'edd_discount_field', -1 ); | |
/** | |
* Custom EDD discount field function | |
*/ | |
function my_child_theme_edd_discount_field() { | |
if( ! isset( $_GET['payment-mode'] ) && count( edd_get_enabled_payment_gateways() ) > 1 && ! edd_is_ajax_enabled() ) | |
return; // Only show once a payment method has been selected if ajax is disabled | |
if ( edd_has_active_discounts() && edd_get_cart_total() ) { | |
?> | |
<fieldset id="edd_discount_code"> | |
<p> | |
<label class="edd-label" for="edd-discount"> | |
<?php _e( 'Discount', 'my-child-theme' ); ?> | |
<img src="<?php echo EDD_PLUGIN_URL; ?>assets/images/loading.gif" id="edd-discount-loader" style="display:none;"/> | |
</label> | |
<span class="edd-description"><?php _e( 'Enter a coupon code if you have one.', 'my-child-theme' ); ?></span> | |
<input class="edd-input" type="text" id="edd-discount" name="edd-discount" placeholder="<?php _e( 'Enter discount', 'my-child-theme' ); ?>"/> | |
</p> | |
</fieldset> | |
<?php | |
} | |
} | |
add_action( 'edd_checkout_form_top', 'my_child_theme_edd_discount_field', -1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment