Plugin Directory

Changeset 1795770


Ignore:
Timestamp:
01/02/2018 03:26:01 PM (8 years ago)
Author:
dcurasi
Message:
  • New - Added the ability to choose how to display the currency
  • Fix - Now the options are deleted when the plugin is uninstalled and not when the plugin is deactivate
  • Fix - The cart total and the minimum order were formatted with two decimal places
  • Dev - The function for set the minimum order has been restructured
  • Dev - Update translations
Location:
minimum-order-amount-for-woocommerce
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • minimum-order-amount-for-woocommerce/trunk/README.txt

    r1612768 r1795770  
    55Tags: woocommerce, order, woocommerce order, minimum order, woocommerce minimum order, shop, cart, woocommerce cart, product, products, minimum order amount, amount, minimum amount
    66Requires at least: 3.0.1
    7 Tested up to: 4.7.3
    8 Stable tag: 1.2.0
     7Tested up to: 4.9.1
     8Stable tag: 1.3.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    5252== Changelog ==
    5353
     54= 1.3.0 - 02/01/18 =
     55* New - Added the ability to choose how to display the currency
     56* Fix - Now the options are deleted when the plugin is uninstalled and not when the plugin is deactivate
     57* Fix - The cart total and the minimum order were formatted with two decimal places
     58* Dev - The function for set the minimum order has been restructured
     59* Dev - Update translations
     60
    5461= 1.2.0 - 12/03/17 =
    5562* New - Added compatibility with WooCommerce Price Based on Country
  • minimum-order-amount-for-woocommerce/trunk/admin/class-dc-moafw-admin.php

    r1612768 r1795770  
    121121     * Creates our settings sections with fields etc.
    122122     *
    123      * @since    1.2.0
     123     * @since    1.3.0
    124124     */
    125125    public function settings_api_init(){
     
    128128        register_setting('dc_moafw_options_group', 'dc_moafw_message');
    129129        register_setting('dc_moafw_options_group', 'dc_moafw_current_total_text');
     130        register_setting('dc_moafw_options_group', 'dc_moafw_currency_display_type');
    130131        register_setting('dc_moafw_options_group', 'dc_moafw_message_shop');
    131132    }
  • minimum-order-amount-for-woocommerce/trunk/admin/css/dc-moafw-admin.css

    r1507445 r1795770  
    33 * included in this file.
    44 */
     5 #dc_moafw_currency_display_type {
     6    padding-top: 0;
     7    padding-bottom: 0;
     8 }
  • minimum-order-amount-for-woocommerce/trunk/admin/partials/dc-moafw-admin-display.php

    r1612768 r1795770  
    77 *
    88 * @link       https://github.com/dcurasi
    9  * @since      1.1.0
     9 * @since      1.3.0
    1010 *
    1111 * @package    Dc_Moafw
     
    6969            <tr valign="top">
    7070                <th scope="row">
     71                    <label for="dc_moafw_currency_display_type"><?php _e( 'Currency Display Type', 'dc-moafw' ); ?></label>
     72                </th>
     73                <td>
     74                  <select id="dc_moafw_currency_display_type" name="dc_moafw_currency_display_type">
     75                      <option value="symbol" <?php echo selected(get_option('dc_moafw_currency_display_type'), "symbol"); ?>><?php _e('Symbol', 'dc-moafw'); ?></option>
     76                      <option value="text" <?php echo selected(get_option('dc_moafw_currency_display_type'), "text"); ?>><?php _e('Text', 'dc-moafw'); ?></option>
     77                  </select>
     78                  <p class="description"><?php _e( 'The way the currency appears in the notification message (i.e. "&euro;" if is "symbol", "EUR" if is "text").', 'dc-moafw' ); ?></p>
     79                </td>
     80            </tr>
     81            <tr valign="top">
     82                <th scope="row">
    7183                    <label for="dc_moafw_message_shop"><?php _e( 'Show message in the shop', 'dc-moafw' ); ?></label>
    7284                </th>
  • minimum-order-amount-for-woocommerce/trunk/dc-moafw.php

    r1612768 r1795770  
    1010 *
    1111 * @link              https://github.com/dcurasi
    12  * @since             1.2.0
     12 * @since             1.3.0
    1313 * @package           Dc_Moafw
    1414 *
     
    1717 * Plugin URI:        https://github.com/dcurasi/dc-moafw
    1818 * Description:       Minimum Order Amount for Woocommerce allows you to set easily and fast a minimum amount for the woocommerce orders.
    19  * Version:           1.2.0
     19 * Version:           1.3.0
    2020 * Author:            Dario Curasì
    2121 * Author URI:        https://github.com/dcurasi
  • minimum-order-amount-for-woocommerce/trunk/includes/class-dc-moafw-activator.php

    r1612768 r1795770  
    2828     * Long Description.
    2929     *
    30      * @since    1.2.0
     30     * @since    1.3.0
    3131     */
    3232    public static function activate() {
     
    3535        add_option('dc_moafw_message', __('A Minimum of [minimum] is required before checking out.', 'dc-moafw'));
    3636        add_option('dc_moafw_current_total_text', __("Current cart's total: [current]", 'dc-moafw'));
     37        add_option('dc_moafw_currency_display_type', "text");
    3738        add_option('dc_moafw_message_shop', 0);
    3839    }
  • minimum-order-amount-for-woocommerce/trunk/includes/class-dc-moafw-deactivator.php

    r1612768 r1795770  
    2828     * Long Description.
    2929     *
    30      * @since    1.2.0
     30     * @since    1.3.0
    3131     */
    3232    public static function deactivate() {
    33         delete_option('dc_moafw_activate');
    34         delete_option('dc_moafw_minimum');
    35         delete_option('dc_moafw_message');
    36         delete_option('dc_moafw_current_total_text');
    37         delete_option('dc_moafw_message_shop');
     33       
    3834    }
    3935
  • minimum-order-amount-for-woocommerce/trunk/includes/class-dc-moafw.php

    r1612768 r1795770  
    7070
    7171        $this->plugin_name = 'dc-moafw';
    72         $this->version = '1.2.0';
     72        $this->version = '1.3.0';
    7373
    7474        $this->load_dependencies();
     
    145145     * of the plugin.
    146146     *
    147      * @since    1.2.0
     147     * @since    1.3.0
    148148     * @access   private
    149149     */
     
    152152        $plugin_admin = new Dc_Moafw_Admin( $this->get_plugin_name(), $this->get_version() );
    153153
    154         //$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
     154        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
    155155        //$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
    156156        $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_menu_page' );
  • minimum-order-amount-for-woocommerce/trunk/languages/dc-moafw-it_IT.po

    r1612768 r1795770  
    22msgstr ""
    33"Project-Id-Version: Minimum Order Amount for Woocommerce\n"
    4 "POT-Creation-Date: 2017-03-11 13:30+0100\n"
    5 "PO-Revision-Date: 2017-03-11 13:32+0100\n"
     4"POT-Creation-Date: 2018-01-02 13:18+0100\n"
     5"PO-Revision-Date: 2018-01-02 13:26+0100\n"
    66"Last-Translator: \n"
    77"Language-Team: Dario Curasì <curasi.d87@gmail.com>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 1.8.11\n"
     12"X-Generator: Poedit 2.0.5\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=2; plural=(n != 1);\n"
     
    1717"X-Poedit-SearchPath-0: .\n"
    1818
    19 #: admin/class-dc-moafw-admin.php:141
     19#: admin/class-dc-moafw-admin.php:142
    2020msgid ""
    2121"Minimum Order Amount for Woocommerce is active but does not work. You need "
     
    7676
    7777#: admin/partials/dc-moafw-admin-display.php:71
     78msgid "Currency Display Type"
     79msgstr "Tipo di visualizzazione della Valuta"
     80
     81#: admin/partials/dc-moafw-admin-display.php:75
     82msgid "Symbol"
     83msgstr "Simbolo"
     84
     85#: admin/partials/dc-moafw-admin-display.php:76
     86msgid "Text"
     87msgstr "Testo"
     88
     89#: admin/partials/dc-moafw-admin-display.php:78
     90msgid ""
     91"The way the currency appears in the notification message (i.e. \"&euro;\" if "
     92"is \"symbol\", \"EUR\" if is \"text\")."
     93msgstr ""
     94"Il modo in cui la valuta viene visualizzata nel messaggio (per es. \"&euro;"
     95"\" se è \"simbolo\", \"EUR\" se è \"testo\")."
     96
     97#: admin/partials/dc-moafw-admin-display.php:83
    7898msgid "Show message in the shop"
    7999msgstr "Mostra messaggio nello shop"
    80100
    81 #: admin/partials/dc-moafw-admin-display.php:75
     101#: admin/partials/dc-moafw-admin-display.php:87
    82102msgid "Enable"
    83103msgstr "Abilita"
    84104
    85 #: admin/partials/dc-moafw-admin-display.php:76
     105#: admin/partials/dc-moafw-admin-display.php:88
    86106msgid ""
    87107"Enable this option to show the notification message also in the shop pages. "
  • minimum-order-amount-for-woocommerce/trunk/languages/dc-moafw-pl_PL.po

    r1612768 r1795770  
    22msgstr ""
    33"Project-Id-Version: Minimum Order Amount for Woocommerce\n"
    4 "POT-Creation-Date: 2017-03-12 15:25+0100\n"
    5 "PO-Revision-Date: 2017-03-12 15:26+0100\n"
     4"POT-Creation-Date: 2018-01-02 13:22+0100\n"
     5"PO-Revision-Date: 2018-01-02 13:25+0100\n"
    66"Last-Translator: \n"
    77"Language-Team: Dario Curasì <curasi.d87@gmail.com>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 1.8.11\n"
     12"X-Generator: Poedit 2.0.5\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
     
    1818"X-Poedit-SearchPath-0: .\n"
    1919
    20 #: admin/class-dc-moafw-admin.php:141
     20#: admin/class-dc-moafw-admin.php:142
    2121msgid ""
    2222"Minimum Order Amount for Woocommerce is active but does not work. You need "
     
    7777
    7878#: admin/partials/dc-moafw-admin-display.php:71
     79msgid "Currency Display Type"
     80msgstr "Typ wyświetlania waluty"
     81
     82#: admin/partials/dc-moafw-admin-display.php:75
     83msgid "Symbol"
     84msgstr "Symbol"
     85
     86#: admin/partials/dc-moafw-admin-display.php:76
     87msgid "Text"
     88msgstr "Tekst"
     89
     90#: admin/partials/dc-moafw-admin-display.php:78
     91msgid ""
     92"The way the currency appears in the notification message (i.e. \"&euro;\" if "
     93"is \"symbol\", \"EUR\" if is \"text\")."
     94msgstr ""
     95"Sposób, w jaki waluta pojawia się w wiadomości powiadomienia (tj. \"&euro;\" "
     96"jeśli jest \"symbol\", \"EUR\", jeśli jest \"tekst\")."
     97
     98#: admin/partials/dc-moafw-admin-display.php:83
    7999msgid "Show message in the shop"
    80100msgstr "Pokaż wiadomość w sklepie"
    81101
    82 #: admin/partials/dc-moafw-admin-display.php:75
     102#: admin/partials/dc-moafw-admin-display.php:87
    83103msgid "Enable"
    84104msgstr "Włącz"
    85105
    86 #: admin/partials/dc-moafw-admin-display.php:76
     106#: admin/partials/dc-moafw-admin-display.php:88
    87107msgid ""
    88108"Enable this option to show the notification message also in the shop pages. "
  • minimum-order-amount-for-woocommerce/trunk/languages/dc-moafw.pot

    r1612768 r1795770  
    33msgstr ""
    44"Project-Id-Version: Minimum Order Amount for Woocommerce\n"
    5 "POT-Creation-Date: 2017-03-11 13:30+0100\n"
     5"POT-Creation-Date: 2018-01-02 13:18+0100\n"
    66"PO-Revision-Date: 2017-01-07 19:04+0100\n"
    77"Last-Translator: \n"
     
    1111"Content-Type: text/plain; charset=UTF-8\n"
    1212"Content-Transfer-Encoding: 8bit\n"
    13 "X-Generator: Poedit 1.8.11\n"
     13"X-Generator: Poedit 2.0.5\n"
    1414"X-Poedit-Basepath: ..\n"
    1515"Plural-Forms: nplurals=2; plural=(n != 1);\n"
     
    1818"X-Poedit-SearchPath-0: .\n"
    1919
    20 #: admin/class-dc-moafw-admin.php:141
     20#: admin/class-dc-moafw-admin.php:142
    2121msgid ""
    2222"Minimum Order Amount for Woocommerce is active but does not work. You need "
     
    7070
    7171#: admin/partials/dc-moafw-admin-display.php:71
     72msgid "Currency Display Type"
     73msgstr ""
     74
     75#: admin/partials/dc-moafw-admin-display.php:75
     76msgid "Symbol"
     77msgstr ""
     78
     79#: admin/partials/dc-moafw-admin-display.php:76
     80msgid "Text"
     81msgstr ""
     82
     83#: admin/partials/dc-moafw-admin-display.php:78
     84msgid ""
     85"The way the currency appears in the notification message (i.e. \"&euro;\" if "
     86"is \"symbol\", \"EUR\" if is \"text\")."
     87msgstr ""
     88
     89#: admin/partials/dc-moafw-admin-display.php:83
    7290msgid "Show message in the shop"
    7391msgstr ""
    7492
    75 #: admin/partials/dc-moafw-admin-display.php:75
     93#: admin/partials/dc-moafw-admin-display.php:87
    7694msgid "Enable"
    7795msgstr ""
    7896
    79 #: admin/partials/dc-moafw-admin-display.php:76
     97#: admin/partials/dc-moafw-admin-display.php:88
    8098msgid ""
    8199"Enable this option to show the notification message also in the shop pages. "
  • minimum-order-amount-for-woocommerce/trunk/public/class-dc-moafw-public.php

    r1612768 r1795770  
    104104     * Set a minimum dollar amount per order
    105105     *
    106      * @since    1.2.0
     106     * @since    1.3.0
    107107     */
    108108    public function dc_moafw_set_minimum_order() {
    109109        global $woocommerce;
    110         $flag = false;
    111 
    112         if ( in_array( 'polylang/polylang.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && function_exists('pll__') ) {
    113             $message = str_replace('[minimum]', '%s %s', pll__(get_option('dc_moafw_message')));
    114             $current_cart_text = str_replace('[current]', '%s %s', pll__(get_option('dc_moafw_current_total_text')));
    115         }
    116         else {
    117             $message = str_replace('[minimum]', '%s %s', get_option('dc_moafw_message'));
    118             $current_cart_text = str_replace('[current]', '%s %s', get_option('dc_moafw_current_total_text'));
    119         }
    120 
    121         if ( in_array( 'woocommerce-product-price-based-on-countries/woocommerce-product-price-based-on-countries.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    122             $wcpbc_values = new WCPBC_Customer();
    123             if ( $wcpbc_values->zone_id ) {
    124                 $flag = true;
    125             }
    126         }
     110        $wcpbc_values = new WCPBC_Customer();
     111        $wcpbc_currency_active = $this->dc_moafw_wcpbc_currency_is_active($wcpbc_values);
     112
     113        $message = $this->dc_moafw_get_message();
     114        $current_cart_text = $this->dc_moafw_get_current_cart_text();
    127115
    128116        // Total we are going to be using for the Math
    129117        // This is before taxes and shipping charges
    130118        $total = round(WC()->cart->subtotal, 2);
    131 
     119        //print_r(WC()->cart->subtotal_ex_tax);
    132120        if( is_cart() || is_checkout() ) {
    133             if($flag) {
     121            if($wcpbc_currency_active) {
    134122                // Set minimum cart total
    135123                $minimum_cart_total = get_option('dc_moafw_minimum') * $wcpbc_values->exchange_rate;
     
    139127                    wc_add_notice( sprintf( '<strong>'.$message.'</strong>'
    140128                        .'<br />'.$current_cart_text,
    141                         $minimum_cart_total,
    142                         $wcpbc_values->currency,
    143                         $total,
    144                         $wcpbc_values->currency ),
     129                        number_format($minimum_cart_total, 2, ',', '.'),
     130                        $this->dc_moafw_get_currency_display_type($wcpbc_values),
     131                        number_format($total, 2, ',', '.'),
     132                        $this->dc_moafw_get_currency_display_type($wcpbc_values) ),
    145133                    'error' );
    146134                }
     
    154142                    wc_add_notice( sprintf( '<strong>'.$message.'</strong>'
    155143                        .'<br />'.$current_cart_text,
    156                         $minimum_cart_total,
    157                         get_option( 'woocommerce_currency'),
    158                         $total,
    159                         get_option( 'woocommerce_currency') ),
     144                        number_format($minimum_cart_total, 2, ',', '.'),
     145                        $this->dc_moafw_get_currency_display_type($wcpbc_values),
     146                        number_format($total, 2, ',', '.'),
     147                        $this->dc_moafw_get_currency_display_type($wcpbc_values) ),
    160148                    'error' );
    161149                }
     
    163151        }
    164152        elseif(get_option( 'dc_moafw_message_shop' ) && $total) {
    165             if($flag) {
     153            if($wcpbc_currency_active) {
    166154                // Set minimum cart total
    167155                $minimum_cart_total = get_option('dc_moafw_minimum') * $wcpbc_values->exchange_rate;
     
    170158                    // Display our error message
    171159                    wc_add_notice( sprintf( '<strong>'.$message.'</strong>',
    172                         $minimum_cart_total,
    173                         $wcpbc_values->currency),
     160                        number_format($minimum_cart_total, 2, ',', '.'),
     161                        $this->dc_moafw_get_currency_display_type($wcpbc_values)),
    174162                    'error' );
    175163                }
     
    182170                    // Display our error message
    183171                    wc_add_notice( sprintf( '<strong>'.$message.'</strong>',
    184                         $minimum_cart_total,
    185                         get_option( 'woocommerce_currency') ),
     172                        number_format($minimum_cart_total, 2, ',', '.'),
     173                        $this->dc_moafw_get_currency_display_type($wcpbc_values) ),
    186174                    'error' );
    187175                }
     
    190178    }
    191179
     180    /**
     181     * Check if woocommerce-product-price-based-on-countries is active and have a currency
     182     *
     183     * @since    1.3.0
     184     */
     185    public function dc_moafw_wcpbc_currency_is_active($wcpbc_values) {
     186        if ( in_array( 'woocommerce-product-price-based-on-countries/woocommerce-product-price-based-on-countries.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
     187            if ( $wcpbc_values->zone_id ) {
     188                return true;
     189            }
     190
     191            return false;
     192        }
     193
     194        return false;
     195    }
     196
     197    /**
     198     * Get a currency display type
     199     *
     200     * @since    1.3.0
     201     */
     202    public function dc_moafw_get_currency_display_type($wcpbc_values) {
     203        if(get_option('dc_moafw_currency_display_type') != "symbol") {
     204            if($this->dc_moafw_wcpbc_currency_is_active($wcpbc_values)) {
     205                return $wcpbc_values->currency;
     206            }
     207
     208            return get_option( 'woocommerce_currency');
     209        }
     210
     211        return get_woocommerce_currency_symbol();
     212    }
     213
     214    /**
     215     * Get a message
     216     *
     217     * @since    1.3.0
     218     */
     219    public function dc_moafw_get_message() {
     220        if ( in_array( 'polylang/polylang.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && function_exists('pll__') ) {
     221            return str_replace('[minimum]', '%s %s', pll__(get_option('dc_moafw_message')));
     222
     223        }
     224
     225        return str_replace('[minimum]', '%s %s', get_option('dc_moafw_message'));
     226    }
     227
     228    /**
     229     * Get a current cart text
     230     *
     231     * @since    1.3.0
     232     */
     233    public function dc_moafw_get_current_cart_text() {
     234        if ( in_array( 'polylang/polylang.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && function_exists('pll__') ) {
     235            return str_replace('[current]', '%s %s', pll__(get_option('dc_moafw_current_total_text')));
     236        }
     237            return str_replace('[current]', '%s %s', get_option('dc_moafw_current_total_text'));
     238    }
     239
    192240}
  • minimum-order-amount-for-woocommerce/trunk/uninstall.php

    r1507445 r1795770  
    2121 *
    2222 * @link       https://github.com/dcurasi
    23  * @since      1.0.0
     23 * @since      1.3.0
    2424 *
    2525 * @package    Dc_Moafw
     
    2828// If uninstall not called from WordPress, then exit.
    2929if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
     30    delete_option('dc_moafw_activate');
     31    delete_option('dc_moafw_minimum');
     32    delete_option('dc_moafw_message');
     33    delete_option('dc_moafw_current_total_text');
     34    delete_option('dc_moafw_currency_display_type');
     35    delete_option('dc_moafw_message_shop');
    3036    exit;
    3137}
Note: See TracChangeset for help on using the changeset viewer.