Plugin Directory

Changeset 875432


Ignore:
Timestamp:
03/14/2014 01:49:37 PM (12 years ago)
Author:
sydcode
Message:

Fixed currency format bug

Location:
woocommerce-prices/trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • woocommerce-prices/trunk/languages/woocommerce-prices.pot

    r795157 r875432  
    22msgstr ""
    33"Project-Id-Version: WooCommerce Prices\n"
    4 "POT-Creation-Date: 2013-10-29 17:00+1000\n"
    5 "PO-Revision-Date: 2013-10-29 17:03+1000\n"
     4"POT-Creation-Date: 2014-03-15 00:44+1000\n"
     5"PO-Revision-Date: 2014-03-15 00:44+1000\n"
    66"Last-Translator: \n"
    77"Language-Team: \n"
     
    1111"X-Generator: Poedit 1.5.5\n"
    1212"X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e\n"
     13"X-Poedit-Basepath: .\n"
     14"X-Poedit-SearchPath-0: ..\n"
    1315
    14 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:15
     16#: ../template.php:15
    1517msgid "WooCommerce Prices"
    1618msgstr ""
    1719
    18 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:29
     20#: ../template.php:29
    1921msgid "Action"
    2022msgstr ""
    2123
    22 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:31
     24#: ../template.php:31
    2325msgid "Regular Price"
    2426msgstr ""
    2527
    26 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:32
     28#: ../template.php:32
    2729msgid "New Regular Price"
    2830msgstr ""
    2931
    30 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:33
     32#: ../template.php:33
    3133msgid "Increase Regular Price"
    3234msgstr ""
    3335
    34 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:34
     36#: ../template.php:34
    3537msgid "Decrease Regular Price"
    3638msgstr ""
    3739
    38 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:36
     40#: ../template.php:36
    3941msgid "Sale Price"
    4042msgstr ""
    4143
    42 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:37
     44#: ../template.php:37
    4345msgid "New Sale Price"
    4446msgstr ""
    4547
    46 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:38
     48#: ../template.php:38
    4749msgid "New Sale Discount"
    4850msgstr ""
    4951
    50 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:39
     52#: ../template.php:39
    5153msgid "Increase Sale Price"
    5254msgstr ""
    5355
    54 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:40
     56#: ../template.php:40
    5557msgid "Decrease Sale Price"
    5658msgstr ""
    5759
    58 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:42
    59 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:63
     60#: ../template.php:42 ../template.php:63
    6061msgid "Sale From"
    6162msgstr ""
    6263
    63 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:43
     64#: ../template.php:43
    6465msgid "New Sale From"
    6566msgstr ""
    6667
    67 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:44
     68#: ../template.php:44
    6869msgid "Increase Sale From"
    6970msgstr ""
    7071
    71 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:45
     72#: ../template.php:45
    7273msgid "Decrease Sale From"
    7374msgstr ""
    7475
    75 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:47
    76 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:67
     76#: ../template.php:47 ../template.php:67
    7777msgid "Sale To"
    7878msgstr ""
    7979
    80 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:48
     80#: ../template.php:48
    8181msgid "New Sale To"
    8282msgstr ""
    8383
    84 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:49
     84#: ../template.php:49
    8585msgid "Increase Sale To"
    8686msgstr ""
    8787
    88 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:50
     88#: ../template.php:50
    8989msgid "Decrease Sale To"
    9090msgstr ""
    9191
    92 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:55
     92#: ../template.php:55
    9393msgid "Value"
    9494msgstr ""
    9595
    96 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:56
     96#: ../template.php:56
    9797msgid "Enter amount or percentage"
    9898msgstr ""
    9999
    100 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:59
     100#: ../template.php:59
    101101msgid "Days"
    102102msgstr ""
    103103
    104 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:60
     104#: ../template.php:60
    105105msgid "Enter number of days"
    106106msgstr ""
    107107
    108 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:74
     108#: ../template.php:74
    109109msgid "Category"
    110110msgstr ""
    111111
    112 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:87
     112#: ../template.php:87
    113113msgid "OR"
    114114msgstr ""
    115115
    116 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:89
     116#: ../template.php:89
    117117msgid "Taxonomy"
    118118msgstr ""
    119119
    120 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:95
     120#: ../template.php:95
    121121msgid "Term"
    122122msgstr ""
    123123
    124 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:103
     124#: ../template.php:103
    125125msgid "Edit Prices"
    126126msgstr ""
    127127
    128 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:104
     128#: ../template.php:104
    129129msgid "Get Prices"
    130130msgstr ""
    131131
    132 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:105
     132#: ../template.php:105
    133133msgid "Save Prices"
    134134msgstr ""
    135135
    136 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:106
     136#: ../template.php:106
    137137msgid "Saving products"
    138138msgstr ""
    139139
    140 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:107
     140#: ../template.php:107
    141141msgid "Products saved"
    142142msgstr ""
    143143
    144 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/template.php:113
     144#: ../template.php:113
    145145msgid "Loading Products"
    146146msgstr ""
    147147
    148 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/woocommerce-prices.php:94
     148#: ../woocommerce-prices.php:94
    149149msgid "You do not have sufficient permissions to access this page."
    150150msgstr ""
    151151
    152 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/woocommerce-prices.php:172
    153 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/woocommerce-prices.php:218
    154 #: C:\xampp\htdocs\wordpress52\wp-content\plugins\woocommerce-prices/woocommerce-prices.php:306
     152#: ../woocommerce-prices.php:180 ../woocommerce-prices.php:206
     153#: ../woocommerce-prices.php:298
    155154msgid "Security check failed"
    156155msgstr ""
     156
     157#: ../woocommerce-prices.php:202 ../woocommerce-prices.php:294
     158msgid "WooCommerce Prices requires WooCommerce"
     159msgstr ""
  • woocommerce-prices/trunk/readme.txt

    r795175 r875432  
    44Tags: woocommerce, e-commerce, ecommerce, shop, shopping, store, prices, sales, edit, editor, manage
    55Requires at least: 3.3
    6 Tested up to: 3.7
    7 Stable tag: 1.0.0
     6Tested up to: 3.8.1
     7Stable tag: 1.0.1
    88License: GPLv3 or later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    8383== Changelog ==
    8484
     85= 1.0.1 =
     86* Fixed currency format bug
     87
    8588= 1.0.0 =
    8689* First release
  • woocommerce-prices/trunk/script.js

    r795157 r875432  
    204204            var value = $('#action-value').val();
    205205            var amount = getAmountValue(value);
    206             var percent = getPercentValue(value);   
     206            var percent = getPercentValue(value);
    207207            var selected = grid.getSelectedRows();
    208208            var products = grid.getData();
     
    213213                    return;
    214214                }
    215                 var regular = parseFloat(products[i].regular_price);
     215                var regular = accounting.unformat(products[i].regular_price, wooPrices.decimalSeparator);
    216216                switch (action) {
    217217                    // New regular price                       
     
    243243                        break;
    244244                }
    245                 products[i].regular_price = Number(regular).toFixed(2);
     245                products[i].regular_price = accounting.formatMoney(regular, '', 2, '', wooPrices.decimalSeparator);
    246246            });
    247247            grid.setData(products);
     
    266266                    return;
    267267                }
    268                 var regular = parseFloat(products[i].regular_price);
    269                 var sale = parseFloat(products[i].sale_price);
     268                var regular = accounting.unformat(products[i].regular_price, wooPrices.decimalSeparator);
     269                var sale = accounting.unformat(products[i].sale_price, wooPrices.decimalSeparator);
    270270                var from = products[i].sale_from;
    271271                var to = products[i].sale_to;
     
    326326                    sale = 0;
    327327                }
    328                 products[i].sale_price = Number(sale).toFixed(2);       
     328                products[i].sale_price = accounting.formatMoney(sale, '', 2, '', wooPrices.decimalSeparator);
    329329                products[i].sale_from = from;           
    330330                products[i].sale_to = to;           
     
    434434            var amount = false;
    435435            if (value.indexOf('%') == -1) {
    436                 amount = parseFloat(value.replace('%', ''));
     436                amount = value.replace('%', '');
     437                amount = accounting.unformat(amount, wooPrices.decimalSeparator);
    437438            }   
    438439            return amount;
     
    445446            var percent = false;
    446447            if (value.indexOf('%') > 0) {
    447                 percent = parseFloat(value.replace('%', ''));
     448                percent = value.replace('%', '');
     449                percent = accounting.unformat(percent, wooPrices.decimalSeparator);
    448450            }   
    449451            return percent;
  • woocommerce-prices/trunk/woocommerce-prices.php

    r795157 r875432  
    44Plugin Name: WooCommerce Prices
    55Description: This plugin allows for custom editing of product prices in WooCommerce. Thanks to Anthony for sponsoring this plugin.
    6 Version: 1.0.0
     6Version: 1.0.1
    77Author: sydcode
    88Author URI: http://profiles.wordpress.org/sydcode
     
    3232   
    3333    protected static $instance = null;
    34     const PLUGIN_VERSION = '1.0.0';
     34    const PLUGIN_VERSION = '1.0.1';
    3535    const PLUGIN_SLUG = 'woocommerce_prices';
    3636
     
    133133        $url = plugins_url('/smoothness/jquery-ui-1.10.3.custom.min.css', __FILE__);
    134134        wp_enqueue_style('jquery-smoothness', $url, array(), '1.10.3');
     135        // Accounting.JS script
     136        $url = plugins_url('accounting.min.js', __FILE__);
     137        wp_enqueue_script('accounting-js', $url, array(), '0.3.2');
     138        // Plugin stylesheet and script
    135139        $url = plugins_url('style.css', __FILE__);
    136140        wp_enqueue_style(self::PLUGIN_SLUG, $url, array(), self::PLUGIN_VERSION);   
     
    141145            'jquery-ui-datepicker',
    142146            'jquery-slickgrid-core',
    143             'jquery-slickgrid-grid'
     147            'jquery-slickgrid-grid',
     148            'accounting-js'
    144149        );
    145150        wp_enqueue_script(self::PLUGIN_SLUG, $url, $args, self::PLUGIN_VERSION);
    146         $url = plugins_url('', __FILE__);
    147         wp_localize_script(self::PLUGIN_SLUG, 'wooPrices', array('pluginURL' => $url));
     151        $data = array(
     152            'pluginURL' => plugins_url('', __FILE__),
     153            'decimalSeparator' => get_option('woocommerce_price_decimal_sep')
     154        );
     155        wp_localize_script(self::PLUGIN_SLUG, 'wooPrices', $data);
    148156    }   
    149157   
     
    185193   
    186194 /**
    187     * Parse value to get amount
    188     */
    189     public function parse_value_amount($value) {
    190         $amount = '';
    191         if (strpos($value, '%') === false) {
    192             $value = preg_replace('/^[^0-9\.]/', '', $value);
    193             $amount = floatval($value);
    194         }           
    195         return $amount;
    196     }
    197    
    198  /**
    199     * Parse value to get percentage
    200     */
    201     public function parse_value_percent($value) {
    202         $percent = '';
    203         if (strpos($value, '%') === true) {
    204             $value = str_replace('%', '', $value);
    205             $percent = floatval($value);
    206         }           
    207         return $percent;
    208     }       
    209    
    210  /**
    211195    * Get product data for grid
    212196    *
     
    214198    */
    215199    public function get_products() {
     200        // Check that WooCommerce is active
     201        if (!function_exists('wc_format_localized_price')) {
     202            wp_die(__('WooCommerce Prices requires WooCommerce', 'woocommerce_prices'));
     203        }       
    216204        // Security check
    217205        if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'wooprices')) {
     
    268256            $regular_price = get_post_meta($post->ID, '_regular_price', true);
    269257            if ('' != $regular_price) {
    270                 $regular_price = number_format(floatval($regular_price), 2);
     258                $regular_price = wc_format_localized_price($regular_price);
    271259            }
    272260            $sale_price = get_post_meta($post->ID, '_sale_price', true);
    273261            if ('' != $sale_price) {
    274                 $sale_price = number_format(floatval($sale_price), 2);
     262                $sale_price = wc_format_localized_price($sale_price);
    275263            }
    276264            // Get sale dates
     
    301289    * Save grid data to products
    302290    */
    303     public function save_products() {   
     291    public function save_products() {
     292        // Check that WooCommerce is active
     293        if (!function_exists('wc_format_decimal')) {
     294            wp_die(__('WooCommerce Prices requires WooCommerce', 'woocommerce_prices'));
     295        }       
    304296        // Security check
    305297        if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'wooprices')) {
     
    310302        foreach ($products as $product) {
    311303            $ID = $product['ID'];
    312             $regular_price = $product['regular_price'];
    313             $sale_price = $product['sale_price'];
     304            $regular_price = wc_format_decimal($product['regular_price']);
     305            $sale_price = wc_format_decimal($product['sale_price']);
    314306            $sale_from = strtotime($product['sale_from']);
    315307            $sale_to = strtotime($product['sale_to']);
Note: See TracChangeset for help on using the changeset viewer.