{
    "docs": [
        {
            "location": "/",
            "text": "WooCommerce Extended Coupon Features\n\n\n\nMore coupon and discount options for WooCommerce.\n\n\nSoft79\n\nCreated: 07/05/2014\n\nLatest update: 11/02/2017\n\n\n\n\n\n\n\n\n\n\nWooCommerce Extended Coupon Features\n is an easy-to-use WordPress / WooCommerce plugin that adds functionality to the WooCommerce coupon system.\n\n\nThe functionality is conveniently integrated to the standard WooCommerce Edit Coupon panel therefore the plugin is extremely easy to use.\n\n\n\n\nWhat can be achieved with this plugin?\n\n\n\n\nCreate discounts that will automatically be applied to the customer\u2019s cart when certain conditions are met.\n\n\nExtended coupon restrictions\n\n\nRestrict coupon by shipping method,\n\n\nRestrict coupon by payment method,\n\n\nRestrict coupon by customer credentials or customer role\n\n\nRestrict coupon by combinations of products (e.g. buy both A and B and get 20% off!)\n\n\nRestrict coupon by amount of matching products (e.g. buy three products from category C and get a free product!)\n\n\nApply coupon using an url\n\n\n(PRO) Give away free products\n\n\n(PRO) BOGO (Buy One Get One)\n\n\n(PRO) Limit product discount to: One per order line, cheapest product or cheapest order line\n\n\n\n\nwww.soft79.nl",
            "title": "About"
        },
        {
            "location": "/usage/",
            "text": "Editing coupons\n\n\nWooCommerce Extended Coupon Features\n adds several tabs and fields to the WooCommerce Coupon Management pages.\n\n\nAdditional usage restrictions\n\n\nSeveral features are added to the \nUsage Restriction\n-tab of the coupon edit page. Here extra rules can be configured that work in combination with the Products, Exclude products, Product categories and Exclude categories rules. \n\n\n\n\nAND Products (not OR)\n\n\nBy default a coupon validates if only one of the selected products is in the cart. Check this box if ALL of the products entered on the \nUsage Restriction\n-tab must be in the cart to validate the coupon. The word 'OR' or 'AND' is displayed next to the 'Products'-field on the \nUsage Restriction\n-tab for clarification.\n\n\nAND Categories (not OR)\n\n\nBy default a coupon validates if a product from any of the selected categories is in the cart. Check this box if products from ALL of the categories entered on the \nUsage Restriction\n-tab must be in the cart to validate the coupon. The word 'OR' or 'AND' is displayed next to the \nProducts\n-field on the \nUsage Restriction\n-tab for clarification.\n\n\nMinimum/maximum quantity of matching products\n\n\nThe coupon will only validate if the number of products matching the product or category restrictions (on the \nUsage Restriction\n-tab in the cart is within this range. If no product or category restriction is entered, the total quantity of all of the products in the cart will be used.\n\n\nMinimum/maximum subtotal of matching products\n\n\nThe coupon will only validate if the total value of the products matching the product or category restrictions (on the \nUsage Restriction\n-tab in the cart is within this range. If no product or category restriction is entered, the total value of all of the products in the cart will be used.\n\n\nPlease note: The difference between this option and the 'minimum/maximum spend' on the 'General'-tab is that on the general tab the subtotal of all of the items in the cart is compared.\n\n\nDiscount on cart with excluded products (PRO Version Only)\n\n\nThis option is only visible if the discount type is Cart Discount or Cart % Discount.\n\n\nBy default, When the coupon is setup as a 'Cart Discount' it will never validate a coupon when an excluded product is in the cart (this is how WooCommerce Coupons work). By checking this box the coupon will still validate when an excluded product is in the cart. Useful for cart discounts based on a subtotal of matching products, but having some products or categories excluded.\n\n\nFree products\n\n\nIn the 'Free products'-field on the 'Free products'-tab you can enter one or more products that will automatically be added to the cart when the coupon is applied. The product will automatically be removed when the coupon is no longer valid.\n\n\n\n\nWatch video\n\n\nIf you tick the 'select one'-checkbox, the customer must choose one (or more) of the selected products on the cart or checkout page. The customer can also choose the desired variations of a variable product. You can also edit the message that is displayed.\n\n\n\n\nIf you wish to change the look-and-feel of the product selection you must create a subdirectory woocommerce-auto-added-coupons-pro in your themes directory  and copy and edit the files templates/cart/select-free-product.php and templates/checkout/select-free-product.php in here.\n\n\nMultiplication of free products\n\n\nWhen the box 'Allow multiplication of the free products' is checked the amount of free products will be multiplied every time the minimum spend, subtotal or quantity is reached. For example if the minimum spend is $ 50 and the user has $ 160 worth of products in the cart, the free products will be added 3 times to the cart.\n\n\nCheckout\n\n\nOn the checkout-tab restrictions can be entered that will normally only be active when the customer initiates checkout.\n\n\n\n\nShipping methods\n\n\nThe coupon will only validate if the customer selects one of these shipping methods.\n\n\nPayment methods\n\n\nThe coupon will only validate if the customer selects one of these payment methods.\n\n\nCustomer restrictions\n\n\nAllowed customer\n\n\nWhen you enter one or more customers here, the coupon will only validate if the customer is logged in and is in this list.\n\n\nAllowed user roles\n\n\nWhen you enter one or more user roles here, the coupon will only validate if the customer has one of these user roles (e.g. Wholesale buyer or Guest).\n\n\nDisallowed user roles\n\n\nThe coupon will only validate if the customer does not have any of these user roles (e.g. Wholesale buyer or Guest).\n\n\nMiscellaneous\n\n\nAuto coupon\n\n\n\n\nYou can convert a coupon into a discount rule simply by ticking the \"Auto coupon\" checkbox on the 'miscellaneous'-tab. When using this option it is important to enter a description for the coupon, as this will be presented to the customer.\n\n\nWhen this option is activated, the discount will automatically be applied to the cart when it's conditions are met and the description will be presented to the customer and on the cart page. Once the conditions are no longer met, for example when the customer removes an item from the cart, the discount will be removed from the cart.\n\n\nApply silently\n\n\nWhen this box is checked, no 'Discount applied' notice will be presented when the coupon is applied.\n\n\nAllow applying when invalid\n\n\n(PRO Version Only)\n\n\nWhen the box 'Allow applying when invalid' is ticked, a customer can always add the coupon to the cart, but will be presented with a message that the discount will only apply when the conditions are met.\n\n\nNOTE: This option is not available for 'Auto coupons'.\n\n\nCoupon by URL\n\n\nNow you can easily create a link that will automatically apply a coupon to the user's cart, optionally in combination with a product.\n\n\nSimply append ?apply_coupon=coupon_code to the url. If you also want to add products to the cart with the same url, you can use add-to-cart=product_id and optionally a quantity. You can find the id of a product on the WooCommerce Edit-page of the product.\n\n\nExample:\n\n\n(http://www.your-store.nl/cart/?add-to-cart=4321&quantity=3&apply_coupon=my_coupon)[#]\n\n\nIf the customer opens the url when the conditions of the coupon are not yet met or the cart is empty the coupon won't be applied yet, instead the following message will be displayed: Coupon will be applied once it's conditions are met. Once the conditions of the coupon are met it will be applied automatically.\n\n\nAutomatic updates\n\n\n(PRO Version Only)\n\n\nTo receive automatic updates, you need to enter the licence key.\nNOTE: This is only possible if you purchased the plugin at soft79.nl.\n\n\nGo to:  \nwp-admin > Settings > WooCommerce Extended Coupon Features\n\n\n\n\nEnter the domain and licence key. The licence will be automatically activated.\n\n\nTo deactivate a licence key for a domain (e.g. to move it to a different domain) just empty the fields and save the settings. The licence will automatically be deactivated for the domain and can be used on a different domain.\n\n\nYou can also manage you licence activations from \nyour account\n page at soft79.nl.",
            "title": "Usage"
        },
        {
            "location": "/usage/#editing-coupons",
            "text": "WooCommerce Extended Coupon Features  adds several tabs and fields to the WooCommerce Coupon Management pages.",
            "title": "Editing coupons"
        },
        {
            "location": "/usage/#additional-usage-restrictions",
            "text": "Several features are added to the  Usage Restriction -tab of the coupon edit page. Here extra rules can be configured that work in combination with the Products, Exclude products, Product categories and Exclude categories rules.",
            "title": "Additional usage restrictions"
        },
        {
            "location": "/usage/#and-products-not-or",
            "text": "By default a coupon validates if only one of the selected products is in the cart. Check this box if ALL of the products entered on the  Usage Restriction -tab must be in the cart to validate the coupon. The word 'OR' or 'AND' is displayed next to the 'Products'-field on the  Usage Restriction -tab for clarification.",
            "title": "AND Products (not OR)"
        },
        {
            "location": "/usage/#and-categories-not-or",
            "text": "By default a coupon validates if a product from any of the selected categories is in the cart. Check this box if products from ALL of the categories entered on the  Usage Restriction -tab must be in the cart to validate the coupon. The word 'OR' or 'AND' is displayed next to the  Products -field on the  Usage Restriction -tab for clarification.",
            "title": "AND Categories (not OR)"
        },
        {
            "location": "/usage/#minimummaximum-quantity-of-matching-products",
            "text": "The coupon will only validate if the number of products matching the product or category restrictions (on the  Usage Restriction -tab in the cart is within this range. If no product or category restriction is entered, the total quantity of all of the products in the cart will be used.",
            "title": "Minimum/maximum quantity of matching products"
        },
        {
            "location": "/usage/#minimummaximum-subtotal-of-matching-products",
            "text": "The coupon will only validate if the total value of the products matching the product or category restrictions (on the  Usage Restriction -tab in the cart is within this range. If no product or category restriction is entered, the total value of all of the products in the cart will be used.  Please note: The difference between this option and the 'minimum/maximum spend' on the 'General'-tab is that on the general tab the subtotal of all of the items in the cart is compared.",
            "title": "Minimum/maximum subtotal of matching products"
        },
        {
            "location": "/usage/#discount-on-cart-with-excluded-products-pro-version-only",
            "text": "This option is only visible if the discount type is Cart Discount or Cart % Discount.  By default, When the coupon is setup as a 'Cart Discount' it will never validate a coupon when an excluded product is in the cart (this is how WooCommerce Coupons work). By checking this box the coupon will still validate when an excluded product is in the cart. Useful for cart discounts based on a subtotal of matching products, but having some products or categories excluded.",
            "title": "Discount on cart with excluded products (PRO Version Only)"
        },
        {
            "location": "/usage/#free-products",
            "text": "In the 'Free products'-field on the 'Free products'-tab you can enter one or more products that will automatically be added to the cart when the coupon is applied. The product will automatically be removed when the coupon is no longer valid.   Watch video  If you tick the 'select one'-checkbox, the customer must choose one (or more) of the selected products on the cart or checkout page. The customer can also choose the desired variations of a variable product. You can also edit the message that is displayed.   If you wish to change the look-and-feel of the product selection you must create a subdirectory woocommerce-auto-added-coupons-pro in your themes directory  and copy and edit the files templates/cart/select-free-product.php and templates/checkout/select-free-product.php in here.",
            "title": "Free products"
        },
        {
            "location": "/usage/#multiplication-of-free-products",
            "text": "When the box 'Allow multiplication of the free products' is checked the amount of free products will be multiplied every time the minimum spend, subtotal or quantity is reached. For example if the minimum spend is $ 50 and the user has $ 160 worth of products in the cart, the free products will be added 3 times to the cart.",
            "title": "Multiplication of free products"
        },
        {
            "location": "/usage/#checkout",
            "text": "On the checkout-tab restrictions can be entered that will normally only be active when the customer initiates checkout.",
            "title": "Checkout"
        },
        {
            "location": "/usage/#shipping-methods",
            "text": "The coupon will only validate if the customer selects one of these shipping methods.",
            "title": "Shipping methods"
        },
        {
            "location": "/usage/#payment-methods",
            "text": "The coupon will only validate if the customer selects one of these payment methods.",
            "title": "Payment methods"
        },
        {
            "location": "/usage/#customer-restrictions",
            "text": "",
            "title": "Customer restrictions"
        },
        {
            "location": "/usage/#allowed-customer",
            "text": "When you enter one or more customers here, the coupon will only validate if the customer is logged in and is in this list.",
            "title": "Allowed customer"
        },
        {
            "location": "/usage/#allowed-user-roles",
            "text": "When you enter one or more user roles here, the coupon will only validate if the customer has one of these user roles (e.g. Wholesale buyer or Guest).",
            "title": "Allowed user roles"
        },
        {
            "location": "/usage/#disallowed-user-roles",
            "text": "The coupon will only validate if the customer does not have any of these user roles (e.g. Wholesale buyer or Guest).",
            "title": "Disallowed user roles"
        },
        {
            "location": "/usage/#miscellaneous",
            "text": "",
            "title": "Miscellaneous"
        },
        {
            "location": "/usage/#auto-coupon",
            "text": "You can convert a coupon into a discount rule simply by ticking the \"Auto coupon\" checkbox on the 'miscellaneous'-tab. When using this option it is important to enter a description for the coupon, as this will be presented to the customer.  When this option is activated, the discount will automatically be applied to the cart when it's conditions are met and the description will be presented to the customer and on the cart page. Once the conditions are no longer met, for example when the customer removes an item from the cart, the discount will be removed from the cart.",
            "title": "Auto coupon"
        },
        {
            "location": "/usage/#apply-silently",
            "text": "When this box is checked, no 'Discount applied' notice will be presented when the coupon is applied.",
            "title": "Apply silently"
        },
        {
            "location": "/usage/#allow-applying-when-invalid",
            "text": "(PRO Version Only)  When the box 'Allow applying when invalid' is ticked, a customer can always add the coupon to the cart, but will be presented with a message that the discount will only apply when the conditions are met.  NOTE: This option is not available for 'Auto coupons'.",
            "title": "Allow applying when invalid"
        },
        {
            "location": "/usage/#coupon-by-url",
            "text": "Now you can easily create a link that will automatically apply a coupon to the user's cart, optionally in combination with a product.  Simply append ?apply_coupon=coupon_code to the url. If you also want to add products to the cart with the same url, you can use add-to-cart=product_id and optionally a quantity. You can find the id of a product on the WooCommerce Edit-page of the product.  Example:  (http://www.your-store.nl/cart/?add-to-cart=4321&quantity=3&apply_coupon=my_coupon)[#]  If the customer opens the url when the conditions of the coupon are not yet met or the cart is empty the coupon won't be applied yet, instead the following message will be displayed: Coupon will be applied once it's conditions are met. Once the conditions of the coupon are met it will be applied automatically.",
            "title": "Coupon by URL"
        },
        {
            "location": "/usage/#automatic-updates",
            "text": "(PRO Version Only)  To receive automatic updates, you need to enter the licence key.\nNOTE: This is only possible if you purchased the plugin at soft79.nl.  Go to:   wp-admin > Settings > WooCommerce Extended Coupon Features   Enter the domain and licence key. The licence will be automatically activated.  To deactivate a licence key for a domain (e.g. to move it to a different domain) just empty the fields and save the settings. The licence will automatically be deactivated for the domain and can be used on a different domain.  You can also manage you licence activations from  your account  page at soft79.nl.",
            "title": "Automatic updates"
        },
        {
            "location": "/development/",
            "text": "Filters and Actions\n\n\nThese filters are called by WooCommerce Extended Coupon Features:\n\n\napply_filters( 'wjecf_bogo_product_amount_for_coupon', $qty, $coupon );\napply_filters( 'wjecf_set_free_product_amount_in_cart', $quantity, $product );\napply_filters( 'wjecf_free_product_amount_for_coupon', $coupon_qty, $coupon );\napply_filters( 'wjecf_free_cart_item_price', __('Free!', 'woocommerce'), $price_html, $cart_item, $cart_item_key );\napply_filters( 'wjecf_free_cart_item_subtotal', __('Free!', 'woocommerce'), $price_html, $cart_item, $cart_item_key );\napply_filters( 'wjecf_coupon_can_be_applied', $can_be_applied, $coupon );\napply_filters( 'wjecf_coupon_has_a_value', $has_a_value, $coupon );\n\n\n\n\nThese actions are called by WooCommerce Extended Coupon Features:\n\n\ndo_action( 'wjecf_coupon_metabox_checkout', $thepostid, $post );\ndo_action( 'wjecf_coupon_metabox_customer', $thepostid, $post );\ndo_action( 'wjecf_woocommerce_coupon_options_extended_features', $thepostid, $post );\ndo_action( 'wjecf_coupon_metabox_misc', $thepostid, $post );\ndo_action( 'wjecf_coupon_metabox_products', $thepostid, $post );\ndo_action( 'wjecf_coupon_metabox_free_products', $thepostid, $post );\ndo_action( 'wjecf_init_plugins');\ndo_action( 'wjecf_assert_coupon_is_valid', $coupon );\n\n\n\n\nAPI Functions\n\n\nThe API functions are in WJECF_Pro_Api.php and can be called using \nWJECF_API()->function_name()\n.\n\n\nDocumentation is not yet available, but see \nwjecf-pro-api-example.php\n for reference.\n\n\nCreate mini-plugins for Extended Coupon Features\n\n\nYou can further extend functionality of WooCommerce Extended Coupon Features by creating your own mini-plugins.\n\n\n\n\nHook into the \nwjecf_init_plugins\n-action. (Using this hook guarantees that the WooCommerce and WooCommerce Extended Coupon Features plugins are loaded)\n\n\nHere, create a class that extends \nAbstract_WJECF_Plugin\n.\n\n\nCreate a constructor \n__construct()\n, where you setup the plugin data by calling \n$this->set_plugin_data\n\n\nCreate a function \ninit_hook()\n, where you setup your plugin and define frontend hooks.\n\n\nCreate a function \ninit_admin_hook()\n, where you setup your plugin for admin usage and define admin hooks.\n\n\n\n\n(Version 2.5.1+ only) If your plugin need to handle custom meta fields, use the WooCommerce meta box functions (e.g. \nwoocommerce_wp_select\n).\n\n\nTo handle the sanitization of these fields, create a function \nadmin_coupon_meta_fields( $coupon )\n\nand have it return an array \n[ 'field_name' => 'sanitization', ... ]\n .\n\n\nUpon saving a coupon, these fields will be automatically read from \n$_POST\n and sanitized with the given sanitization method, \ne.g. \n'int'\n, \n'int[]'\n, \n'yesno'\n, \n'decimal'\n, \n'clean'\n or even a callback: \n[ 'callback' => callback ]\n and saved to the current coupon. \n\n\nFor versions prior to 2.5.1, you need to handle process_shop_coupon_meta yourself.\n\n\n\n\n\n\nLoad the class by calling \nWJECF()->add_plugin( 'NameOfYourClass')\n\n\n\n\n\n\nExample:\n\n\n<?php\n/**\nPlugin Name: WJECF Example plugin - Allow a coupon on certain weekdays only\nDescription: An example on how to extend WooCommerce Extended Coupon Features\nAuthor: Soft79\nVersion: 1.0\nAuthor URI: http://www.soft79.nl/\n*/\n\nadd_action( 'wjecf_init_plugins', 'setup_my_wjecf_example_plugin' );\n\nfunction setup_my_wjecf_example_plugin() {\n\n    class WJECF_Plugin_Example extends Abstract_WJECF_Plugin {\n\n        //This is the meta-key where the weekday will be saved\n        //HINT: Prepend it with _wjecf_<your plugin name> to avoid naming conflicts\n        const META_KEY_WEEKDAY = '_wjecf_example_plugin_weekday';\n\n        /**\n         * In the constructor you can supply general information about your WJECF-plugin.\n         */\n        public function __construct() {\n            $this->set_plugin_data( array(\n                'description' => __( 'WJECF Example plugin - Accept a coupon on certain weekdays only.', 'your-text-domain' ),\n                'dependencies' => array(),\n                'minimal_wjecf_version' => '2.5.1',\n                'can_be_disabled' => true\n            ) ); \n        }\n\n//FRONTEND\n\n        /**\n         * This function is called when WooCommerce and all other plugins are loaded.\n         * Here you can setup frontend hooks.\n         */\n\n        public function init_hook() {\n            add_action( 'woocommerce_coupon_is_valid', array( $this, 'filter_woocommerce_coupon_is_valid' ), 10, 2 );\n        }\n\n\n        /**\n         * Invalidates the coupon if the weekday is not ok\n         * @param bool $valid \n         * @param WC_Coupon $coupon \n         * @return bool False if invalid\n         */\n\n        public function filter_woocommerce_coupon_is_valid( $valid, $coupon ) {            \n            if ( is_callable( array( $coupon, 'get_meta' ) ) ) {\n                //WC3.0+\n                $coupon_weekday = $coupon->get_meta( self::META_KEY_WEEKDAY );\n            } else {\n                //Older WC versions\n                $coupon_weekday = get_post_meta( $coupon->id, self::META_KEY_WEEKDAY, true );\n            }\n\n            //Not valid if the weekday differs\n            if ( is_numeric( $coupon_weekday ) && date('w') != $coupon_weekday ) {\n                return false;\n            }\n\n            return $valid;\n        }        \n\n//ADMIN\n\n        /**\n         * This function is called when WooCommerce and all other plugins are loaded and we are on the admin section of WordPress.\n         * Here you can setup admin hooks.\n         */\n        public function init_admin_hook() {\n            add_action( 'woocommerce_coupon_options_usage_restriction', array( $this, 'action_woocommerce_coupon_options_usage_restriction' ), 9999 ); //9999 is at the bottom of the tab\n        }\n\n        /**\n         * Automatically called at the process_shop_coupon_meta action (WJECF 2.5.1+ only).\n         * \n         * Returns an array [ meta_key => sanitizion_rule, ... ] with the meta fields that must be saved if the user clicks 'Update' on the coupon admin page.         * \n         * Valid sanitizion rules are: 'html', 'clean', 'yesno', 'decimal', 'int', 'int[]' (array of ints), 'int,' (comma separated ints)\n         * \n         * $_POST[meta_key] will be sanitized and automatically saved.\n         * \n         * @since 2.5.1\n         * @param WC_Coupon $coupon The coupon that will be saved\n         * @return array An array with [ key => sanitizion_rule, ... ]\n         */\n        public function admin_coupon_meta_fields( $coupon ) {\n            return array( self::META_KEY_WEEKDAY => 'int' );\n        }\n\n        /**\n         * This is called when the usage restrictions tab is rendered.\n         */\n        public function action_woocommerce_coupon_options_usage_restriction() {\n            woocommerce_wp_select(\n                array(\n                    'id' => self::META_KEY_WEEKDAY, \n                    'label' => __( 'Weekday', 'woocommerce-jos-autocoupon' ), \n                    'options' => array(\n                        '' => '(Always valid)',\n                        0 => 'Sunday',\n                        1 => 'Monday',\n                        2 => 'Tuesday',\n                        3 => 'Wednesday',\n                        4 => 'Thursday',\n                        5 => 'Friday',\n                        6 => 'Saturday'\n                    ),\n                    'description' => __( 'Coupon is only valid on this weekday.', 'your-text-domain' ),\n                    'desc_tip' => true\n                )\n            );\n        } \n    }\n\n    //Loads the plugin!\n    WJECF()->add_plugin( 'WJECF_Plugin_Example' );\n}",
            "title": "Development"
        },
        {
            "location": "/development/#filters-and-actions",
            "text": "These filters are called by WooCommerce Extended Coupon Features:  apply_filters( 'wjecf_bogo_product_amount_for_coupon', $qty, $coupon );\napply_filters( 'wjecf_set_free_product_amount_in_cart', $quantity, $product );\napply_filters( 'wjecf_free_product_amount_for_coupon', $coupon_qty, $coupon );\napply_filters( 'wjecf_free_cart_item_price', __('Free!', 'woocommerce'), $price_html, $cart_item, $cart_item_key );\napply_filters( 'wjecf_free_cart_item_subtotal', __('Free!', 'woocommerce'), $price_html, $cart_item, $cart_item_key );\napply_filters( 'wjecf_coupon_can_be_applied', $can_be_applied, $coupon );\napply_filters( 'wjecf_coupon_has_a_value', $has_a_value, $coupon );  These actions are called by WooCommerce Extended Coupon Features:  do_action( 'wjecf_coupon_metabox_checkout', $thepostid, $post );\ndo_action( 'wjecf_coupon_metabox_customer', $thepostid, $post );\ndo_action( 'wjecf_woocommerce_coupon_options_extended_features', $thepostid, $post );\ndo_action( 'wjecf_coupon_metabox_misc', $thepostid, $post );\ndo_action( 'wjecf_coupon_metabox_products', $thepostid, $post );\ndo_action( 'wjecf_coupon_metabox_free_products', $thepostid, $post );\ndo_action( 'wjecf_init_plugins');\ndo_action( 'wjecf_assert_coupon_is_valid', $coupon );",
            "title": "Filters and Actions"
        },
        {
            "location": "/development/#api-functions",
            "text": "The API functions are in WJECF_Pro_Api.php and can be called using  WJECF_API()->function_name() .  Documentation is not yet available, but see  wjecf-pro-api-example.php  for reference.",
            "title": "API Functions"
        },
        {
            "location": "/development/#create-mini-plugins-for-extended-coupon-features",
            "text": "You can further extend functionality of WooCommerce Extended Coupon Features by creating your own mini-plugins.   Hook into the  wjecf_init_plugins -action. (Using this hook guarantees that the WooCommerce and WooCommerce Extended Coupon Features plugins are loaded)  Here, create a class that extends  Abstract_WJECF_Plugin .  Create a constructor  __construct() , where you setup the plugin data by calling  $this->set_plugin_data  Create a function  init_hook() , where you setup your plugin and define frontend hooks.  Create a function  init_admin_hook() , where you setup your plugin for admin usage and define admin hooks.   (Version 2.5.1+ only) If your plugin need to handle custom meta fields, use the WooCommerce meta box functions (e.g.  woocommerce_wp_select ).  To handle the sanitization of these fields, create a function  admin_coupon_meta_fields( $coupon ) \nand have it return an array  [ 'field_name' => 'sanitization', ... ]  .  Upon saving a coupon, these fields will be automatically read from  $_POST  and sanitized with the given sanitization method, \ne.g.  'int' ,  'int[]' ,  'yesno' ,  'decimal' ,  'clean'  or even a callback:  [ 'callback' => callback ]  and saved to the current coupon.   For versions prior to 2.5.1, you need to handle process_shop_coupon_meta yourself.    Load the class by calling  WJECF()->add_plugin( 'NameOfYourClass')    Example:  <?php\n/**\nPlugin Name: WJECF Example plugin - Allow a coupon on certain weekdays only\nDescription: An example on how to extend WooCommerce Extended Coupon Features\nAuthor: Soft79\nVersion: 1.0\nAuthor URI: http://www.soft79.nl/\n*/\n\nadd_action( 'wjecf_init_plugins', 'setup_my_wjecf_example_plugin' );\n\nfunction setup_my_wjecf_example_plugin() {\n\n    class WJECF_Plugin_Example extends Abstract_WJECF_Plugin {\n\n        //This is the meta-key where the weekday will be saved\n        //HINT: Prepend it with _wjecf_<your plugin name> to avoid naming conflicts\n        const META_KEY_WEEKDAY = '_wjecf_example_plugin_weekday';\n\n        /**\n         * In the constructor you can supply general information about your WJECF-plugin.\n         */\n        public function __construct() {\n            $this->set_plugin_data( array(\n                'description' => __( 'WJECF Example plugin - Accept a coupon on certain weekdays only.', 'your-text-domain' ),\n                'dependencies' => array(),\n                'minimal_wjecf_version' => '2.5.1',\n                'can_be_disabled' => true\n            ) ); \n        }\n\n//FRONTEND\n\n        /**\n         * This function is called when WooCommerce and all other plugins are loaded.\n         * Here you can setup frontend hooks.\n         */\n\n        public function init_hook() {\n            add_action( 'woocommerce_coupon_is_valid', array( $this, 'filter_woocommerce_coupon_is_valid' ), 10, 2 );\n        }\n\n\n        /**\n         * Invalidates the coupon if the weekday is not ok\n         * @param bool $valid \n         * @param WC_Coupon $coupon \n         * @return bool False if invalid\n         */\n\n        public function filter_woocommerce_coupon_is_valid( $valid, $coupon ) {            \n            if ( is_callable( array( $coupon, 'get_meta' ) ) ) {\n                //WC3.0+\n                $coupon_weekday = $coupon->get_meta( self::META_KEY_WEEKDAY );\n            } else {\n                //Older WC versions\n                $coupon_weekday = get_post_meta( $coupon->id, self::META_KEY_WEEKDAY, true );\n            }\n\n            //Not valid if the weekday differs\n            if ( is_numeric( $coupon_weekday ) && date('w') != $coupon_weekday ) {\n                return false;\n            }\n\n            return $valid;\n        }        \n\n//ADMIN\n\n        /**\n         * This function is called when WooCommerce and all other plugins are loaded and we are on the admin section of WordPress.\n         * Here you can setup admin hooks.\n         */\n        public function init_admin_hook() {\n            add_action( 'woocommerce_coupon_options_usage_restriction', array( $this, 'action_woocommerce_coupon_options_usage_restriction' ), 9999 ); //9999 is at the bottom of the tab\n        }\n\n        /**\n         * Automatically called at the process_shop_coupon_meta action (WJECF 2.5.1+ only).\n         * \n         * Returns an array [ meta_key => sanitizion_rule, ... ] with the meta fields that must be saved if the user clicks 'Update' on the coupon admin page.         * \n         * Valid sanitizion rules are: 'html', 'clean', 'yesno', 'decimal', 'int', 'int[]' (array of ints), 'int,' (comma separated ints)\n         * \n         * $_POST[meta_key] will be sanitized and automatically saved.\n         * \n         * @since 2.5.1\n         * @param WC_Coupon $coupon The coupon that will be saved\n         * @return array An array with [ key => sanitizion_rule, ... ]\n         */\n        public function admin_coupon_meta_fields( $coupon ) {\n            return array( self::META_KEY_WEEKDAY => 'int' );\n        }\n\n        /**\n         * This is called when the usage restrictions tab is rendered.\n         */\n        public function action_woocommerce_coupon_options_usage_restriction() {\n            woocommerce_wp_select(\n                array(\n                    'id' => self::META_KEY_WEEKDAY, \n                    'label' => __( 'Weekday', 'woocommerce-jos-autocoupon' ), \n                    'options' => array(\n                        '' => '(Always valid)',\n                        0 => 'Sunday',\n                        1 => 'Monday',\n                        2 => 'Tuesday',\n                        3 => 'Wednesday',\n                        4 => 'Thursday',\n                        5 => 'Friday',\n                        6 => 'Saturday'\n                    ),\n                    'description' => __( 'Coupon is only valid on this weekday.', 'your-text-domain' ),\n                    'desc_tip' => true\n                )\n            );\n        } \n    }\n\n    //Loads the plugin!\n    WJECF()->add_plugin( 'WJECF_Plugin_Example' );\n}",
            "title": "Create mini-plugins for Extended Coupon Features"
        },
        {
            "location": "/changelog/",
            "text": "= 2.6.0 =\n*Release Date - 2017-12-02*\n* ADMIN: Compatibility with coupons added on the Order page from wp-admin (requires WC3.3+)\n* ADMIN: Show 'settings' link on the plugin screen\n* INTERNAL: Moved debugging functions to WJECF_Debug. Use template/log.php for output rendering of the log\n* (PRO) FEATURE: Limit coupon to first time purchase only\n* (PRO) ENHANCEMENT: Free products: Better grid layout of the free product selector\n* (PRO) ENHANCEMENT: Free products: Auto submit of selection (works for inputs in container with class 'wjecf-auto-submit')\n* (PRO) FIX: Free products: Respect \"sold individually\" when adding free products to the cart\n* (PRO) FIX: Free products: WC2.6 compatibility (product->get_status())\n\n= 2.5.5.1 = \n*Release Date - 2017-11-07*\n* (PRO) FIX: 'Limit discount to' not applied correctly in combination with WC3.2.3\n\n= 2.5.5 =\n*Release Date - 2017-11-01*\n* (PRO) FIX: Free products: Removed unnecessary $lt;tr&gt; in cart / checkout table if no free product selection applies\n* (PRO) FIX: Free products: Preserve notices when updating cart after applying/removing a coupon\n* (PRO) FIX: Free products: Compatibility with Subscriptions plugin (prevent trigger of calculate_totals when adding free product to the cart)\n* (PRO) FIX: Free products: Compatibility with WPML plugin (translation of the free products)\n\n= 2.5.4 =\n*Release Date - 2017-09-23*\n* TWEAK: Get coupon description using WC_Coupon::get_description() to respect applicable filters (for example used by Polylang)\n* (PRO) FEATURE: Allow customer to remove 'Auto Coupons' from the cart (see settings page)\n* (PRO) FEATURE: Filter 'wjecf_get_limit_to_options' to allow adding custom 'Limit to'-options\n* (PRO) PERFORMANCE: Free products: Only load js and css when required\n* (PRO) FIX: Free products: \"update cart\"-button not automatically enabled after selecting a free product (in combination with certain themes (e.g. Flatsome)\n* (PRO) FIX: Free products: Prevent certain plugins from parsing attribute fields containing [products] as shortcode\n* (PRO) FIX: Limit discount to cheapest item failed in WC3.0 in combination with a percent discount\n* (PRO) FIX: Custom fields: Accept WC3.0 core fields (e.g. _price)\n* (PRO) FIX: PHP Warnings in WJECF_Pro_Admin_Auto_Update\n\n= 2.5.3 =\n*Release Date - 2017-06-12*\n* (PRO) FIX: Free products: Free product selection always visible on checkout-page\n* (PRO) FIX: Free products: JS error when using IE / Safari\n* (PRO) FIX: Free products: Cart contents was not updated when applying a coupon\n* (PRO) FIX: Free products: wjecf_free_product_amount_for_coupon not called for $max_quantity variable in the template\n\n= 2.5.2.2 =\n*Release Date - 2017-06-01*\n* (PRO) FIX: Documentation url\n* (PRO) FIX: Forgot to raise version number, causing a permanent 'An update is available'\n\n= 2.5.2.1 =\n*Release Date - 2017-06-01*\n* (PRO) FIX: Duplicate products at free product selection\n\n= 2.5.2 =\n* (PRO) FEATURE: Free product selection using checkboxes / numeric inputs\n* (PRO) FIX: Free product selection fails if coupon code contains a space\n* (PRO) FIX: CSS for column system used by the free product selection\n* DOCUMENTATION: Added the API part to the documentation (work in progress)\n\n= 2.5.1 =\n* FIX: Draft settings not being saved\n* FIX: PHP < 5.5 compatibility\n* FIX: Abstract_WJECF_Plugin log function\n* INTERNAL: Functions add_action_once / add_filter_once. To guarantee execution only once.\n* INTERNAL: Updated the API example; also usable from CLI\n* INTERNAL: Created Sanitizer for form data handling\n* INTERNAL: Reorganised coupon meta handling ( Abstract_WJECF_Plugin::admin_coupon_meta_fields )\n\n= 2.5.0 =\n* (PRO) FEATURE: Auto update!\n* (PRO) FEATURE: Checkbox 'Allow applying coupon when invalid'\n* (PRO) FEATURE: Custom message when applying a coupon which does not yet validate\n* FEATURE: Settings page\n* FEATURE REMOVED: Experimental feature 'Allow when minimum spend not reached' (Use 'Allow applying coupon when invalid' instead)\n* COSMETIC: Products tab is now 'Free Products' tab. Moved other items to the 'Usage restriction'-tab\n* FIX: Issue with 'Allow discount on cart with excluded items'\n* FIX: Notice if a free product without weight is added/removed to/from the cart\n* FIX: Deprecation notice in WJECF_AutoCoupon::sort_auto_coupons\n* INTERNAL: Introduced 'allow_overwrite_coupon_values'\n\n= 2.4.3 =\n* FIX: Customer selector WooCommerce 3.0.0 compatibility\n\n= 2.4.2.1 =\n* FIX: WooCommerce < 2.7 compatibility\n\n= 2.4.2 =\n* FIX: Invalid calculation of subtotal/quantity of matching product since WC 3.0.0\n* FIX: Missing \"PRODUCT AND/OR\" selector on Admin since WC 3.0.0 (Javascript)\n* FIX: WooCommerce version detection if woocommerce is not installed in /wp-content/plugins/woocommerce directory\n\n= 2.4.1 =\n* (PRO) FIX: Product selector compatability with select2 v4 (WooCommerce 3.0)\n\n= 2.4.0 =\n* FIX: WooCommerce 3.0.0 Compatibility\n* INTERNAL: Also load textdomain from WP_LANG_DIR/woocommerce-jos-autocoupon/woocommerce-jos-autocoupon-LOCALE.mo\n\n= 2.3.7.5 = \n* FIX: Limit usage to cheapest discounting the wrong product when the quantity of cheapest product was greater than 1.\n\n= 2.3.7.4 = \n* FIX: Combining add-to-cart and apply_coupon in a single querystring\n\n= 2.3.7.3 = \n* FIX: Invalid usage of get_plugin_data\n\n= 2.3.7.2 = \n* FIX: Backwards compatibility with WooCommerce < 2.5.0\n* INTERNAL: Introducing WJECF_WC() to maintain backwards compatibility\n\n= 2.3.7.1 = \n* (PRO) FIX: Bug in 'Limit discount to'\n\n= 2.3.7 =\n* PERFORMANCE: Admin could hang in some occasions on a jQuery-selector\n* FIX: Suppresed warnings were displayed by the Query Monitor plugin if pro files are missing\n* FIX: WPML Compatibility\n* FIX: Invalid textdomain in woocommerce_coupon_error (Thanks, 7o599)\n* (PRO) FIX: 'Limit discount to' skipped non-matching products on cart % discount\n* (PRO) FEATURE: Limit discount to every nth (matching) item in the cart\n\n= 2.3.6 =\n* FIX: Compatibility with WooCommerce < 2.3.0 for coupon by url\n* COSMETIC: On the admin page, moved AND/OR selector near the product/categories input\n* (PRO) FEATURE: Filter matching products by custom field.\n\n= 2.3.5 =\n* (PRO) FIX: Workaround for missing WooCommerce 2.6.3 constant WC_ROUNDING_PRECISION\n* (PRO) FIX: Refresh the cart when a coupon is applied/removed by AJAX (to add/remove free products)\n\n= 2.3.4 =\n* FIX: WooCommerce 2.6 and UPS / USPS Shipping method compatibility ( those plugins use : as separator )\n* FIX: Coupon by url (hook on wp_loaded instead of init)\n* FIX: Admin pages invalid parsing of Chosen inputboxes WooCommerce < 2.3.0\n* FIX: Free product on WooCommerce < 2.3.0\n* INTERNAL: Rewritten overwrite_success_message methods\n* (PRO) Ajax 'Apply coupon' support for free product selection on cart and checkout page. (OVERRIDEABLE TEMPLATE FILES UPDATED!)\n* (PRO) FEATURE: Remember coupons that are not valid when applying (on the cart page) and apply them automatically when they validate\n\n= 2.3.3 =\n* FIX: limit_usage_to_x_items: Removed call to get_discount_amount from coupon_has_a_value; it is redundant and caused limit_usage_to_x_items to change\n* (PRO) FEATURE: Filters wjecf_free_product_amount_for_coupon, wjecf_bogo_product_amount_for_coupon and wjecf_set_free_product_amount_in_cart\n* (PRO) FEATURE: Keep track of by-url-coupons (?apply_coupon=) and apply when they validate\n* (PRO) FIX: Experimental feature 'Allow discount on cart with excluded items' didn't work since 2.2.3\n* (PRO) FIX: Invalid free product quantity applied when using both BOGO and FREE products in a single coupon.\n* (PRO) FIX: limit_usage_to_x_items: Possible wrong discount on combination of limit_usage_to_x_items and \\_wjecf_apply_discount_to\n\n= 2.3.2 =\n* FEATURE: Display custom error message when coupon is invalidated by this plugin\n* FIX: apply_coupon redirected to wrong url when home_url contained a subdirectory\n* FIX: Remove add-to-cart when redirecting for apply_coupon\n* FIX: Auto Coupon Backwards compatability for WooCommerce versions prior to 2.3.0 that don't have hook woocommerce_after_calculate_totals\n* TRANSLATION: Persian. Thanks to Ehsan Shahnazi.\n\n= 2.3.1.1 =\n* TRANSLATION: Brazilian Portuguese. Thanks to Francisco.\n\n= 2.3.1 =\n* FIX: WPML Compatibility for AND Products / AND Categories\n* FIX: Redirect to page without ?apply_coupon= after applying coupon by url\n* FIX: Auto coupon meta_query issue (thanks to hwillson)\n* FIX: Compatibility with WooCommerce prior to 2.2.9 (WC_Cart::get_cart_item)\n* (PRO) FIX: Free products: Add variant attributes to cart items for variable products\n* (PRO) FEATURE: Apply discount only to the cheapest product\n\n= 2.3.0 =\n* (PRO) FEATURE: Allow customer to choose a free product\n* (PRO) FEATURE: Setting the priority of auto coupons (Useful for Individual use coupons)\n* (PRO) FEATURE: Display extra columns on the Coupon Admin page (auto coupon, individual use, priority, free products)\n* (PRO) TWEAK: Free products: Display 'Free!' as subtotal for free products, (adaptable with filter 'wjecf_free_cart_item_subtotal' )\n* (PRO) FIX: Free products: Plugin wouldn't always detect the free products in cart and kept appending free products\n* (PRO) Introduction of the API for developers, see wjecf-pro-api.php\n* FEATURE: Filter to only display Auto Coupons on the Coupon Admin page\n* FIX: Compatibilty PHP 5.4\n* FIX: Rewritten and simplified Autocoupon removal/addition routine making it more robust\n* FIX: Multiplier value calculation (as for now only used for Free Products)\n* FIX: Coupon must never be valid for free products (_wjecf_free_product_coupon set in cart_item)\n* INTERNAL: Refactoring of all classes\n* INTERNAL: New log for debugging\n\n= 2.2.5.1 =\n* FIX: When checkbox 'Individual use' was ticked, Autocoupons would be removed/added multiple times\n\n= 2.2.5 =\n* (PRO) FEATURE: BOGO On all matching products\n* FIX: Changed WooCommerce detection method for better Multi Site support\n* (PRO) FIX: Free products: Fixed an inconsistency that could cause a loop on removal/adding of free variant products\n* (PRO) TWEAK: Free products: Hooking before_calculate_totals for most cases but also on woocommerce_applied_coupon, which is required when one coupon is replaced by another\n* INTERNAL: Check if classes already exist before creating them\n\n= 2.2.4 =\n* FEATURE: Online documentation added\n* FEATURE: Use AND-operator for the selected categories (default is OR)\n* FIX: Backwards compatibility with WooCommerce 2.3.7 (WC_Cart::is_empty)\n* FIX: Backwards compatibility with WooCommerce < 2.3.0 (WC_Coupon::is_type, Chosen in stead of Select2)\n\n= 2.2.3 =\n* (PRO) FEATURE: Allow discount on cart with excluded items\n* (PRO) FEATURE: Free products!\n* FEATURE: Allow coupon in cart even if minimum spend not reached\n* FEATURE: New coupon feature: Minimum / maximum price subtotal of matching products in the cart\n* COSMETIC: Admin Extended coupon features in multiple tabs\n* FIX: Create session cookie if no session was initialized when applying coupon by url\n* TWEAK: Auto coupon: Use woocommerce_after_calculate_totals hook for update_matched_autocoupons\n* API: New function: $wjecf_extended_coupon_features->get_quantity_of_matching_products( $coupon )\n* API: New function: $wjecf_extended_coupon_features->get_subtotal_of_matching_products( $coupon )\n\n= 2.2.1 =\n* FIX: Prevent mulitple apply_coupon calls (for example through ajax)\n* FIX: Don't redirect to cart when using WooCommerce's ?add-to-cart=xxx in combination with ?apply_coupon=xxx as this would prevent the application of the coupon.\n\n= 2.2.0 =\n* FIX: Lowered execution priority for apply_coupon by url for combinations with add-to-cart.\n* FEATURE: New coupon feature: Excluded customer role restriction\n* FEATURE: New coupon feature: Customer / customer role restriction\n* FEATURE: New coupon feature: Minimum / maximum quantity of matching products in the cart\n* FEATURE: New coupon feature: Allow auto coupons to be applied silently (without displaying a message)\n* TWEAK: Moved all settings to the 'Extended features'-tab on the admin page.\n* FIX: 2.0.0 broke compatibility with PHP versions older than 5.3\n* FIX: Changed method to fetch email addresses for auto coupon with email address restriction\n* FILTER: Filter wjecf_coupon_has_a_value (An auto coupon will not be applied if this returns false)\n* FILTER: Filter wjecf_coupon_can_be_applied (An auto coupon will not be applied if this returns false)\n* INTERNAL: db_version tracking for automatic updates\n* INTERNAL: Consistent use of wjecf prefix. \n* INTERNAL: Renamed meta_key woocommerce-jos-autocoupon to \\_wjecf_is_auto_coupon\n\n= 2.0.0 =\n* RENAME: Renamed plugin from \"WooCommerce auto added coupons\" to \"WooCommerce Extended Coupon Features\"\n* FEATURE: Restrict coupons by payment method\n* FEATURE: Restrict coupons by shipping method  \n* FEATURE: Use AND-operator for the selected products (default is OR)\n* FIX: Validate email restrictions for auto coupons\n* Norwegian translation added (Thanks to Anders Zorensen)\n\n= 1.1.5 =\n* FIX: Cart total discount amount showing wrong discount value in newer WooCommerce versions (tax)\n* Performance: get_all_auto_coupons select only where meta woocommerce_jos_autocoupon = yes (Thanks to ircary)\n\n= 1.1.4 =\n* Translation support through .mo / .po files\n* Included translations: Dutch, German, Spanish (Thanks to stephan.sperling for the german translation)\n\n= 1.1.3.1 =\n* FIX: Apply auto coupon if discount is 0.00 and free shipping is ticked    \n\n= 1.1.3 =\n* Don't apply coupon if the discount is 0.00\n* Allow applying multiple coupons via an url using *?apply_coupon=coupon_code1,coupon_code2*\n\n= 1.1.2 =\n* Minor change to make the plugin compatible with WooCommerce 2.3.1\n* Loop through coupons in ascending order\n\n= 1.1.1 =\n* Tested with Wordpress 4.0\n\n= 1.1.0 =\n* Allow applying coupon via an url using *?apply_coupon=coupon_code*\n\n= 1.0.1 =\n* Don't add the coupon if *Individual use only* is checked and another coupon is already applied.\n\n= 1.0 =\n* First version ever!",
            "title": "Changelog"
        }
    ]
}