From 21da6ee31c610a02a41782d79c1ce5dc783670d1 Mon Sep 17 00:00:00 2001
From: Caleb Burks <19caleb95@gmail.com>
Date: Sat, 25 Feb 2017 02:16:30 -0600
Subject: [PATCH 1/2] Hide coupon free shipping conditionally
---
.../admin/meta-boxes/class-wc-meta-box-coupon-data.php | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php b/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php
index 5ff8304ce61..f9796e4a767 100644
--- a/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php
+++ b/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php
@@ -72,7 +72,13 @@ class WC_Meta_Box_Coupon_Data {
woocommerce_wp_text_input( array( 'id' => 'coupon_amount', 'label' => __( 'Coupon amount', 'woocommerce' ), 'placeholder' => wc_format_localized_price( 0 ), 'description' => __( 'Value of the coupon.', 'woocommerce' ), 'data_type' => 'price', 'desc_tip' => true ) );
// Free Shipping
- woocommerce_wp_checkbox( array( 'id' => 'free_shipping', 'label' => __( 'Allow free shipping', 'woocommerce' ), 'description' => sprintf( __( 'Check this box if the coupon grants free shipping. A free shipping method must be enabled in your shipping zone and be set to require "a valid free shipping coupon" (see the "Free Shipping Requires" setting).', 'woocommerce' ), 'https://docs.woocommerce.com/document/free-shipping/' ) ) );
+ if ( wc_shipping_enabled() ) {
+ woocommerce_wp_checkbox( array(
+ 'id' => 'free_shipping',
+ 'label' => __( 'Allow free shipping', 'woocommerce' ),
+ 'description' => sprintf( __( 'Check this box if the coupon grants free shipping. A free shipping method must be enabled in your shipping zone and be set to require "a valid free shipping coupon" (see the "Free Shipping Requires" setting).', 'woocommerce' ), 'https://docs.woocommerce.com/document/free-shipping/' )
+ ) );
+ }
// Expiry date
$expiry_date = $coupon->get_date_expires() ? date( 'Y-m-d', $coupon->get_date_expires() ) : '';
From e7827600118fd0826a22636dcc7eab9018985e62 Mon Sep 17 00:00:00 2001
From: Caleb Burks <19caleb95@gmail.com>
Date: Sat, 25 Feb 2017 02:27:38 -0600
Subject: [PATCH 2/2] Clean up
These lines, so long ;p
---
.../class-wc-meta-box-coupon-data.php | 52 ++++++++++++++++---
1 file changed, 45 insertions(+), 7 deletions(-)
diff --git a/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php b/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php
index f9796e4a767..21e8709728c 100644
--- a/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php
+++ b/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php
@@ -66,10 +66,21 @@ class WC_Meta_Box_Coupon_Data {
'discount_type', 'label' => __( 'Discount type', 'woocommerce' ), 'options' => wc_get_coupon_types() ) );
+ woocommerce_wp_select( array(
+ 'id' => 'discount_type',
+ 'label' => __( 'Discount type', 'woocommerce' ),
+ 'options' => wc_get_coupon_types()
+ ) );
// Amount
- woocommerce_wp_text_input( array( 'id' => 'coupon_amount', 'label' => __( 'Coupon amount', 'woocommerce' ), 'placeholder' => wc_format_localized_price( 0 ), 'description' => __( 'Value of the coupon.', 'woocommerce' ), 'data_type' => 'price', 'desc_tip' => true ) );
+ woocommerce_wp_text_input( array(
+ 'id' => 'coupon_amount',
+ 'label' => __( 'Coupon amount', 'woocommerce' ),
+ 'placeholder' => wc_format_localized_price( 0 ),
+ 'description' => __( 'Value of the coupon.', 'woocommerce' ),
+ 'data_type' => 'price',
+ 'desc_tip' => true
+ ) );
// Free Shipping
if ( wc_shipping_enabled() ) {
@@ -82,7 +93,14 @@ class WC_Meta_Box_Coupon_Data {
// Expiry date
$expiry_date = $coupon->get_date_expires() ? date( 'Y-m-d', $coupon->get_date_expires() ) : '';
- woocommerce_wp_text_input( array( 'id' => 'expiry_date', 'value' => esc_attr( $expiry_date ), 'label' => __( 'Coupon expiry date', 'woocommerce' ), 'placeholder' => 'YYYY-MM-DD', 'description' => '', 'class' => 'date-picker', 'custom_attributes' => array( 'pattern' => apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ) ) );
+ woocommerce_wp_text_input( array(
+ 'id' => 'expiry_date',
+ 'value' => esc_attr( $expiry_date ),
+ 'label' => __( 'Coupon expiry date', 'woocommerce' ),
+ 'placeholder' => 'YYYY-MM-DD', 'description' => '',
+ 'class' => 'date-picker',
+ 'custom_attributes' => array( 'pattern' => apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) )
+ ) );
do_action( 'woocommerce_coupon_options', $coupon->get_id(), $coupon );
@@ -92,16 +110,36 @@ class WC_Meta_Box_Coupon_Data {
echo '
';
// minimum spend
- woocommerce_wp_text_input( array( 'id' => 'minimum_amount', 'label' => __( 'Minimum spend', 'woocommerce' ), 'placeholder' => __( 'No minimum', 'woocommerce' ), 'description' => __( 'This field allows you to set the minimum spend (subtotal, including taxes) allowed to use the coupon.', 'woocommerce' ), 'data_type' => 'price', 'desc_tip' => true ) );
+ woocommerce_wp_text_input( array(
+ 'id' => 'minimum_amount',
+ 'label' => __( 'Minimum spend', 'woocommerce' ),
+ 'placeholder' => __( 'No minimum', 'woocommerce' ),
+ 'description' => __( 'This field allows you to set the minimum spend (subtotal, including taxes) allowed to use the coupon.', 'woocommerce' ),
+ 'data_type' => 'price', 'desc_tip' => true
+ ) );
// maximum spend
- woocommerce_wp_text_input( array( 'id' => 'maximum_amount', 'label' => __( 'Maximum spend', 'woocommerce' ), 'placeholder' => __( 'No maximum', 'woocommerce' ), 'description' => __( 'This field allows you to set the maximum spend (subtotal, including taxes) allowed when using the coupon.', 'woocommerce' ), 'data_type' => 'price', 'desc_tip' => true ) );
+ woocommerce_wp_text_input( array(
+ 'id' => 'maximum_amount',
+ 'label' => __( 'Maximum spend', 'woocommerce' ),
+ 'placeholder' => __( 'No maximum', 'woocommerce' ),
+ 'description' => __( 'This field allows you to set the maximum spend (subtotal, including taxes) allowed when using the coupon.', 'woocommerce' ),
+ 'data_type' => 'price', 'desc_tip' => true
+ ) );
// Individual use
- woocommerce_wp_checkbox( array( 'id' => 'individual_use', 'label' => __( 'Individual use only', 'woocommerce' ), 'description' => __( 'Check this box if the coupon cannot be used in conjunction with other coupons.', 'woocommerce' ) ) );
+ woocommerce_wp_checkbox( array(
+ 'id' => 'individual_use',
+ 'label' => __( 'Individual use only', 'woocommerce' ),
+ 'description' => __( 'Check this box if the coupon cannot be used in conjunction with other coupons.', 'woocommerce' )
+ ) );
// Exclude Sale Products
- woocommerce_wp_checkbox( array( 'id' => 'exclude_sale_items', 'label' => __( 'Exclude sale items', 'woocommerce' ), 'description' => __( 'Check this box if the coupon should not apply to items on sale. Per-item coupons will only work if the item is not on sale. Per-cart coupons will only work if there are no sale items in the cart.', 'woocommerce' ) ) );
+ woocommerce_wp_checkbox( array(
+ 'id' => 'exclude_sale_items',
+ 'label' => __( 'Exclude sale items', 'woocommerce' ),
+ 'description' => __( 'Check this box if the coupon should not apply to items on sale. Per-item coupons will only work if the item is not on sale. Per-cart coupons will only work if there are no sale items in the cart.', 'woocommerce' )
+ ) );
echo '
';