Plugin Directory

Changeset 2486190


Ignore:
Timestamp:
03/03/2021 09:48:33 PM (5 years ago)
Author:
felipe152
Message:
  • 1.5.2
  • Nova função da integração do CartBounty, envie mensagens automaticamente;
  • Correção da automação do status "Aguardando";
Location:
powers-triggers-of-woo-to-chat/trunk
Files:
3 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • powers-triggers-of-woo-to-chat/trunk/admin/class-wwp-admin.php

    r2481538 r2486190  
    1414        add_action( 'wp_ajax_wwp_view_table_publico', array( $this, 'wwp_view_table_publico' ) );
    1515        add_action( 'wp_ajax_wwp_view_disparar', array( $this, 'wwp_view_disparar' ) );
     16        add_action( 'wp_ajax_wwp_view_cartbounty', array( $this, 'wwp_view_cartbounty' ) );
    1617        add_action( 'wp_ajax_wwp_send_from_cartbounty', array( $this, 'wwp_send_from_cartbounty' ) );
    1718
     
    123124    function wwp_mod_cartbounty_abandoned_carts (){
    124125        wp_enqueue_script(  'wwp-cartbounty-script-mod', plugin_dir_url( __FILE__ ) . 'js/mod_cartbounty_abandoned_carts.js', array('jquery'), rand(0,1000), true );   
     126        global $wwp_db_path;
     127        require_once $wwp_db_path.'include/class-wwp-cartbounty.php';
     128        $wwp_cartbounty = new Woowhatspowers_cartbounty();
    125129        if ($_POST and !empty($_POST['wwp_textarea'])) {
    126             $up = update_option('wwp_template_cartbounty',  trim(($_POST['wwp_textarea']) ),FALSE);
    127             if (!$up) {
    128                 $up = add_option('wwp_template_cartbounty', trim(($_POST['wwp_textarea'])));
    129             }
     130            $wwp_cartbounty->wpp_save($_POST);
    130131        }
    131132
     
    138139            $erros = 0;
    139140            foreach ($ids as $v) {
    140                 if ($this->wwp_send_from_cartbounty($v)) {
     141                if ($wwp_cartbounty->wpp_send($v)) {
    141142                    $enviados++;
    142143                } else{
     
    160161       
    161162        add_action( 'admin_footer', function(){
    162             $wwp_template_cartbounty = get_option( 'wwp_template_cartbounty', '' );
     163           
    163164            echo ' <input type="hidden" id="wwp_template_cartbounty" value="'.$wwp_template_cartbounty.'" /> ';
    164165        }, 10, 1 );
     166    }
     167    function wwp_view_cartbounty(){
     168        require_once plugin_dir_path(dirname(__FILE__)).'include/class-wwp-cartbounty.php';
     169        $wwp_cartbounty = new Woowhatspowers_cartbounty();
     170        $wwp_template_cartbounty = $wwp_cartbounty->acoes['template'];
     171        $wwp_cron_cartbounty = $wwp_cartbounty->acoes['cron'];
     172        require_once plugin_dir_path(dirname(__FILE__)).'admin/views/wwp-cartbounty.php';
     173        exit();
    165174    }
    166175    function wwp_send_from_cartbounty($wwp_id = ''){
     
    169178            $wwp_id = $_POST['wwp_id'];
    170179        }
    171         $wwp_template_cartbounty = get_option( 'wwp_template_cartbounty', '' );
    172         if (  empty($wwp_template_cartbounty))  {
    173             if (wp_doing_ajax()) {
    174                 exit('false');
    175             }
    176             return false;
    177         }
    178            
    179         global $wpdb;
    180         $table_prefix = $wpdb->prefix;
    181         $args = $wpdb->prepare('SELECT * FROM `'.$table_prefix.'cartbounty` WHERE id ='.$wwp_id);
    182         $cart = $wpdb->get_row($args);
    183         if (! empty($cart) ) {
    184            
    185             if (!class_exists('PseudoCrypt')) {
    186                 global $wwp_db_path;
    187                 require_once($wwp_db_path . 'include/class-wwp-pseudocrypt.php');
    188             }
    189             $idEncrypt = PseudoCrypt::hash($cart->id, 6);
    190             foreach ($cart as $key => $value) {
    191                 $wwp_template_cartbounty = str_replace('{'.$key.'}', $value, $wwp_template_cartbounty);
    192             }
    193             $wwp_template_cartbounty = str_replace('{cart_link}',   wc_get_cart_url().'?wwp_r='.$idEncrypt, $wwp_template_cartbounty);
    194 
    195             if (!empty($cart->cart_contents)) {
    196                 $cart_contents = array();
    197                 $cart->cart_contents = unserialize($cart->cart_contents);
    198                 foreach ($cart->cart_contents as $key => $value) {
    199                     $cart_contents[] = $value['product_title'];
    200                 }
    201             }
    202             $wwp_template_cartbounty = str_replace('{cart_contents_all}', implode(', ', $cart_contents) , $wwp_template_cartbounty);
    203             if ($this->whatsapp->sendMessage($cart->phone,$wwp_template_cartbounty)) {
    204                 if ( wp_doing_ajax()) {
    205                     exit('true');       
    206                 }
    207                 return true;
    208             };
    209         }
    210         if (wp_doing_ajax()) {
    211             exit('false');
     180        if (!class_exists('Woowhatspowers_cartbounty')) {
     181            global $wwp_db_path;
     182            require_once plugin_dir_path(dirname(__FILE__)).'include/class-wwp-cartbounty.php';
    212183        }
    213         return false;
     184        $wwp_cartbounty = new Woowhatspowers_cartbounty();
     185        $send = $wwp_cartbounty->wpp_send($wwp_id);
     186       
     187        if ($send=== FALSE) {
     188            return false;
     189        }
     190        return true;
    214191    }
    215192
  • powers-triggers-of-woo-to-chat/trunk/admin/js/mod_cartbounty_abandoned_carts.js

    r2475924 r2486190  
    4848        });
    4949    });
    50     var form = $("<form/>",
    51         {
    52             id: 'wwp_form',
    53             method: 'post',
    54             action:window.location.href,
    55             style:'width:50%;' }
    56         );
    57     form.append(
    58         $("<label>",
    59              {
    60                 for:'wwp_textarea',
    61                 style:'font-weight: bold'
    62              }
    63          ).html('<h2>Template de Mensagem WhatsApp</h2>')
    64     );
    65     form.append(
    66          $("<textarea>",
    67               {
    68                 id:'wwp_textarea',
    69                 name:'wwp_textarea',
    70                 style:'width:100%; height: 117px;' }
    71            ).html($('#wwp_template_cartbounty').val())
    72     );
    73     form.append(
    74          $("<input>",
    75               { type:'submit',
    76                 value:'Salvar',
    77                 class: 'button button-primary' }
    78           )
    79     );
    80     form.append(
    81          $("<h2>").html('Legenda de Shortcode')
    82     )
    83     form.append(
    84          $("<div>",
    85               {
    86                 class: 'postbox',
    87                 style:'display: inline-block;' }
    88           ).append($("<div>",
    89             {
    90                 class: 'legenda-block',
    91                 style: 'padding: 0 0.75rem;'
    92             }
    93           )
    94           .append('<p><strong>Carrinho abandonado</strong></p>')
    95           .append('<ul><li>{name}</li><li>{surname}</li><li>{email}</li><li>{cart_contents_all}</li><li>{cart_contents($)}</li><li>{cart_link}</li></ul>')
    96           )
    97     );
    98     $("#wpbody-content").after(form);
     50
     51    //Carregar view;
     52    $.ajax({
     53        url: ajaxurl,
     54        type: 'POST',
     55        data: {
     56            'action': 'wwp_view_cartbounty'
     57        },
     58    })
     59    .done(function(data) {
     60        $("#wpbody-content").after(data);
     61    });
    9962});
  • powers-triggers-of-woo-to-chat/trunk/class-wwp-jetbooking-front.php

    r2481538 r2486190  
    3131        }
    3232    }
    33 
    34    
    35 
    36 
    37    
    3833}
  • powers-triggers-of-woo-to-chat/trunk/class-wwp-woocommerce-front.php

    r2481538 r2486190  
    6060        }
    6161        $orders = wc_get_orders(array(
    62             'type'=> 'shop_order',
    63             'status'=> array( 'wc-on-hold' ),
     62            'post_status'=> 'on-hold',
    6463            'meta_key' => 'wwp_notify_whatsapp',
    6564            'meta_compare' => '==',
    6665            'meta_value' =>  1
    6766        ));
     67
    6868       
    69         foreach ($orders as $order) {
     69        foreach ($orders as $order) {   
    7070            $dataCriado = $order->order_date;
    7171            $keySend = '';
     
    7979                }
    8080            }
     81
    8182           
    82             if ($keySend==='') { return false; }
    83             $modelo =  $settings->hold_order->modelo[$keySend];
    84             //REPLACE MODELO
    85             $modelo  = $this->wwp_replace_modelo($order->id, $modelo);
    86             //GET PHONE
    87             $target_phone = $order->get_billing_phone();
    88             $target_phone = $this->phone_validation($target_phone,$this->whatsapp->getCode());
    89             if ($target_phone === FALSE) {
    90                 return false;
    91             }
    92 
    93             //SEND MESSAGE
    94             $res = $this->whatsapp->sendMessage($target_phone,$modelo);
    95             if ($res) {
    96                 $this->log->lwrite('Enviado para '.$target_phone);
    97             } else {
    98                 $erro = $this->whatsapp->lastResp;
    99                 $this->log->lwrite('Erro ao enviar para '.$target_phone.'. Erro: '.$erro[1]);
    100             }
    101         }
    102         exit();
     83            if ($keySend!='') {
     84                $modelo =  $settings->hold_order->modelo[$keySend];
     85                //REPLACE MODELO
     86                $modelo  = $this->wwp_replace_modelo($order->id, $modelo);
     87                //GET PHONE
     88                $target_phone = $order->get_billing_phone();
     89                $target_phone = $this->phone_validation($target_phone,$this->whatsapp->getCode());
     90                if ($target_phone !== FALSE) {
     91                    //SEND MESSAGE
     92                    $res = $this->whatsapp->sendMessage($target_phone,$modelo);
     93                }
     94            }
     95        }
    10396    }
    10497
     
    325318
    326319    public function wwp_option_field($checkout) {
    327          echo '<div><h2>' . __('Notificação por Whatsapp') . '</h2>';
     320         echo '<div id="wpp_check"><h2>' . __('Notificação por Whatsapp') . '</h2>';
    328321         woocommerce_form_field( 'wwp_notify_whatsapp', array(
    329322            'type'          => 'checkbox',
  • powers-triggers-of-woo-to-chat/trunk/readme.txt

    r2481538 r2486190  
    5454
    5555== Changelog ==
     56* 1.5.2
     57* Nova função da integração do CartBounty, envie mensagens automaticamente;
     58* Correção da automação do status "Aguardando";
    5659* 1.5.0
    5760* Nova integração com Forms do JetEngine;
  • powers-triggers-of-woo-to-chat/trunk/wc-whatsapp-powers.php

    r2481538 r2486190  
    44 * Plugin URI:  https://wordpress.org/plugins/powers-triggers-of-woo-to-chat/
    55 * Description: Automatiza envio de mensagens Whatsapp.
    6  * Version:     1.5.0
     6 * Version:     1.5.2
    77 * Author:      Felipe Peixoto
    88 * Author URI:  http://felipepeixoto.tecnologia.ws/projetos/plugins-para-wordpress/notificacoes-de-pedidos-por-whatsapp/
     
    1919register_activation_hook( __FILE__, 'pac_active_plugin' );
    2020register_deactivation_hook( __FILE__, 'wwp_deactive_plugin' );
     21add_filter( 'postmeta_form_limit', function( $limit ) {
     22    return 100;
     23});
    2124
    2225
     
    133136        new Woowhatspowers_Woocommerce_Front();
    134137       
    135         //Recovery cart
    136         if (wwp_is_plugin_active('woo-save-abandoned-carts/cartbounty-abandoned-carts.php') and isset($_GET['wwp_r']) ){
    137             $wwp_id = $_GET['wwp_r'];
    138             if (!class_exists('PseudoCrypt')) {
    139                 global $wwp_db_path;
    140                 require_once($wwp_db_path . 'include/class-wwp-pseudocrypt.php');
    141             }
    142             $wwp_id = PseudoCrypt::unhash($wwp_id);
    143             global $wpdb;
    144             $table_prefix = $wpdb->prefix;
    145             $args = $wpdb->prepare('SELECT * FROM `'.$table_prefix.'cartbounty` WHERE id ='.$wwp_id);
    146             $cart = $wpdb->get_row($args);
    147             if (! empty($cart) and ! empty($cart->cart_contents) ) {
    148                 $cart->cart_contents = (array) unserialize( $cart->cart_contents );
    149                 if( function_exists('WC') ){
    150                     WC()->cart->empty_cart();
    151                     foreach ($cart->cart_contents as $produto) {
    152                         WC()->cart->add_to_cart( $produto['product_id']);
    153                     }
     138       
     139        if (wwp_is_plugin_active('woo-save-abandoned-carts/cartbounty-abandoned-carts.php')){
     140            global $wwp_db_path;
     141            require_once($wwp_db_path.'class-wwp-cartbounty-front.php');
     142            $wwp_cartbounty = new Woowhatspowers_cartbounty_Front();
     143            //Recovery cart
     144            if (isset($_GET['wwp_r'])) {
     145                $wwp_id = $_GET['wwp_r'];
     146                if ($wwp_cartbounty->recoverCart($wwp_id)) {
     147                    wp_redirect(wc_get_cart_url());
     148                    exit();
    154149                }
    155150            }
    156             wp_redirect(wc_get_cart_url());
    157             exit(); 
     151
    158152        }
    159153    }
     
    174168       
    175169    }
     170    if (isset($_GET['remind-test'])) {
     171        do_action( 'wwp_reminder_action' );
     172        exit();
     173    }
    176174});
    177175
Note: See TracChangeset for help on using the changeset viewer.