├── .gitignore ├── README.md ├── index.php ├── languages └── woocommerce-dynamic-pricing-table.pot ├── readme.txt └── woocommerce-dynamic-pricing-table.php /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X metadata 2 | .DS_Store 3 | 4 | # Windows junk 5 | Thumbs.db 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WooCommerce Dynamic Pricing Table 2 | 3 | This extension will add a pricing table and other discount notifications for customers on the frontend of your WooCommerce store when using the [WooCommerce Dynamic Pricing](https://www.woocommerce.com/products/dynamic-pricing/) plugin. 4 | 5 | ## Advanced Product Discount Table 6 | 7 | **Note:** The extension does not provide styling for the [Advanced Product Discount](https://docs.woocommerce.com/document/woocommerce-dynamic-pricing/#section-7) table and any table styling must be provided by your theme itself or by CSS you write. The screenshot below is taken from the [WooCommerce Storefront Theme](https://www.woocommerce.com/storefront/) which does have table styling on product pages included within the theme. 8 | 9 |  10 | 11 | ## User Role Discount Messages 12 | 13 | [User Role](https://docs.woocommerce.com/document/woocommerce-dynamic-pricing/#section-2) discount notification messages are displayed on the WooCommerce product sections. 14 | 15 |  16 | 17 | ## Simple Category Discount Messages 18 | 19 | [Simple Category Pricing](https://docs.woocommerce.com/document/woocommerce-dynamic-pricing/#section-4) discount notification messages are displayed on the on WooCommerce product category sections. 20 | 21 |  22 | 23 | ## Installation 24 | 25 | 1. Download the plugin from it's GitHub Repository Download [WooCommerce Dynamic Pricing Table](https://github.com/stuartduff/woocommerce-dynamic-pricing-table). 26 | 2. Goto WordPress > Appearance > Plugins > Add New. 27 | 3. Click Upload Plugin and Choose File, then select the plugin's .zip file. Click Install Now. 28 | 4. Click Activate to use your new plugin right away. 29 | 30 | ## Minimum Requirements 31 | 32 | For this extension to function [WooCommerce](https://www.woocommerce.com/) and the [WooCommerce Dynamic Pricing](https://www.woocommerce.com/products/dynamic-pricing/) extension must be installed and activated on your [WordPress](https://wordpress.org/) site. 33 | 34 | ## FAQ 35 | 36 | > What type of discounts does the extension display. 37 | 38 | * [Advanced Product Discounts](https://docs.woocommerce.com/document/woocommerce-dynamic-pricing/#section-7) on WooCommerce products that have either a bulk or special offer discount applied to them. 39 | * [User Role Discount](https://docs.woocommerce.com/document/woocommerce-dynamic-pricing/#section-2) will display on WooCommerce product sections. 40 | * [Simple Category Pricing](https://docs.woocommerce.com/document/woocommerce-dynamic-pricing/#section-4) will display category discounts on WooCommrce product categories. 41 | 42 | > Are there any limitations to how many product tables will display on an single product. 43 | 44 | Only one advanced product pricing group table will display on any single product, if you have more than one pricing group active on a single product the discount table will then be disabled. 45 | 46 | > Where should I contact if I have an issue with this extension. 47 | 48 | All support requests for this extension should be posted to the [WooCommerce Dynamic Pricing Table Issue Tracker ](https://github.com/stuartduff/woocommerce-dynamic-pricing-table/issues) here on Github. 49 | 50 | ## Changelog 51 | 52 | **1.0.6 - 19/02/20** 53 | * Fix - Various small fixes to stop error messages from displaying in WooCommerce v3.9+ 54 | 55 | **1.0.5 - 05/09/16** 56 | * Fix - Added check to prevent wc_add_notice() from trying to display on admin. 57 | 58 | **1.0.4 - 30/08/16** 59 | * Feature - Added the ability to display [Simple Category Pricing](https://docs.woocommerce.com/document/woocommerce-dynamic-pricing/#section-4) discounts on WooCommerce categories. 60 | 61 | **1.0.3 - 27/08/16** 62 | * Feature - Added the ability to display [User Role Pricing](https://docs.woocommerce.com/document/woocommerce-dynamic-pricing/#section-2) discounts on WooCommerce sections. 63 | 64 | **1.0.2 - 26/08/16** 65 | * Fix - Changed the quantity number output to use the WooCommerce [wc_stock_amount()](https://docs.woocommerce.com/wc-apidocs/function-wc_stock_amount.html) function. 66 | 67 | **1.0.1 - 25/08/16** 68 | * Fix - Changed the monetary number output to use the WooCommerce [wc_price()](https://docs.woocommerce.com/wc-apidocs/function-wc_price.html) function. 69 | * Fix - If the max quantity field of a product pricing group is less than 1 or left blank "or more" text will now display instead of a 0. 70 | 71 | **1.0.0 - 20/06/16** 72 | * Initial Release - first version of the plugin released. 73 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | \n" 9 | "Language-Team: \n" 10 | "Language: \n" 11 | "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "X-Generator: Loco - https://localise.biz/" 16 | 17 | #: woocommerce-dynamic-pricing-table.php:156 18 | msgid "" 19 | "The WooCommerce Dynamic Pricing Table extension requires that you have the " 20 | "WooCommerce Dynamic Pricing plugin installed and activated." 21 | msgstr "" 22 | 23 | #: woocommerce-dynamic-pricing-table.php:156 24 | msgid "Get WooCommerce Dynamic Pricing now" 25 | msgstr "" 26 | 27 | #: woocommerce-dynamic-pricing-table.php:202 28 | #: woocommerce-dynamic-pricing-table.php:259 29 | msgid "Quantity" 30 | msgstr "" 31 | 32 | #: woocommerce-dynamic-pricing-table.php:202 33 | msgid "Bulk Purchase Pricing" 34 | msgstr "" 35 | 36 | #: woocommerce-dynamic-pricing-table.php:210 37 | msgid " or more" 38 | msgstr "" 39 | 40 | #: woocommerce-dynamic-pricing-table.php:222 41 | #: woocommerce-dynamic-pricing-table.php:272 42 | msgid "%1$s Discount Per Item" 43 | msgstr "" 44 | 45 | #: woocommerce-dynamic-pricing-table.php:226 46 | #: woocommerce-dynamic-pricing-table.php:276 47 | msgid "% Discount" 48 | msgstr "" 49 | 50 | #: woocommerce-dynamic-pricing-table.php:230 51 | #: woocommerce-dynamic-pricing-table.php:280 52 | msgid "%1$s Per Item" 53 | msgstr "" 54 | 55 | #: woocommerce-dynamic-pricing-table.php:259 56 | msgid "Special Offer Pricing" 57 | msgstr "" 58 | 59 | #: woocommerce-dynamic-pricing-table.php:267 60 | msgid "Buy %1$s get %2$s more discounted" 61 | msgstr "" 62 | 63 | #: woocommerce-dynamic-pricing-table.php:340 64 | msgid "" 65 | "Hi %1$s as a %2$s you will receive a %3$s percent discount on all products." 66 | msgstr "" 67 | 68 | #: woocommerce-dynamic-pricing-table.php:344 69 | msgid "Hi %1$s as a %2$s you will receive a %3$s discount on all products." 70 | msgstr "" 71 | 72 | #: woocommerce-dynamic-pricing-table.php:390 73 | msgid "" 74 | "You will receive a %1$s percent discount on all products within the %2$s " 75 | "category." 76 | msgstr "" 77 | 78 | #: woocommerce-dynamic-pricing-table.php:394 79 | msgid "" 80 | "You will receive %1$s discount on all products within the %2$s category." 81 | msgstr "" 82 | 83 | #. Name of the plugin 84 | msgid "WooCommerce Dynamic Pricing Table" 85 | msgstr "" 86 | 87 | #. Description of the plugin 88 | msgid "" 89 | "Adds a pricing discount table to WooCommerce products that are offering bulk " 90 | "discounts or special offer discounts via the WooCommerce Dynamic Pricing " 91 | "plugin." 92 | msgstr "" 93 | 94 | #. URI of the plugin 95 | msgid "https://github.com/stuartduff/woocommerce-dynamic-pricing-table" 96 | msgstr "" 97 | 98 | #. Author of the plugin 99 | msgid "Stuart Duff" 100 | msgstr "" 101 | 102 | #. Author URI of the plugin 103 | msgid "http://stuartduff.com" 104 | msgstr "" 105 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === WooCommerce Dynamic Pricing Table === 2 | Contributors: stuartduff 3 | Tags: ecommerce, e-commerce, store, sales, sell, shop, cart, checkout, storefront 4 | Requires at least: 4.5 5 | Tested up to: 4.5.2 6 | Stable tag: 1.0.5 7 | License: GPLv3 8 | License URI: https://www.gnu.org/licenses/gpl-3.0.html 9 | 10 | == Description == 11 | 12 | This extension will add a pricing table and other discount notifications for customers on the frontend of your WooCommerce store when using the [WooCommerce Dynamic Pricing](https://www.woocommerce.com/products/dynamic-pricing/) plugin. 13 | == Installation == 14 | 15 | 1. Download the plugin from it's GitHub Repository Download [WooCommerce Dynamic Pricing Table](https://github.com/stuartduff/woocommerce-dynamic-pricing-table). 16 | 2. Goto WordPress > Appearance > Plugins > Add New. 17 | 3. Click Upload Plugin and Choose File, then select the plugin's .zip file. Click Install Now. 18 | 4. Click Activate to use your new plugin right away. 19 | 20 | == Minimum Requirements == 21 | 22 | For this extension to function [WooCommerce](https://www.woocommerce.com/) and the [WooCommerce Dynamic Pricing](https://www.woocommerce.com/products/dynamic-pricing/) extension must be installed and activated on your WordPress site. 23 | 24 | = FAQ = 25 | 26 | Below are the discounts that the plugin will currently display. 27 | 28 | * [Advanced Product Discounts](https://docs.woocommerce.com/document/woocommerce-dynamic-pricing/#section-7) on WooCommerce products that have either a bulk or special offer discount applied to them. 29 | * [User Role Discount](https://docs.woocommerce.com/document/woocommerce-dynamic-pricing/#section-2) will display on WooCommerce product sections. 30 | * [Simple Category Pricing](https://docs.woocommerce.com/document/woocommerce-dynamic-pricing/#section-4) will display category discounts on WooCommrce product categories. 31 | 32 | == Changelog == 33 | 34 | = 1.0.6 - 19/02/20 = 35 | * Fix - Various small fixes to stop error messages from displaying in WooCommerce v3.9+ 36 | 37 | = 1.0.5 - 05/09/16 = 38 | * Fix - Added check to prevent wc_add_notice() from trying to display on admin. 39 | 40 | = 1.0.4 - 30/08/16 = 41 | * Feature - Added the ability to display Simple Category Pricing discounts on WooCommerce categories. 42 | 43 | = 1.0.3 - 27/08/16 = 44 | * Feature - Added the ability to display User Role Pricing discounts on WooCommerce sections. 45 | 46 | = 1.0.2 - 26/08/16 = 47 | * Fix - Changed the quantity number output to use the WooCommerce [wc_stock_amount()](https://docs.woocommerce.com/wc-apidocs/function-wc_stock_amount.html) function. 48 | 49 | = 1.0.1 - 25/08/16 = 50 | * Fix - Changed the monetary number output to use the WooCommerce wc_price() function. 51 | * Fix - If the max quantity field of a product pricing group is less than 1 or left blank "or more" text will now display instead of a 0. 52 | 53 | = 1.0.0 - 20/06/16 = 54 | * Initial Release - first version of the plugin released. 55 | -------------------------------------------------------------------------------- /woocommerce-dynamic-pricing-table.php: -------------------------------------------------------------------------------- 1 | token = 'woocommerce-dynamic-pricing-table'; 75 | $this->plugin_url = plugin_dir_url( __FILE__ ); 76 | $this->plugin_path = plugin_dir_path( __FILE__ ); 77 | $this->version = '1.0.0'; 78 | 79 | register_activation_hook( __FILE__, array( $this, 'install' ) ); 80 | 81 | add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); 82 | 83 | add_action( 'init', array( $this, 'plugin_setup' ) ); 84 | 85 | } 86 | 87 | /** 88 | * Main WC_Dynamic_Pricing_Table Instance 89 | * 90 | * Ensures only one instance of WC_Dynamic_Pricing_Table is loaded or can be loaded. 91 | * 92 | * @since 1.0.0 93 | * @static 94 | * @see WC_Dynamic_Pricing_Table() 95 | * @return Main WC_Dynamic_Pricing_Table instance 96 | */ 97 | public static function instance() { 98 | if ( is_null( self::$_instance ) ) 99 | self::$_instance = new self(); 100 | return self::$_instance; 101 | } // End instance() 102 | 103 | /** 104 | * Load the localisation file. 105 | * @access public 106 | * @since 1.0.0 107 | * @return void 108 | */ 109 | public function load_plugin_textdomain() { 110 | load_plugin_textdomain( 'woocommerce-dynamic-pricing-table', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 111 | } 112 | 113 | /** 114 | * Installation. 115 | * Runs on activation. Logs the version number. 116 | * @access public 117 | * @since 1.0.0 118 | * @return void 119 | */ 120 | public function install() { 121 | $this->log_plugin_version_number(); 122 | } 123 | 124 | /** 125 | * Log the plugin version number. 126 | * @access private 127 | * @since 1.0.0 128 | * @return void 129 | */ 130 | private function log_plugin_version_number() { 131 | // Log the version number. 132 | update_option( $this->token . '-version', $this->version ); 133 | } 134 | 135 | /** 136 | * Setup all the things. 137 | * Only executes if WooCommerce Dynamic Pricing is active. 138 | * If WooCommerce Dynamic Pricing is inactive an admin notice is displayed. 139 | * @return void 140 | */ 141 | public function plugin_setup() { 142 | if ( class_exists( 'WC_Dynamic_Pricing' ) ) { 143 | add_action( 'woocommerce_before_add_to_cart_button', array( $this, 'output_dynamic_pricing_table' ) ); 144 | 145 | if ( ! is_admin() ) { 146 | add_action( 'wp', array( $this, 'output_dynamic_pricing_role_message' ) ); 147 | add_action( 'wp', array( $this, 'output_dynamic_pricing_category_message' ) ); 148 | } 149 | } else { 150 | add_action( 'admin_notices', array( $this, 'install_wc_dynamic_pricing_notice' ) ); 151 | } 152 | } 153 | 154 | /** 155 | * WooCommerce Dynamic Pricing plugin install notice. 156 | * If the user activates this plugin while not having the WooCommerce Dynamic Pricing plugin installed or activated, prompt them to install WooCommerce Dynamic Pricing. 157 | * @since 1.0.0 158 | * @return void 159 | */ 160 | public function install_wc_dynamic_pricing_notice() { 161 | echo '
' . __( 'The WooCommerce Dynamic Pricing Table extension requires that you have the WooCommerce Dynamic Pricing plugin installed and activated.', 'woocommerce-dynamic-pricing-table' ) . ' ' . __( 'Get WooCommerce Dynamic Pricing now', 'woocommerce-dynamic-pricing-table' ) . '
163 |' . __( 'Quantity' , 'woocommerce-dynamic-pricing-table' ) . ' | ' . __( 'Bulk Purchase Pricing' , 'woocommerce-dynamic-pricing-table' ) . ' | '; 209 | 210 | foreach( $array_rule_sets as $pricing_rule_sets ) { 211 | 212 | foreach ( $pricing_rule_sets['rules'] as $key => $value ) { 213 | 214 | // Checks if a product discount group max quantity field is less than 1. 215 | if ( $pricing_rule_sets['rules'][$key]['to'] < 1 ){ 216 | $rules_to = __( ' or more', 'woocommerce-dynamic-pricing-table' ); 217 | } else { 218 | $rules_to = ' - ' . wc_stock_amount( $pricing_rule_sets['rules'][$key]['to'] ); 219 | } 220 | 221 | $output .= '||
---|---|---|---|
' . wc_stock_amount( $pricing_rule_sets['rules'][$key]['from'] ) . $rules_to . ' | '; 224 | 225 | switch ( $pricing_rule_sets['rules'][$key]['type'] ) { 226 | 227 | case 'price_discount': 228 | $output .= '' . sprintf( __( '%1$s Discount Per Item', 'woocommerce-dynamic-pricing-table' ), wc_price( $pricing_rule_sets['rules'][$key]['amount'] ) ) . ' | '; 229 | break; 230 | 231 | case 'percentage_discount': 232 | $output .= '' . floatval( $pricing_rule_sets['rules'][$key]['amount'] ) . __( '% Discount', 'woocommerce-dynamic-pricing-table' ) . ' | '; 233 | break; 234 | 235 | case 'fixed_price': 236 | $output .= '' . sprintf( __( '%1$s Per Item', 'woocommerce-dynamic-pricing-table' ), wc_price( $pricing_rule_sets['rules'][$key]['amount'] ) ) . ' | '; 237 | break; 238 | 239 | } 240 | 241 | $output .= '
' . __( 'Quantity', 'woocommerce-dynamic-pricing-table' ) . ' | ' . __( 'Special Offer Pricing', 'woocommerce-dynamic-pricing-table' ) . ' | '; 266 | 267 | foreach( $array_rule_sets as $pricing_rule_sets ) { 268 | 269 | foreach ( $pricing_rule_sets['blockrules'] as $key => $value ) { 270 | 271 | $output .= '||
---|---|---|---|
' . sprintf( __( 'Buy %1$s get %2$s more discounted', 'woocommerce-dynamic-pricing-table' ), wc_stock_amount( $pricing_rule_sets['blockrules'][$key]['from'] ), wc_stock_amount( $pricing_rule_sets['blockrules'][$key]['adjust'] ) ) . ' | '; 274 | 275 | switch ( $pricing_rule_sets['blockrules'][$key]['type'] ) { 276 | 277 | case 'fixed_adjustment': 278 | $output .= '' . sprintf( __( '%1$s Discount Per Item', 'woocommerce-dynamic-pricing-table' ), wc_price( $pricing_rule_sets['blockrules'][$key]['amount'] ) ) . ' | '; 279 | break; 280 | 281 | case 'percent_adjustment': 282 | $output .= '' . floatval( $pricing_rule_sets['blockrules'][$key]['amount'] ) . __( '% Discount', 'woocommerce-dynamic-pricing-table' ) . ' | '; 283 | break; 284 | 285 | case 'fixed_price': 286 | $output .= '' . sprintf( __( '%1$s Per Item', 'woocommerce-dynamic-pricing-table' ), wc_price( $pricing_rule_sets['blockrules'][$key]['amount'] ) ) . ' | '; 287 | break; 288 | 289 | } 290 | 291 | $output .= '