Plugin Directory

Changeset 1833221


Ignore:
Timestamp:
03/04/2018 03:53:21 PM (8 years ago)
Author:
dcurasi
Message:
  • Fix - Now if the cart is empty, the minimum order notification is not shown
  • New - Now the decimal and thousands separators are displayed as woocommerce settings
  • New - Now the number of decimals in the price is the same as the woocommerce settings
  • New - Now the currency position in the price is set as in the woocommerce settings
Location:
minimum-order-amount-for-woocommerce/trunk
Files:
3 edited

Legend:

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

    r1796307 r1833221  
    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.9.1
    8 Stable tag: 1.3.1
     7Tested up to: 4.9.4
     8Stable tag: 1.4.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    5252== Changelog ==
    5353
     54= 1.4.0 - 04/03/18 =
     55* Fix - Now if the cart is empty, the minimum order notification is not shown
     56* New - Now the decimal and thousands separators are displayed as woocommerce settings
     57* New - Now the number of decimals in the price is the same as the woocommerce settings
     58* New - Now the currency position in the price is set as in the woocommerce settings
     59
    5460= 1.3.1 - 03/01/18 =
    5561* Fix - Fix the fatal error on the cart page (if WCPBC_Customer class does not exist)
  • minimum-order-amount-for-woocommerce/trunk/dc-moafw.php

    r1796027 r1833221  
    1010 *
    1111 * @link              https://github.com/dcurasi
    12  * @since             1.3.1
     12 * @since             1.4.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.3.1
     19 * Version:           1.4.0
    2020 * Author:            Dario Curasì
    2121 * Author URI:        https://github.com/dcurasi
  • minimum-order-amount-for-woocommerce/trunk/public/class-dc-moafw-public.php

    r1796027 r1833221  
    118118        $message = $this->dc_moafw_get_message();
    119119        $current_cart_text = $this->dc_moafw_get_current_cart_text();
     120        $decimal_separator = wc_get_price_decimal_separator();
     121        $thousand_separator = wc_get_price_thousand_separator();
     122        $num_decimals = wc_get_price_decimals();
    120123
    121124        // Total we are going to be using for the Math
    122125        // This is before taxes and shipping charges
    123         $total = round(WC()->cart->subtotal, 2);
     126        $total = round(WC()->cart->subtotal, $num_decimals);
    124127        //print_r(WC()->cart->subtotal_ex_tax);
    125         if( is_cart() || is_checkout() ) {
     128        if( (is_cart() || is_checkout()) && $total) {
    126129            if($wcpbc_currency_active) {
    127130                // Set minimum cart total
     
    132135                    wc_add_notice( sprintf( '<strong>'.$message.'</strong>'
    133136                        .'<br />'.$current_cart_text,
    134                         number_format($minimum_cart_total, 2, ',', '.'),
    135                         $this->dc_moafw_get_currency_display_type($wcpbc_values),
    136                         number_format($total, 2, ',', '.'),
    137                         $this->dc_moafw_get_currency_display_type($wcpbc_values) ),
     137                        $this->dc_moafw_get_currency_display_type($wcpbc_values),
     138                        number_format($minimum_cart_total, $num_decimals, $decimal_separator, $thousand_separator),
     139                        $this->dc_moafw_get_currency_display_type($wcpbc_values),
     140                        number_format($total, $num_decimals, $decimal_separator, $thousand_separator) ),
    138141                    'error' );
    139142                }
     
    147150                    wc_add_notice( sprintf( '<strong>'.$message.'</strong>'
    148151                        .'<br />'.$current_cart_text,
    149                         number_format($minimum_cart_total, 2, ',', '.'),
    150                         $this->dc_moafw_get_currency_display_type($wcpbc_values),
    151                         number_format($total, 2, ',', '.'),
    152                         $this->dc_moafw_get_currency_display_type($wcpbc_values) ),
     152                        $this->dc_moafw_get_currency_display_type($wcpbc_values),
     153                        number_format($minimum_cart_total, $num_decimals, $decimal_separator, $thousand_separator),
     154                        $this->dc_moafw_get_currency_display_type($wcpbc_values),
     155                        number_format($total, $num_decimals, $decimal_separator, $thousand_separator) ),
    153156                    'error' );
    154157                }
     
    163166                    // Display our error message
    164167                    wc_add_notice( sprintf( '<strong>'.$message.'</strong>',
    165                         number_format($minimum_cart_total, 2, ',', '.'),
    166                         $this->dc_moafw_get_currency_display_type($wcpbc_values)),
     168                        $this->dc_moafw_get_currency_display_type($wcpbc_values),
     169                        number_format($minimum_cart_total, $num_decimals, $decimal_separator, $thousand_separator) ),
    167170                    'error' );
    168171                }
     
    175178                    // Display our error message
    176179                    wc_add_notice( sprintf( '<strong>'.$message.'</strong>',
    177                         number_format($minimum_cart_total, 2, ',', '.'),
    178                         $this->dc_moafw_get_currency_display_type($wcpbc_values) ),
     180                        $this->dc_moafw_get_currency_display_type($wcpbc_values),
     181                        number_format($minimum_cart_total, $num_decimals, $decimal_separator, $thousand_separator) ),
    179182                    'error' );
    180183                }
     
    223226     */
    224227    public function dc_moafw_get_message() {
     228        $price_format = get_woocommerce_price_format();
    225229        if ( in_array( 'polylang/polylang.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && function_exists('pll__') ) {
    226             return str_replace('[minimum]', '%s %s', pll__(get_option('dc_moafw_message')));
    227 
    228         }
    229 
    230         return str_replace('[minimum]', '%s %s', get_option('dc_moafw_message'));
     230            return str_replace('[minimum]', $price_format, pll__(get_option('dc_moafw_message')));
     231
     232        }
     233
     234        return str_replace('[minimum]', $price_format, get_option('dc_moafw_message'));
    231235    }
    232236
     
    237241     */
    238242    public function dc_moafw_get_current_cart_text() {
     243        $price_format = str_replace(array('1', '2'), array('3', '4'), get_woocommerce_price_format());
    239244        if ( in_array( 'polylang/polylang.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && function_exists('pll__') ) {
    240             return str_replace('[current]', '%s %s', pll__(get_option('dc_moafw_current_total_text')));
    241         }
    242             return str_replace('[current]', '%s %s', get_option('dc_moafw_current_total_text'));
     245            return str_replace('[current]', $price_format, pll__(get_option('dc_moafw_current_total_text')));
     246        }
     247            return str_replace('[current]', $price_format, get_option('dc_moafw_current_total_text'));
    243248    }
    244249
Note: See TracChangeset for help on using the changeset viewer.