Plugin Directory

Changeset 2786611


Ignore:
Timestamp:
09/18/2022 04:46:52 PM (4 years ago)
Author:
simon_tw
Message:

fixed woo tpl bug and add some function

Location:
wp-line-notify
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • wp-line-notify/trunk/includes/class-woo.php

    r2617598 r2786611  
    77        $fields = array(
    88            'billing' => array(
    9                 'billing_first_name' => __( 'Billing First Name', 'woocommerce' ),
    10                 'billing_last_name'  => __( 'Billing Last Name', 'woocommerce' ),
    11                 'billing_company'    => __( 'Billing Company', 'woocommerce' ),
    12                 'billing_address_1'  => __( 'Billing Address 1', 'woocommerce' ),
    13                 'billing_address_2'  => __( 'Billing Address 2', 'woocommerce' ),
    14                 'billing_city'       => __( 'Billing City', 'woocommerce' ),
    15                 'billing_state'      => __( 'Billing State', 'woocommerce' ),
    16                 'billing_postcode'   => __( 'Billing Postal/Zip Code', 'woocommerce' ),
    17                 'billing_country'    => __( 'Billing Country / Region', 'woocommerce' ),
    18                 'billing_email'      => __( 'Email Address', 'woocommerce' ),
    19                 'billing_phone'      => __( 'Billing Phone Number', 'woocommerce' ),
     9                'billing_first_name' => __( 'Billing First Name', 'wp-line-notify' ),
     10                'billing_last_name'  => __( 'Billing Last Name', 'wp-line-notify' ),
     11                'billing_company'    => __( 'Billing Company', 'wp-line-notify' ),
     12                'billing_address_1'  => __( 'Billing Address 1', 'wp-line-notify' ),
     13                'billing_address_2'  => __( 'Billing Address 2', 'wp-line-notify' ),
     14                'billing_city'       => __( 'Billing City', 'wp-line-notify' ),
     15                'billing_state'      => __( 'Billing State', 'wp-line-notify' ),
     16                'billing_postcode'   => __( 'Billing Postal/Zip Code', 'wp-line-notify' ),
     17                'billing_country'    => __( 'Billing Country / Region', 'wp-line-notify' ),
     18                'billing_email'      => __( 'Email Address', 'wp-line-notify' ),
     19                'billing_phone'      => __( 'Billing Phone Number', 'wp-line-notify' ),
    2020            ),
    2121            'shipping' => array(
    22                 'shipping_first_name'=> __( 'Shipping First Name', 'woocommerce' ),
    23                 'shipping_last_name' => __( 'Shipping Last Name', 'woocommerce' ),
    24                 'shipping_company'   => __( 'Shipping Company', 'woocommerce' ),
    25                 'shipping_address_1' => __( 'Shipping Address 1', 'woocommerce' ),
    26                 'shipping_address_2' => __( 'Shipping Address 2', 'woocommerce' ),
    27                 'shipping_city'      => __( 'Shipping City', 'woocommerce' ),
    28                 'shipping_state'     => __( 'Shipping State', 'woocommerce' ),
    29                 'shipping_postcode'  => __( 'Shipping Postal/Zip Code', 'woocommerce' ),
    30                 'shipping_country'   => __( 'Shipping Country / Region', 'woocommerce' ),
    31                 'shipping_phone'     => __( 'Shipping Phone Number', 'woocommerce' ),
     22                'shipping_first_name'=> __( 'Shipping First Name', 'wp-line-notify' ),
     23                'shipping_last_name' => __( 'Shipping Last Name', 'wp-line-notify' ),
     24                'shipping_company'   => __( 'Shipping Company', 'wp-line-notify' ),
     25                'shipping_address_1' => __( 'Shipping Address 1', 'wp-line-notify' ),
     26                'shipping_address_2' => __( 'Shipping Address 2', 'wp-line-notify' ),
     27                'shipping_city'      => __( 'Shipping City', 'wp-line-notify' ),
     28                'shipping_state'     => __( 'Shipping State', 'wp-line-notify' ),
     29                'shipping_postcode'  => __( 'Shipping Postal/Zip Code', 'wp-line-notify' ),
     30                'shipping_country'   => __( 'Shipping Country / Region', 'wp-line-notify' ),
     31                'shipping_phone'     => __( 'Shipping Phone Number', 'wp-line-notify' ),
    3232            ),
    3333            'order' => array(
    34                 'total'             => __( 'Total' , 'wp-line-notify' ),
     34                'order-id'          => __( 'Order id' , 'wp-line-notify' ),
    3535                'order-product'     => __( 'Order item' , 'wp-line-notify' ),
    3636                'order-name'        => __( 'Order name' , 'wp-line-notify' ),
    3737                'shipping-name'     => __( 'Shipping name' , 'wp-line-notify' ),
    3838                'payment-method'    => __( 'Payment method' , 'wp-line-notify' ),
     39                'total'             => __( 'Total' , 'wp-line-notify' ),
    3940                'order-time'        => __( 'Order time' , 'wp-line-notify' ),
    40                 'customer_note'     => __( 'Order notes', 'woocommerce' ),
     41                'customer_note'     => __( 'Order notes', 'wp-line-notify' ),
    4142            )
    4243        );
     
    4950        $template = sprintf(
    5051'%1$s
    51 %2$s: [order-name]
     52%2$s: [order-id]
    5253%3$s: [order-product]
    53 %4$s: [payment-method]
     54%4$s: [order-name]
    5455%5$s: [shipping-name]
    55 %6$s: [total]',
    56             __( 'You have a new order.' , 'wp-line-notify' ),
    57             __( 'Order item' , 'wp-line-notify' ),
    58             __( 'Order name' , 'wp-line-notify' ),
    59             __( 'Shipping name' , 'wp-line-notify' ),
    60             __( 'Payment method' , 'wp-line-notify' ),
    61             __( 'Total' , 'wp-line-notify' )
     56%6$s: [payment-method]
     57%7$s: [total]',
     58                __( 'You have a new order.' , 'wp-line-notify' ),
     59                __( 'Order id' , 'wp-line-notify' ),
     60                __( 'Order item' , 'wp-line-notify' ),
     61                __( 'Order name' , 'wp-line-notify' ),
     62                __( 'Shipping name' , 'wp-line-notify' ),
     63                __( 'Payment method' , 'wp-line-notify' ),
     64                __( 'Total' , 'wp-line-notify' )
    6265        );
    6366
    64         return trim( $template );
     67        return trim( $template );
    6568    }
    6669
     
    7477            $fields = THWCFD_Utils::get_fields($type);
    7578        }
    76         return $fields;
     79        return $fields;
    7780    }
    7881
     
    8891
    8992        $options = get_option(SIG_LINE_NOTIFY_OPTIONS);
    90 
     93        $my_status = (!empty($options['woo_status'])) ? $options['woo_status']:[];
    9194?>
    9295        <input type="checkbox" id="chcek_order" name="<?php echo SIG_LINE_NOTIFY_OPTIONS?>[woocommerce]" value="1" <?php if(isset($options['woocommerce'])) echo checked( 1, $options['woocommerce'], false )?>>
    93 
    94         <label for="chcek_order"><?php _e( 'Add a new order' , 'wp-line-notify' )?></label>
    95 
     96        <label for="chcek_order"><?php _e( 'Add a new order' , 'wp-line-notify' )?></label><br>
     97        <hr>
     98
     99        <?php _e( 'Order status changed:' , 'wp-line-notify' )?>
     100        <?php foreach(wc_get_order_statuses() as $type=>$name): ?>
     101            &nbsp;&nbsp;&nbsp;<input type="checkbox" id="chcek_order_<?php echo $type?>" name="<?php echo SIG_LINE_NOTIFY_OPTIONS?>[woo_status][]" value="<?php echo $type?>" <?php if( in_array($type,$my_status) ) echo 'checked="checked"';?>>
     102            <label for="chcek_order_<?php echo $type?>"><?php echo $name?></label>
     103        <?php endforeach;?>
    96104        <hr>
    97105
  • wp-line-notify/trunk/includes/page-setup.php

    r2599085 r2786611  
    109109        <table class="form-table">
    110110            <tr valign="top">
    111                 <th scope="row"><?php _e( 'WooCommerce' , 'quadric' ); ?></th>
     111                <th scope="row"><?php _e( 'WooCommerce' , 'wp-line-notify' ); ?></th>
    112112                <td>
    113113                <?php
  • wp-line-notify/trunk/languages/wp-line-notify.pot

    r2599085 r2786611  
    1 # Copyright (C) 2021 Simon Chuang
     1# Copyright (C) 2022 Simon Chuang
    22# This file is distributed under the GPLv2.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: WordPress LINE Notify 1.3\n"
     5"Project-Id-Version: WordPress LINE Notify 1.3.2\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-line-notify\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2021-09-15T12:11:23+08:00\n"
     12"POT-Creation-Date: 2022-09-18T18:17:05+02:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    14 "X-Generator: WP-CLI 2.5.0\n"
     14"X-Generator: WP-CLI 2.6.0\n"
    1515"X-Domain: wp-line-notify\n"
    1616
     
    3939msgstr ""
    4040
    41 #: includes/class-elementor.php:72
     41#: includes/class-elementor.php:73
    4242msgid "Line notify alert"
    4343msgstr ""
    4444
    45 #: includes/class-elementor.php:82
     45#: includes/class-elementor.php:83
    4646msgid "Prompt text"
    4747msgstr ""
    4848
    49 #: includes/class-elementor.php:85
     49#: includes/class-elementor.php:86
    5050msgid "The reminder text is displayed at the beginning of the sent message."
    5151msgstr ""
    5252
     53#: includes/class-woo.php:9
     54msgid "Billing First Name"
     55msgstr ""
     56
     57#: includes/class-woo.php:10
     58msgid "Billing Last Name"
     59msgstr ""
     60
     61#: includes/class-woo.php:11
     62msgid "Billing Company"
     63msgstr ""
     64
     65#: includes/class-woo.php:12
     66msgid "Billing Address 1"
     67msgstr ""
     68
     69#: includes/class-woo.php:13
     70msgid "Billing Address 2"
     71msgstr ""
     72
     73#: includes/class-woo.php:14
     74msgid "Billing City"
     75msgstr ""
     76
     77#: includes/class-woo.php:15
     78msgid "Billing State"
     79msgstr ""
     80
     81#: includes/class-woo.php:16
     82msgid "Billing Postal/Zip Code"
     83msgstr ""
     84
     85#: includes/class-woo.php:17
     86msgid "Billing Country / Region"
     87msgstr ""
     88
     89#: includes/class-woo.php:18
     90msgid "Email Address"
     91msgstr ""
     92
     93#: includes/class-woo.php:19
     94msgid "Billing Phone Number"
     95msgstr ""
     96
     97#: includes/class-woo.php:22
     98msgid "Shipping First Name"
     99msgstr ""
     100
     101#: includes/class-woo.php:23
     102msgid "Shipping Last Name"
     103msgstr ""
     104
     105#: includes/class-woo.php:24
     106msgid "Shipping Company"
     107msgstr ""
     108
     109#: includes/class-woo.php:25
     110msgid "Shipping Address 1"
     111msgstr ""
     112
     113#: includes/class-woo.php:26
     114msgid "Shipping Address 2"
     115msgstr ""
     116
     117#: includes/class-woo.php:27
     118msgid "Shipping City"
     119msgstr ""
     120
     121#: includes/class-woo.php:28
     122msgid "Shipping State"
     123msgstr ""
     124
     125#: includes/class-woo.php:29
     126msgid "Shipping Postal/Zip Code"
     127msgstr ""
     128
     129#: includes/class-woo.php:30
     130msgid "Shipping Country / Region"
     131msgstr ""
     132
     133#: includes/class-woo.php:31
     134msgid "Shipping Phone Number"
     135msgstr ""
     136
    53137#: includes/class-woo.php:34
     138#: includes/class-woo.php:59
     139msgid "Order id"
     140msgstr ""
     141
     142#: includes/class-woo.php:35
     143#: includes/class-woo.php:60
     144msgid "Order item"
     145msgstr ""
     146
     147#: includes/class-woo.php:36
    54148#: includes/class-woo.php:61
     149msgid "Order name"
     150msgstr ""
     151
     152#: includes/class-woo.php:37
     153#: includes/class-woo.php:62
     154msgid "Shipping name"
     155msgstr ""
     156
     157#: includes/class-woo.php:38
     158#: includes/class-woo.php:63
     159msgid "Payment method"
     160msgstr ""
     161
     162#: includes/class-woo.php:39
     163#: includes/class-woo.php:64
    55164msgid "Total"
    56165msgstr ""
    57166
    58 #: includes/class-woo.php:35
    59 #: includes/class-woo.php:57
    60 msgid "Order item"
    61 msgstr ""
    62 
    63 #: includes/class-woo.php:36
     167#: includes/class-woo.php:40
     168msgid "Order time"
     169msgstr ""
     170
     171#: includes/class-woo.php:41
     172msgid "Order notes"
     173msgstr ""
     174
    64175#: includes/class-woo.php:58
    65 msgid "Order name"
    66 msgstr ""
    67 
    68 #: includes/class-woo.php:37
    69 #: includes/class-woo.php:59
    70 msgid "Shipping name"
    71 msgstr ""
    72 
    73 #: includes/class-woo.php:38
    74 #: includes/class-woo.php:60
    75 msgid "Payment method"
    76 msgstr ""
    77 
    78 #: includes/class-woo.php:39
    79 msgid "Order time"
    80 msgstr ""
    81 
    82 #: includes/class-woo.php:56
    83176msgid "You have a new order."
    84177msgstr ""
    85178
    86 #: includes/class-woo.php:94
     179#: includes/class-woo.php:96
    87180msgid "Add a new order"
    88181msgstr ""
    89182
    90183#: includes/class-woo.php:99
     184msgid "Order status changed:"
     185msgstr ""
     186
     187#: includes/class-woo.php:107
    91188msgid "You can use these tags in the message template:"
    92189msgstr ""
    93190
    94 #: includes/class-woo.php:100
     191#: includes/class-woo.php:108
    95192msgid "(Click tag to insert into the template)"
    96193msgstr ""
    97194
    98 #: includes/class-woo.php:105
     195#: includes/class-woo.php:113
    99196msgid "Default Item"
    100197msgstr ""
    101198
    102 #: includes/class-woo.php:116
     199#: includes/class-woo.php:124
    103200msgid "Billing Fields"
    104201msgstr ""
    105202
    106 #: includes/class-woo.php:122
     203#: includes/class-woo.php:130
    107204msgid "Shipping Fields"
    108205msgstr ""
    109206
    110 #: includes/class-woo.php:128
     207#: includes/class-woo.php:136
    111208msgid "Additional Fields"
    112209msgstr ""
    113210
    114 #: includes/class-woo.php:137
     211#: includes/class-woo.php:145
    115212msgid "Buyer Information"
    116213msgstr ""
    117214
    118 #: includes/class-woo.php:144
     215#: includes/class-woo.php:152
    119216msgid "Recipient Information"
    120217msgstr ""
    121218
    122 #: includes/class-woo.php:156
     219#: includes/class-woo.php:164
    123220msgid "Template"
    124221msgstr ""
    125222
    126 #: includes/class-woo.php:167
     223#: includes/class-woo.php:175
    127224msgid "* If you do not enter any text, the system will use the default template."
    128225msgstr ""
    129226
    130227#: includes/page-setup.php:9
    131 #: wp-line-notify.php:321
     228#: wp-line-notify.php:333
    132229msgid "LINE Notify token is required!"
    133230msgstr ""
    134231
    135232#: includes/page-setup.php:17
    136 #: wp-line-notify.php:112
     233#: wp-line-notify.php:115
    137234msgid "Line Notify Setting"
    138235msgstr ""
     
    193290#: includes/page-setup.php:103
    194291msgid "User register"
     292msgstr ""
     293
     294#: includes/page-setup.php:111
     295msgid "WooCommerce"
    195296msgstr ""
    196297
     
    233334msgstr ""
    234335
    235 #: wp-line-notify.php:113
     336#: wp-line-notify.php:116
    236337msgid "WP Line Notify"
    237338msgstr ""
    238339
    239 #: wp-line-notify.php:124
     340#: wp-line-notify.php:127
    240341msgid "Settings"
    241342msgstr ""
    242343
    243 #: wp-line-notify.php:139
     344#: wp-line-notify.php:142
    244345msgid "Send test ok!"
    245346msgstr ""
    246347
    247 #: wp-line-notify.php:142
     348#: wp-line-notify.php:145
    248349msgid "Error on send LINE Notify."
    249350msgstr ""
    250351
    251 #: wp-line-notify.php:157
     352#: wp-line-notify.php:160
    252353msgid "publish a post"
    253354msgstr ""
    254355
    255 #: wp-line-notify.php:158
     356#: wp-line-notify.php:161
    256357msgid "pending a post"
    257358msgstr ""
    258359
    259 #: wp-line-notify.php:183
     360#: wp-line-notify.php:186
    260361msgid "You have a new comment."
    261362msgstr ""
    262363
    263 #: wp-line-notify.php:190
     364#: wp-line-notify.php:193
    264365msgid "You have a new user register."
    265366msgstr ""
    266367
    267 #: wp-line-notify.php:193
     368#: wp-line-notify.php:196
    268369msgid "Username:"
    269370msgstr ""
    270371
    271 #: wp-line-notify.php:300
     372#: wp-line-notify.php:295
     373msgid "There is an order id %1$d, and the state is changed to %2$s."
     374msgstr ""
     375
     376#: wp-line-notify.php:312
    272377msgid "You have a new contact message."
    273378msgstr ""
    274379
    275 #: wp-line-notify.php:303
     380#: wp-line-notify.php:315
    276381msgid "from:"
    277382msgstr ""
    278383
    279 #: wp-line-notify.php:307
     384#: wp-line-notify.php:319
    280385msgid "email:"
    281386msgstr ""
    282387
    283 #: wp-line-notify.php:311
     388#: wp-line-notify.php:323
    284389msgid "message:"
    285390msgstr ""
    286391
    287 #: wp-line-notify.php:323
     392#: wp-line-notify.php:335
    288393msgid "Plase write something !"
    289394msgstr ""
  • wp-line-notify/trunk/readme.txt

    r2617598 r2786611  
    33Tags: notify, plugin, line, WooCommerce, Elementor, Contact Form
    44Requires at least: 4.8
    5 Tested up to: 5.8
    6 Requires PHP: 5.6
    7 Stable tag: 1.3.1
     5Tested up to: 6.0.2
     6Requires PHP: 7.2
     7Stable tag: 1.3.2
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2929
    30301. screenshot-1.png
    31 2. screenshot-2.png
    3231
    3332== Changelog ==
     33
     34= 1.3.2 - 2022-09-19 =
     35* Fixed some bug. (WooCommerce default template)
     36* Add Order status changed notify.
    3437
    3538= 1.3.1 - 2021-10-21 =
  • wp-line-notify/trunk/wp-line-notify.php

    r2617598 r2786611  
    33 * Plugin Name: WordPress LINE Notify
    44 * Description: This plugin can send a alert message by LINE Notify
    5  * Version:     1.3.1
     5 * Version:     1.3.2
    66 * Author:      Simon Chuang
    77 * Author URI:  https://github.com/mark2me/wp-line-notify
     
    4141        require_once( SIG_LINE_NOTIFY_DIR . '/includes/class-woo.php' );
    4242
    43 
    4443        // actions
    4544        add_action( 'plugins_loaded' , array($this, 'load_textdomain' ) );
     
    6968
    7069        if( isset($this->options['woocommerce']) && $this->options['woocommerce'] == 1 && is_plugin_active( 'woocommerce/woocommerce.php' ) ){
    71                 add_action( 'woocommerce_checkout_update_order_meta', array($this,'new_woocommerce_order_alert') , 15, 3 );
    72         }
     70                add_action( 'woocommerce_new_order', array($this,'new_woocommerce_order_alert') ,10, 2);
     71        }
     72
     73        if( !empty($this->options['woo_status']) && is_plugin_active( 'woocommerce/woocommerce.php' ) ){
     74            add_action( 'woocommerce_order_status_changed', array($this,'update_woocommerce_order_status') ,10, 4);
     75        }
    7376
    7477        if( isset($this->options['wpcf7']) && is_array($this->options['wpcf7']) && count($this->options['wpcf7']) > 0 && is_plugin_active('contact-form-7/wp-contact-form-7.php') ){
     
    195198    }
    196199
    197     public function new_woocommerce_order_alert( $order_get_id ) {
    198 
    199         $order = wc_get_order( $order_get_id );
     200    public function new_woocommerce_order_alert( $order_id, $order ) {
     201
    200202        $order_data = $order->get_data();
    201 
    202203
    203204        if( isset($this->options['woocommerce_tpl']) && !empty($this->options['woocommerce_tpl']) ){
    204205            $message = $this->options['woocommerce_tpl'];
    205206        }else{
    206 
    207207            $message = WP_LINE_NOTIFY_WOO::form();
    208208        }
    209209
    210         //order
    211210        $order_product = '';
    212211        if(isset($order_data['line_items']) && count($order_data['line_items'])>0){
     
    216215                    $sku = $product->get_sku();
    217216                    if( !empty($sku) ){
    218                         $order_product .= "\n {$item['name']} [" .  $product->get_sku() . "] x {$item['quantity']}";
     217                        $order_product .= "\n {$item['name']} [" . $product->get_sku() . "] x {$item['quantity']}";
    219218                    }else{
    220219                        $order_product .= "\n {$item['name']} x {$item['quantity']}";
     
    229228        $shipping_name = (isset($order_data['shipping']['first_name']) && isset($order_data['shipping']['last_name'])) ? ($order_data['shipping']['last_name'].$order_data['shipping']['first_name']) : '';
    230229
    231 
    232230        $text = array(
     231            '[order-id]'        => $order_id,
     232            '[order-product]'   => $order_product,
    233233            '[order-name]'      => $order_name,
    234234            '[shipping-name]'   => $shipping_name,
    235             '[order-product]'   => $order_product,
     235            '[payment-method]'  => (isset($order_data['payment_method_title'])) ? $order_data['payment_method_title'] : '',
    236236            '[total]'           => (isset($order_data['total'])) ? $order_data['total'] : '',
    237             '[payment-method]'  => (isset($order_data['payment_method_title'])) ? $order_data['payment_method_title'] : '',
    238237            '[order-time]'      => (isset($order_data['date_created'])) ? $order_data['date_created']->date('Y-m-d H:i:s') : '',
    239238            '[customer_note]'   => (isset($order_data['customer_note'])) ? $order_data['customer_note'] : '',
     
    287286    }
    288287
     288    public function update_woocommerce_order_status($order_id, $old_status, $new_status, $order) {
     289
     290        $options = get_option(SIG_LINE_NOTIFY_OPTIONS);
     291        if( !empty($options['woo_status']) ) {
     292            $my_status = (!empty($options['woo_status']));
     293            if( in_array( 'wc-'.$new_status, $options['woo_status'] ) ){
     294
     295                $message = sprintf( __('There is an order id %1$d, and the state is changed to %2$s.', 'wp-line-notify'), $order_id, wc_get_order_status_name($new_status) );
     296                $this->send_msg( $message );
     297            }
     298        }
     299    }
     300
    289301
    290302    public function new_wpcf7_message($cf7) {
Note: See TracChangeset for help on using the changeset viewer.