Plugin Directory

Changeset 1985889


Ignore:
Timestamp:
12/05/2018 12:36:40 PM (7 years ago)
Author:
elevawebsite
Message:

Select just one item for category in your order

Location:
food-restaurant-order-and-contact-by-whatsapp/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • food-restaurant-order-and-contact-by-whatsapp/trunk/app/code/admin/settings.php

    r1800525 r1985889  
    149149                        'default' => '1',
    150150                        'options' => array(
    151                             '1' => __( 'Yes', 'id_whatsappchat' ),
    152                             '0'  => __( 'No', 'id_whatsappchat' )
     151                            '1' => __( 'Sim', 'id_whatsappchat' ),
     152                            '0'  => __( 'Não', 'id_whatsappchat' )
    153153                        )
    154154                    ),
  • food-restaurant-order-and-contact-by-whatsapp/trunk/food-order.php

    r1800418 r1985889  
    44 * Plugin URI: http://criacaode.site
    55 * Text Domain: food-order
    6  * Domain Path: /languages
    76 * Description: Create your menus, and order them by WhatsApp
    87 * Tags: whatsapp, order, restaurant, automation
    98 * Author: Mercado Binário
    109 * Author URI: criacaode.site
    11  * Version: 1.1
     10 * Version: 2.0
    1211 * License: GPL-2.0+
    1312 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    2120new Idnovate_Settings_API_WhatsAppChat();
    2221new 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 }
    3022
    3123if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit.php') && $_GET['post_type'] == 'food_order' ) {
     
    5143
    5244
    53         //$the_query = new WP_Term_Query($args);
    5445        foreach($the_query->get_terms() as $term){
    5546            echo "
     
    7465
    7566
    76     if(isset($_POST['ok']) && ($_POST['ok'] == 'ok')){
     67    if(isset($_POST['ok']) && ($_POST['ok'] == 'ok')){ 
    7768        $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++) 
    7970        {
    8071            $pedido = sanitize_text_field($_POST['pedido'][$i]);
     
    8374            }
    8475        }
    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, ",");
    8792       
    8893        $mobile_phone = $dadosBanco['mobile_phone'];
     
    97102    }
    98103
    99 
    100104class food_order{
    101105
     
    114118    private function __construct(){
    115119       
    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
    119123        add_shortcode('cardapio',array($this,'cardapio'));
    120124    }
    121 
     125   
    122126 public function cardapio($atts){
    123127   
     
    130134
    131135
    132     $nomes = explode(",", strval($nome));
     136    $nomes = explode(",", strval($nome)); 
    133137    $order = $atts['order'];
    134138    $result = array();
     
    140144foreach ($nomes as $nome) {
    141145
    142         $terms = get_posts(array(
     146        $terms = get_posts(array( 
    143147            'showposts' => -1,
    144148            'post_type' => 'food_order',
     
    151155        );
    152156        $termo = get_terms(array('taxonomy' =>'cardapios','slug' => "'".$nome."'"));
    153    
    154     if(!empty($terms)){ $ok = true; }
     157
     158    if(!empty($terms)){ $ok = true; } 
    155159}
    156160
    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'>
    171176                            <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>";
    179185                }
    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
    182232        }
    183233
     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        }
    184237       
    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 
    228238    }else{
    229239        _e('There is no menus added!', 'food-order');
    230240    }
    231241
    232 }
     242} 
    233243
    234244    public function register_post_type(){
     
    254264            'menu_icon' => 'dashicons-list-view',
    255265            'menu_position' => 4,
    256             'supports'      => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments','revisions' ),
    257266        ));
    258267
     
    287296    }
    288297
    289     public function register_post_type_2(){ // tipo de post
     298    public function register_post_type_2(){
    290299
    291300        register_post_type('tamanhos', array(
  • food-restaurant-order-and-contact-by-whatsapp/trunk/readme.txt

    r1800515 r1985889  
    22Contributors: logosoft, elevawebsite
    33Tags: whatsapp, order, restaurant, automation
    4 Requires at least: 4.6
     4Requires at least: 3.6
    55Tested up to: 4.9
    6 Stable tag: 1.1
     6Stable tag: 2.0
    77License: free
    88
     
    2323== Changelog ==
    2424= 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.
    2626
    2727== How it works? ==
     
    4242    Finally, you need to click in 'Menu configuration' in Wordpress Configurations and add the cell phone you want to send the message.
    4343
     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.
    4446
    45472: Showing then as a list:
     48
    4649    Let's use the menu example above again.
    4750    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.