diff --git a/admin/admin-post-types.php b/admin/admin-post-types.php index 01b879a4124..11f89161ba0 100644 --- a/admin/admin-post-types.php +++ b/admin/admin-post-types.php @@ -37,7 +37,7 @@ function woocommerce_edit_coupon_columns($columns){ add_action('manage_shop_coupon_posts_custom_column', 'woocommerce_custom_coupon_columns', 2); function woocommerce_custom_coupon_columns($column) { - global $post; + global $post, $woocommerce; $type = get_post_meta($post->ID, 'discount_type', true); $amount = get_post_meta($post->ID, 'coupon_amount', true); @@ -49,7 +49,7 @@ function woocommerce_custom_coupon_columns($column) { switch ($column) { case "type" : - echo $type; + echo $woocommerce->get_coupon_discount_type($type); break; case "amount" : echo $amount; diff --git a/admin/writepanels/writepanel-coupon_data.php b/admin/writepanels/writepanel-coupon_data.php index dac3e78b5ec..4fdf9957924 100644 --- a/admin/writepanels/writepanel-coupon_data.php +++ b/admin/writepanels/writepanel-coupon_data.php @@ -15,7 +15,8 @@ * Displays the meta box */ function woocommerce_coupon_data_meta_box($post) { - + global $woocommerce; + wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' ); ?> @@ -26,12 +27,7 @@ function woocommerce_coupon_data_meta_box($post) { __('Cart Discount', 'woothemes'), - 'percent' => __('Cart % Discount', 'woothemes'), - 'fixed_product' => __('Product Discount', 'woothemes') - )); - woocommerce_wp_select( array( 'id' => 'discount_type', 'label' => __('Discount type', 'woothemes'), 'options' => $discount_types ) ); + woocommerce_wp_select( array( 'id' => 'discount_type', 'label' => __('Discount type', 'woothemes'), 'options' => $woocommerce->get_coupon_discount_types() ) ); // Amount woocommerce_wp_text_input( array( 'id' => 'coupon_amount', 'label' => __('Coupon amount', 'woothemes'), 'placeholder' => __('0.00', 'woothemes'), 'description' => __('Enter an amount e.g. 2.99 or an integer for percentages e.g. 20%', 'woothemes') ) ); diff --git a/classes/woocommerce.class.php b/classes/woocommerce.class.php index e6a63c4d6bc..d0e6ea8ea9f 100644 --- a/classes/woocommerce.class.php +++ b/classes/woocommerce.class.php @@ -206,6 +206,32 @@ class woocommerce { if ($label) return $label; else return ucfirst($name); } + + /*-----------------------------------------------------------------------------------*/ + /* Coupons */ + /*-----------------------------------------------------------------------------------*/ + + /** + * Get coupon types + */ + function get_coupon_discount_types() { + if (!isset($this->coupon_discount_types)) : + $this->coupon_discount_types = apply_filters('woocommerce_coupon_discount_types', array( + 'fixed_cart' => __('Cart Discount', 'woothemes'), + 'percent' => __('Cart % Discount', 'woothemes'), + 'fixed_product' => __('Product Discount', 'woothemes') + )); + endif; + return $this->coupon_discount_types; + } + + /** + * Get a coupon type's name + */ + function get_coupon_discount_type( $type = '' ) { + $types = (array) $this->get_coupon_discount_types(); + if (isset($types[$type])) return $types[$type]; + } /*-----------------------------------------------------------------------------------*/ /* Nonce Field Helpers */ diff --git a/readme.txt b/readme.txt index 9bc119ffd44..6c4a4e6eaf9 100644 --- a/readme.txt +++ b/readme.txt @@ -63,6 +63,8 @@ For further documentation on using WooCommerce, please sign up for free at http: * Made image size settings clearer * Cleaned up coupon code settings/write panel and added a few more hooks * Fixed 'product ids' setting in coupons +* Fixed notices on shop pages due to WP_QUERY +* Cleaned up discount types and made some helper functions for getting them = 1.0.2 - 02/10/2011 = * Fix in woocommerce_templates for when a shop is the front-page