Added option to globally enable/disable the use of coupons for clients
This commit is contained in:
parent
3b74269ed2
commit
0401e79ed4
|
@ -134,6 +134,14 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
|
||||||
'checkboxgroup' => 'start'
|
'checkboxgroup' => 'start'
|
||||||
),
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'desc' => __( 'Enable coupons', 'woocommerce' ),
|
||||||
|
'id' => 'woocommerce_enable_coupons',
|
||||||
|
'std' => 'yes',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => '',
|
||||||
|
),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'desc' => __( 'Enable coupon form on checkout', 'woocommerce' ),
|
'desc' => __( 'Enable coupon form on checkout', 'woocommerce' ),
|
||||||
'id' => 'woocommerce_enable_coupon_form_on_checkout',
|
'id' => 'woocommerce_enable_coupon_form_on_checkout',
|
||||||
|
|
|
@ -155,4 +155,13 @@ jQuery(function(){
|
||||||
|
|
||||||
}).change();
|
}).change();
|
||||||
|
|
||||||
|
// Enable/disable the coupon form on checkout checkbox
|
||||||
|
var $woocommerce_enable_coupons = jQuery('#woocommerce_enable_coupons'),
|
||||||
|
$woocommerce_enable_coupon_form_on_checkout = jQuery('#woocommerce_enable_coupon_form_on_checkout'),
|
||||||
|
toggle_woocommerce_enable_coupon_form_on_checkout = function () {
|
||||||
|
$woocommerce_enable_coupon_form_on_checkout.closest('fieldset').attr('disabled', ! $woocommerce_enable_coupons.is(':checked'));
|
||||||
|
};
|
||||||
|
toggle_woocommerce_enable_coupon_form_on_checkout();
|
||||||
|
$woocommerce_enable_coupons.change(toggle_woocommerce_enable_coupon_form_on_checkout);
|
||||||
|
|
||||||
});
|
});
|
|
@ -1225,6 +1225,9 @@ class WC_Cart {
|
||||||
function add_discount( $coupon_code ) {
|
function add_discount( $coupon_code ) {
|
||||||
global $woocommerce;
|
global $woocommerce;
|
||||||
|
|
||||||
|
// Coupons are globally disabled
|
||||||
|
if ( get_option( 'woocommerce_enable_coupons' ) == 'no' ) return false;
|
||||||
|
|
||||||
$the_coupon = new WC_Coupon($coupon_code);
|
$the_coupon = new WC_Coupon($coupon_code);
|
||||||
|
|
||||||
if ($the_coupon->id) :
|
if ($the_coupon->id) :
|
||||||
|
|
|
@ -86,9 +86,13 @@ global $woocommerce;
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="actions">
|
<td colspan="6" class="actions">
|
||||||
|
|
||||||
|
<?php if ( get_option( 'woocommerce_enable_coupons' ) == 'yes' ) { ?>
|
||||||
<div class="coupon">
|
<div class="coupon">
|
||||||
<label for="coupon_code"><?php _e('Coupon', 'woocommerce'); ?>:</label> <input name="coupon_code" class="input-text" id="coupon_code" value="" /> <input type="submit" class="button" name="apply_coupon" value="<?php _e('Apply Coupon', 'woocommerce'); ?>" />
|
<label for="coupon_code"><?php _e('Coupon', 'woocommerce'); ?>:</label> <input name="coupon_code" class="input-text" id="coupon_code" value="" /> <input type="submit" class="button" name="apply_coupon" value="<?php _e('Apply Coupon', 'woocommerce'); ?>" />
|
||||||
</div>
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
<?php $woocommerce->nonce_field('cart') ?>
|
<?php $woocommerce->nonce_field('cart') ?>
|
||||||
<input type="submit" class="button" name="update_cart" value="<?php _e('Update Cart', 'woocommerce'); ?>" /> <a href="<?php echo esc_url( $woocommerce->cart->get_checkout_url() ); ?>" class="checkout-button button alt"><?php _e('Proceed to Checkout →', 'woocommerce'); ?></a>
|
<input type="submit" class="button" name="update_cart" value="<?php _e('Update Cart', 'woocommerce'); ?>" /> <a href="<?php echo esc_url( $woocommerce->cart->get_checkout_url() ); ?>" class="checkout-button button alt"><?php _e('Proceed to Checkout →', 'woocommerce'); ?></a>
|
||||||
<?php do_action('woocommerce_proceed_to_checkout'); ?>
|
<?php do_action('woocommerce_proceed_to_checkout'); ?>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* Checkout Coupon Form
|
* Checkout Coupon Form
|
||||||
*/
|
*/
|
||||||
if (get_option('woocommerce_enable_coupon_form_on_checkout')=="no") return;
|
if ( get_option( 'woocommerce_enable_coupons' ) == 'no' || get_option( 'woocommerce_enable_coupon_form_on_checkout' ) == 'no' ) return;
|
||||||
|
|
||||||
$info_message = apply_filters('woocommerce_checkout_coupon_message', __('Have a coupon?', 'woocommerce'));
|
$info_message = apply_filters('woocommerce_checkout_coupon_message', __('Have a coupon?', 'woocommerce'));
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -591,6 +591,9 @@ function woocommerce_process_login() {
|
||||||
function woocommerce_process_coupon_form() {
|
function woocommerce_process_coupon_form() {
|
||||||
global $woocommerce;
|
global $woocommerce;
|
||||||
|
|
||||||
|
// Do nothing if coupons are globally disabled
|
||||||
|
if ( get_option( 'woocommerce_enable_coupons' ) == 'no' ) return;
|
||||||
|
|
||||||
if (isset($_POST['coupon_code']) && $_POST['coupon_code']) :
|
if (isset($_POST['coupon_code']) && $_POST['coupon_code']) :
|
||||||
|
|
||||||
$coupon_code = stripslashes(trim($_POST['coupon_code']));
|
$coupon_code = stripslashes(trim($_POST['coupon_code']));
|
||||||
|
|
Loading…
Reference in New Issue