Changeset 1985889
- Timestamp:
- 12/05/2018 12:36:40 PM (7 years ago)
- Location:
- food-restaurant-order-and-contact-by-whatsapp/trunk
- Files:
-
- 1 added
- 3 edited
-
app/code/admin/settings.php (modified) (1 diff)
-
food-order.php (modified) (12 diffs)
-
food-order.pot (added)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
food-restaurant-order-and-contact-by-whatsapp/trunk/app/code/admin/settings.php
r1800525 r1985889 149 149 'default' => '1', 150 150 'options' => array( 151 '1' => __( ' Yes', 'id_whatsappchat' ),152 '0' => __( 'N o', 'id_whatsappchat' )151 '1' => __( 'Sim', 'id_whatsappchat' ), 152 '0' => __( 'Não', 'id_whatsappchat' ) 153 153 ) 154 154 ), -
food-restaurant-order-and-contact-by-whatsapp/trunk/food-order.php
r1800418 r1985889 4 4 * Plugin URI: http://criacaode.site 5 5 * Text Domain: food-order 6 * Domain Path: /languages7 6 * Description: Create your menus, and order them by WhatsApp 8 7 * Tags: whatsapp, order, restaurant, automation 9 8 * Author: Mercado Binário 10 9 * Author URI: criacaode.site 11 * Version: 1.110 * Version: 2.0 12 11 * License: GPL-2.0+ 13 12 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt … … 21 20 new Idnovate_Settings_API_WhatsAppChat(); 22 21 new Idnovate_WhatsAppChat(); 23 24 add_action( 'plugins_loaded', 'foodOrder_load_textdomain' );25 function foodOrder_load_textdomain() {26 if(load_plugin_textdomain( 'food-order', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' )){27 28 }29 }30 22 31 23 if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit.php') && $_GET['post_type'] == 'food_order' ) { … … 51 43 52 44 53 //$the_query = new WP_Term_Query($args);54 45 foreach($the_query->get_terms() as $term){ 55 46 echo " … … 74 65 75 66 76 if(isset($_POST['ok']) && ($_POST['ok'] == 'ok')){ 67 if(isset($_POST['ok']) && ($_POST['ok'] == 'ok')){ 77 68 $dadosBanco = Idnovate_WhatsAppChat::get_settings_values(1); 78 for($i=0; $i <= count($_POST['pedido']); $i++) 69 for($i=0; $i <= count($_POST['pedido']); $i++) 79 70 { 80 71 $pedido = sanitize_text_field($_POST['pedido'][$i]); … … 83 74 } 84 75 } 85 86 $data = __('My order: ', 'food-order'). sanitize_text_field($_POST['tamanho']) . ",". @implode($data, ","); 76 $n = 1; 77 $max = $i+250; 78 79 while($i < $max) 80 { 81 $pedidoLimite = 'pedidoLimite'.$n; 82 $pedido2 = sanitize_text_field($_POST["$pedidoLimite"]); 83 if(!empty($pedido2)){ 84 $data[$i] .= $pedido2; 85 } 86 87 $i++; 88 $n++; 89 } 90 91 $data = __('My order: ', 'food-order'). sanitize_text_field($_POST['tamanho']) . ". ". @implode($data, ","); 87 92 88 93 $mobile_phone = $dadosBanco['mobile_phone']; … … 97 102 } 98 103 99 100 104 class food_order{ 101 105 … … 114 118 private function __construct(){ 115 119 116 add_action('init','food_order::register_post_type'); 117 add_action('init','food_order::register_taxonomies'); 118 add_action('init','food_order::register_post_type_2'); 120 add_action('init','food_order::register_post_type'); // itens 121 add_action('init','food_order::register_taxonomies'); // categorias 122 add_action('init','food_order::register_post_type_2'); // tamanhos 119 123 add_shortcode('cardapio',array($this,'cardapio')); 120 124 } 121 125 122 126 public function cardapio($atts){ 123 127 … … 130 134 131 135 132 $nomes = explode(",", strval($nome)); 136 $nomes = explode(",", strval($nome)); 133 137 $order = $atts['order']; 134 138 $result = array(); … … 140 144 foreach ($nomes as $nome) { 141 145 142 $terms = get_posts(array( 146 $terms = get_posts(array( 143 147 'showposts' => -1, 144 148 'post_type' => 'food_order', … … 151 155 ); 152 156 $termo = get_terms(array('taxonomy' =>'cardapios','slug' => "'".$nome."'")); 153 154 if(!empty($terms)){ $ok = true; } 157 158 if(!empty($terms)){ $ok = true; } 155 159 } 156 160 157 if($ok){ 158 if($order == "cardapio"){ 159 160 $args = array( 161 'post_type' => 'tamanhos', 162 'post_status' => 'publish' 163 ); 164 $the_query2 = get_posts( $args ); 165 166 if(!empty($the_query2)){ 167 echo " 168 <div class='' id='tamanho'> 169 <div class='vc_column-inner ''> 170 <div class='wpb_wrapper'> 161 if($ok){ 162 163 if($order == "cardapio"){ 164 165 $args = array( 166 'post_type' => 'tamanhos', 167 'post_status' => 'publish' 168 ); 169 $the_query2 = get_posts( $args ); 170 171 if(!empty($the_query2)){ 172 echo " 173 <div class='' id='tamanho'> 174 <div class='vc_column-inner ''> 175 <div class='wpb_wrapper'> 171 176 <div class='wpb_text_column wpb_content_element'><div class='wpb_wrapper'> 172 <form method='post' name='form1' action=''> 173 <h3>". __('Size', 'food-order')."</h3> 174 <select name='tamanho' required> 175 <option value=''>". __('Select an option', 'food-order')."</option>"; 176 foreach ( $the_query2 as $post ){ 177 178 echo "<option value='$post->post_title'>$post->post_title</option>"; 177 <form method='post' name='form1' action=''> 178 <h3>". __('Size', 'food-order')."</h3> 179 <select name='tamanho' required> 180 <option value=''>". __('Select an option', 'food-order')."</option>"; 181 foreach ( $the_query2 as $post ){ 182 echo "<option value='$post->post_title'>$post->post_title</option>"; 183 } 184 echo "</select></div></div></div></div></div>"; 179 185 } 180 echo "</select></div></div></div></div></div>"; 181 } 186 } 187 188 $num =0; 189 foreach ($result as $nome) { 190 $num++; 191 $terms = get_posts(array( 192 'showposts' => -1, 193 'post_type' => 'food_order', 194 'tax_query' => array( 195 array( 196 'taxonomy' => 'cardapios', 197 'field' => 'slug', 198 'terms' => array("'".$nome."'")) 199 )) 200 ); 201 202 $termo = get_terms(array('taxonomy' =>'cardapios','slug' => "'".$nome."'")); 203 204 if($order !== ""){ 205 echo " <div class='wpb_column vc_column_container vc_col-sm-4' id='".$termo[0]->slug."' ><div class='vc_column-inner'><div class='wpb_wrapper'><div class='wpb_text_column wpb_content_element'><div class='wpb_wrapper'>"; 206 if(!empty($termo[0]->name)){ 207 echo "<h3>". $termo[0]->name. "</h3>"; 208 } 209 210 foreach ($terms as $obj) { 211 212 if($order == "cardapio"){ 213 if($termo[0]->description == 'limite'){ 214 echo "<input type='radio' id='pedido' name='pedidoLimite$num' value='$obj->post_title' /> "; 215 echo $obj->post_title. "<br>"; 216 }else{ 217 echo "<input type='checkbox' id='pedido' name='pedido[]' value='$obj->post_title' /> "; 218 echo $obj->post_title. "<br>"; 219 } 220 221 222 }elseif($order == "lista"){ 223 $valor = get_post_meta($obj->ID); 224 echo $obj->post_title. "<br>"; 225 } 226 } 227 228 echo "</div> </div></div></div></div>"; 229 230 } 231 182 232 } 183 233 234 if($order == "cardapio"){ 235 echo "<br ><input type='hidden' name='ok' value='ok' /><input type='submit' value='". __('Send by WhatsApp', 'food-order')."' /></form>"; 236 } 184 237 185 foreach ($result as $nome) {186 187 $terms = get_posts(array(188 'showposts' => -1,189 'post_type' => 'food_order',190 'tax_query' => array(191 array(192 'taxonomy' => 'cardapios',193 'field' => 'slug',194 'terms' => array("'".$nome."'"))195 ))196 );197 198 $termo = get_terms(array('taxonomy' =>'cardapios','slug' => "'".$nome."'"));199 200 if($order !== ""){201 echo " <div class='wpb_column vc_column_container vc_col-sm-4' id='".$termo[0]->slug."' ><div class='vc_column-inner'><div class='wpb_wrapper'><div class='wpb_text_column wpb_content_element'><div class='wpb_wrapper'>";202 if(!empty($termo[0]->name)){203 echo "<h3>". $termo[0]->name. "</h3>";204 }205 206 foreach ($terms as $obj) {207 208 if($order == "cardapio"){209 echo "<input type='checkbox' id='pedido' name='pedido[]' value='$obj->post_title' /> ";210 echo $obj->post_title. "<br>";211 212 }elseif($order == "lista"){213 $valor = get_post_meta($obj->ID);214 echo $obj->post_title. "<br>";215 }216 }217 218 echo "</div> </div></div></div></div>";219 220 }221 222 }223 224 if($order == "cardapio"){echo "<br ><input type='hidden' name='ok' value='ok' />225 <input type='submit' value='". __('Send by WhatsApp', 'food-order')."' /></form>";}226 227 228 238 }else{ 229 239 _e('There is no menus added!', 'food-order'); 230 240 } 231 241 232 } 242 } 233 243 234 244 public function register_post_type(){ … … 254 264 'menu_icon' => 'dashicons-list-view', 255 265 'menu_position' => 4, 256 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments','revisions' ),257 266 )); 258 267 … … 287 296 } 288 297 289 public function register_post_type_2(){ // tipo de post298 public function register_post_type_2(){ 290 299 291 300 register_post_type('tamanhos', array( -
food-restaurant-order-and-contact-by-whatsapp/trunk/readme.txt
r1800515 r1985889 2 2 Contributors: logosoft, elevawebsite 3 3 Tags: whatsapp, order, restaurant, automation 4 Requires at least: 4.64 Requires at least: 3.6 5 5 Tested up to: 4.9 6 Stable tag: 1.16 Stable tag: 2.0 7 7 License: free 8 8 … … 23 23 == Changelog == 24 24 = 1.0 = Menu creation, and let them to be ordered by whatsapp using a shortcode. 25 = 1.1 = Translation support added.25 = 1.1 = Bugs fixed. 26 26 27 27 == How it works? == … … 42 42 Finally, you need to click in 'Menu configuration' in Wordpress Configurations and add the cell phone you want to send the message. 43 43 44 UPDATE! 45 Now you are able to select just one item for category in your order. For example, you want the customer to select just one option of sideDish. To restrict this option, you need to put a description 'limite' in that category. 44 46 45 47 2: Showing then as a list: 48 46 49 Let's use the menu example above again. 47 50 You need to add the items and catgories as explained, but the shortcode changes a little bit:
Note: See TracChangeset
for help on using the changeset viewer.