├── .gitignore ├── i18n └── languages │ └── woocommerce-filter-orders-by-coupon.pot ├── readme.md ├── readme.txt ├── screenshots └── screenshot-1.png └── woocommerce-filter-orders-by-coupon.php /.gitignore: -------------------------------------------------------------------------------- 1 | *.zip 2 | .DS_Store 3 | 4 | # Grunt.js SASS cache files 5 | /.sass-cache 6 | 7 | # NPM packages used by Grunt.js 8 | /node_modules 9 | 10 | # NPM debug log 11 | npm-debug.log 12 | 13 | # build directory 14 | /build 15 | 16 | .idea/ -------------------------------------------------------------------------------- /i18n/languages/woocommerce-filter-orders-by-coupon.pot: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 SkyVerge 2 | # This file is distributed under the GNU General Public License v3.0. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: WooCommerce Filter Orders by Coupon 1.0.0\n" 6 | "Report-Msgid-Bugs-To: " 7 | "https://github.com/skyverge/woocommerce-filter-orders-by-coupon/issues\n" 8 | "POT-Creation-Date: 2015-03-08 23:31:17+00:00\n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=utf-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | 16 | #: build/woocommerce-filter-orders-by-coupon.php:106 17 | #: woocommerce-filter-orders-by-coupon.php:106 18 | msgid "Filter by coupon used" 19 | msgstr "" 20 | 21 | #. Plugin Name of the plugin/theme 22 | msgid "WooCommerce Filter Orders by Coupon" 23 | msgstr "" 24 | 25 | #. Plugin URI of the plugin/theme 26 | msgid "http://www.skyverge.com/product/woocommerce-filter-orders/" 27 | msgstr "" 28 | 29 | #. Description of the plugin/theme 30 | msgid "Adds the ability to filter orders by the coupon used." 31 | msgstr "" 32 | 33 | #. Author of the plugin/theme 34 | msgid "SkyVerge" 35 | msgstr "" 36 | 37 | #. Author URI of the plugin/theme 38 | msgid "http://www.skyverge.com/" 39 | msgstr "" -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## WooCommerce Filter Orders by Coupon 2 | 3 | - Requires WordPress 3.8+, WooCommerce 2.2+ 4 | - Contributors: [Beka Rice](http://github.com/bekarice), [SkyVerge](http://github.com/skyverge/) 5 | - Like this? [We always appreciate donations](https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@skyverge.com&item_name=Donation+for+WooCommerce+Filter+Orders) 6 | - Current version: 1.1.0 7 | - License: [GPLv3](http://www.gnu.org/licenses/gpl-3.0.html) 8 | 9 | ### Description 10 | 11 | Does exactly what you think :) This plugin adds a new filtering option to the orders screen. This allows you to filter your orders by the coupon used within the order. 12 | 13 | While you can search for the coupon used, this isn't ideal to find orders that have used a coupon, as you may have product names that contain the coupon name. This plugin adds a filtering option to return exact results for orders that have used a particular coupon. 14 | 15 | Only coupons that are "published" (no drafts) will be available in the filtering dropdown. If you have no published coupons, this dropdown will not show. 16 | 17 | ### Changelog 18 | 19 | **2017.06.27 - version 1.1.0** 20 | * Feature: Add support for GitHub Updater 21 | * Misc: Code cleanup 22 | 23 | **2015.07.27 - version 1.0.1** 24 | * Misc: WooCommerce 2.4 compatibility 25 | 26 | **2015.03.06 - version 1.0.0** 27 | * Initial Release 28 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === WooCommerce Filter Orders by Coupon === 2 | 3 | Contributors: skyverge, beka.rice 4 | Tags: woocommerce, orders, filter orders, coupons 5 | Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@skyverge.com&item_name=Donation+for+WooCommerce+Filter+Orders 6 | Requires at least: 3.8 7 | Tested up to: 4.8 8 | WC Requires at least: 2.2 9 | WC tested up to: 3.1 10 | Stable Tag: 1.1.0 11 | License: GPLv3 12 | License URI: http://www.gnu.org/licenses/gpl-3.0.html 13 | 14 | Adds custom filtering to the orders screen to allow filtering by coupon used. 15 | 16 | == Description == 17 | 18 | This plugin adds a new filtering option to the orders screen. This allows you to filter your orders by the coupon used within the order. 19 | 20 | > **Requires: WooCommerce 2.2+**, Compatible with WooCommerce 2.3 and 2.4 21 | 22 | **There are no settings**. The plugin will add the filtering dropdown automatically to the "Orders" screen while active. 23 | 24 | = Fast Coupon Filtering = 25 | While you can search for the coupon used, this isn't ideal to find orders that have used a coupon, as you may have product names that contain the coupon name. This plugin adds a filtering option to return exact results for orders that have used a particular coupon. 26 | 27 | Only coupons that are "published" (no drafts) will be available in the filtering dropdown. 28 | 29 | = More Details = 30 | - See the [product page](http://www.skyverge.com/product/woocommerce-filter-orders/) for full details. 31 | - View more of SkyVerge's [free WooCommerce extensions](http://profiles.wordpress.org/skyverge/) 32 | - View all [SkyVerge WooCommerce extensions](http://www.skyverge.com/shop/) 33 | - View the FAQ for some tips. 34 | 35 | == Installation == 36 | 37 | 1. Be sure you're running WooCommerce 2.2+ in your shop. 38 | 2. Upload the entire `woocommerce-filter-orders-by-coupon` folder to the `/wp-content/plugins/` directory, or upload the .zip file with the plugin under **Plugins > Add New > Upload** 39 | 3. Activate the plugin through the **Plugins** menu in WordPress 40 | 41 | You can now filter your orders by coupons available in your shop by visiting **WooCommerce > Orders** in your admin. 42 | 43 | == Frequently Asked Questions == 44 | = Why don't all of my coupons show up in the dropdown? = 45 | Only coupons with a status of "published" will be shown here. If your coupon is set up as draft, it won't be used for filtering. 46 | 47 | = I don't see a dropdown at all! What gives? = 48 | The coupon filtering dropdown will only show if coupons are present in your shop and published :). 49 | 50 | = Can I filter for orders that have used more than one coupon? = 51 | Sorry, this functionality isn't available. This plugin is simply meant to be an easy way to check for orders that contain a particular coupon. If an order uses more than one coupon, it will still be included when filtering, so long as the coupon you're filtering for was used. 52 | 53 | = Can I translate this in my language? = 54 | Yep! There's only one string to translate, but you can do so :). The coupon names are pulled directly from your coupon list, so they can be translated there. 55 | 56 | The text domain to use is `wc-filter-orders`. 57 | 58 | = This is handy! Can I contribute? = 59 | Yes you can! Join in on our [GitHub repository](https://github.com/bekarice/woocommerce-filter-orders/) and submit a pull request :) 60 | 61 | == Screenshots == 62 | 1. The new coupon filter added to the Orders page 63 | 64 | == Changelog == 65 | 66 | = 2017.06.27 - version 1.1.0 = 67 | * Feature: Add support for GitHub Updater 68 | * Misc: Code cleanup 69 | 70 | = 2015.07.27 - version 1.0.1 = 71 | * Misc: WooCommerce 2.4 compatibility 72 | 73 | = 2015.03.06 - version 1.0.0 = 74 | * Initial Release 75 | -------------------------------------------------------------------------------- /screenshots/screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bekarice/woocommerce-filter-orders/cac24554fa1d8cb7f60d7a1f690f742aa2209ab0/screenshots/screenshot-1.png -------------------------------------------------------------------------------- /woocommerce-filter-orders-by-coupon.php: -------------------------------------------------------------------------------- 1 | - 1, 83 | 'orderby' => 'title', 84 | 'order' => 'asc', 85 | 'post_type' => 'shop_coupon', 86 | 'post_status' => 'publish', 87 | ); 88 | 89 | $coupons = get_posts( $args ); 90 | 91 | if ( ! empty( $coupons ) ) : ?> 92 | 93 | 103 | prefix}woocommerce_order_items woi ON {$wpdb->posts}.ID = woi.order_id"; 122 | } 123 | 124 | return $join; 125 | } 126 | 127 | 128 | /** 129 | * Modify SQL WHERE for filtering the orders by any coupons used 130 | * 131 | * @since 1.0.0 132 | * 133 | * @param string $where WHERE part of the sql query 134 | * @return string $where modified WHERE part of sql query 135 | */ 136 | public function add_filterable_where( $where ) { 137 | global $typenow, $wpdb; 138 | 139 | if ( 'shop_order' === $typenow && isset( $_GET['_coupons_used'] ) && ! empty( $_GET['_coupons_used'] ) ) { 140 | 141 | // Main WHERE query part 142 | $where .= $wpdb->prepare( " AND woi.order_item_type='coupon' AND woi.order_item_name='%s'", wc_clean( $_GET['_coupons_used'] ) ); 143 | } 144 | 145 | return $where; 146 | } 147 | 148 | 149 | /** Helper methods ***************************************/ 150 | 151 | 152 | /** 153 | * Load Translations 154 | * 155 | * @since 1.0.0 156 | */ 157 | public function load_translation() { 158 | // localization 159 | load_plugin_textdomain( 'wc-filter-orders', false, dirname( plugin_basename( __FILE__ ) ) . '/i18n/languages' ); 160 | } 161 | 162 | 163 | /** 164 | * Main WC_Filter_Orders_By_Coupon Instance, ensures only one instance 165 | * is/can be loaded 166 | * 167 | * @since 1.1.0 168 | * 169 | * @see wc_filter_orders_by_coupon() 170 | * @return WC_Filter_Orders_By_Coupon 171 | */ 172 | public static function instance() { 173 | if ( is_null( self::$instance ) ) { 174 | self::$instance = new self(); 175 | } 176 | return self::$instance; 177 | } 178 | 179 | 180 | /** 181 | * Cloning instances is forbidden due to singleton pattern. 182 | * 183 | * @since 1.1.0 184 | */ 185 | public function __clone() { 186 | /* translators: Placeholders: %s - plugin name */ 187 | _doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'You cannot clone instances of %s.', 'wc-filter-orders' ), 'Filter WC Orders by Coupon' ), '1.1.0' ); 188 | } 189 | 190 | 191 | /** 192 | * Unserializing instances is forbidden due to singleton pattern. 193 | * 194 | * @since 1.1.0 195 | */ 196 | public function __wakeup() { 197 | /* translators: Placeholders: %s - plugin name */ 198 | _doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'You cannot unserialize instances of %s.', 'wc-filter-orders' ), 'Filter WC Orders by Coupon' ), '1.1.0' ); 199 | } 200 | 201 | 202 | } 203 | 204 | 205 | /** 206 | * Returns the One True Instance of WC_Filter_Orders_By_Coupon 207 | * 208 | * @since 1.1.0 209 | * 210 | * @return \WC_Filter_Orders_By_Coupon 211 | */ 212 | function wc_filter_orders_by_coupon() { 213 | return WC_Filter_Orders_By_Coupon::instance(); 214 | } 215 | --------------------------------------------------------------------------------