Changeset 2486190
- Timestamp:
- 03/03/2021 09:48:33 PM (5 years ago)
- Location:
- powers-triggers-of-woo-to-chat/trunk
- Files:
-
- 3 added
- 1 deleted
- 6 edited
-
admin/class-wwp-admin.php (modified) (5 diffs)
-
admin/js/mod_cartbounty_abandoned_carts.js (modified) (1 diff)
-
admin/views/wwp-cartbounty.php (added)
-
admin/views/wwp-settings-startview.php (deleted)
-
class-wwp-cartbounty-front.php (added)
-
class-wwp-jetbooking-front.php (modified) (1 diff)
-
class-wwp-woocommerce-front.php (modified) (3 diffs)
-
include/class-wwp-cartbounty.php (added)
-
readme.txt (modified) (1 diff)
-
wc-whatsapp-powers.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
powers-triggers-of-woo-to-chat/trunk/admin/class-wwp-admin.php
r2481538 r2486190 14 14 add_action( 'wp_ajax_wwp_view_table_publico', array( $this, 'wwp_view_table_publico' ) ); 15 15 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' ) ); 16 17 add_action( 'wp_ajax_wwp_send_from_cartbounty', array( $this, 'wwp_send_from_cartbounty' ) ); 17 18 … … 123 124 function wwp_mod_cartbounty_abandoned_carts (){ 124 125 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(); 125 129 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); 130 131 } 131 132 … … 138 139 $erros = 0; 139 140 foreach ($ids as $v) { 140 if ($ this->wwp_send_from_cartbounty($v)) {141 if ($wwp_cartbounty->wpp_send($v)) { 141 142 $enviados++; 142 143 } else{ … … 160 161 161 162 add_action( 'admin_footer', function(){ 162 $wwp_template_cartbounty = get_option( 'wwp_template_cartbounty', '' );163 163 164 echo ' <input type="hidden" id="wwp_template_cartbounty" value="'.$wwp_template_cartbounty.'" /> '; 164 165 }, 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(); 165 174 } 166 175 function wwp_send_from_cartbounty($wwp_id = ''){ … … 169 178 $wwp_id = $_POST['wwp_id']; 170 179 } 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'; 212 183 } 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; 214 191 } 215 192 -
powers-triggers-of-woo-to-chat/trunk/admin/js/mod_cartbounty_abandoned_carts.js
r2475924 r2486190 48 48 }); 49 49 }); 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 }); 99 62 }); -
powers-triggers-of-woo-to-chat/trunk/class-wwp-jetbooking-front.php
r2481538 r2486190 31 31 } 32 32 } 33 34 35 36 37 38 33 } -
powers-triggers-of-woo-to-chat/trunk/class-wwp-woocommerce-front.php
r2481538 r2486190 60 60 } 61 61 $orders = wc_get_orders(array( 62 'type'=> 'shop_order', 63 'status'=> array( 'wc-on-hold' ), 62 'post_status'=> 'on-hold', 64 63 'meta_key' => 'wwp_notify_whatsapp', 65 64 'meta_compare' => '==', 66 65 'meta_value' => 1 67 66 )); 67 68 68 69 foreach ($orders as $order) { 69 foreach ($orders as $order) { 70 70 $dataCriado = $order->order_date; 71 71 $keySend = ''; … … 79 79 } 80 80 } 81 81 82 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 } 103 96 } 104 97 … … 325 318 326 319 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>'; 328 321 woocommerce_form_field( 'wwp_notify_whatsapp', array( 329 322 'type' => 'checkbox', -
powers-triggers-of-woo-to-chat/trunk/readme.txt
r2481538 r2486190 54 54 55 55 == 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"; 56 59 * 1.5.0 57 60 * Nova integração com Forms do JetEngine; -
powers-triggers-of-woo-to-chat/trunk/wc-whatsapp-powers.php
r2481538 r2486190 4 4 * Plugin URI: https://wordpress.org/plugins/powers-triggers-of-woo-to-chat/ 5 5 * Description: Automatiza envio de mensagens Whatsapp. 6 * Version: 1.5. 06 * Version: 1.5.2 7 7 * Author: Felipe Peixoto 8 8 * Author URI: http://felipepeixoto.tecnologia.ws/projetos/plugins-para-wordpress/notificacoes-de-pedidos-por-whatsapp/ … … 19 19 register_activation_hook( __FILE__, 'pac_active_plugin' ); 20 20 register_deactivation_hook( __FILE__, 'wwp_deactive_plugin' ); 21 add_filter( 'postmeta_form_limit', function( $limit ) { 22 return 100; 23 }); 21 24 22 25 … … 133 136 new Woowhatspowers_Woocommerce_Front(); 134 137 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(); 154 149 } 155 150 } 156 wp_redirect(wc_get_cart_url()); 157 exit(); 151 158 152 } 159 153 } … … 174 168 175 169 } 170 if (isset($_GET['remind-test'])) { 171 do_action( 'wwp_reminder_action' ); 172 exit(); 173 } 176 174 }); 177 175
Note: See TracChangeset
for help on using the changeset viewer.