GoodCom printers

Viewing 20 posts - 1 through 20 (of 55 total)
  • Author
    Posts
  • #35231
    proof
    Participant

      Hi all,

      I have seen a previous post
      https://www.wp-pizza.com/topic/integration-with-goodcom-wireless-order-printer/
      the user seems to have configured the printer to work with wp pizza but the instructions are marked as private/ is there anyone who has info on how to exactly set up these printers

      many thanks

      #35233
      Olly
      Admin & Mod

        i can assure you, what’s private there is irrelevant . (essentially it says configure the printer following the user manual, to pull orders in “php mode””

        its the original post that has the instructions

        that said, that’s also based on wppizza v2 in v3 this would have to be based on this
        https://docs.wp-pizza.com/developers/?section=action-wppizza_on_order_execute

        #35287
        proof
        Participant

          Thanks for clarifying,

          What would need to be different apart from the obvious file path?

          I’m a bit stumped

          #35288
          proof
          Participant

            This is what i have so far

            add_action( 'wppizza_on_order_execute', 'print_order');
            function print_order($orderId, $orderDetails) {
            require(WPPIZZA_PATH.'classes/class.wppizza.order.php');
            $orderDetails = new WPPIZZA_ORDER();
            $orderDetails->setOrderId($orderId);
            $order = $orderDetails->session_formatted();
            $pickup_delivery = ($order['ordervars']['pickup_delivery']['value'] == 'For Delivery' ? 1 : 2);
            $txt = "#PastaSpeed*$pickup_delivery*$orderId*";
            foreach($order['items'] as $item) {
            $nome = html_entity_decode($item[name]);
            $prodotto = trim(preg_replace('/\s+/', ' ', "$nome $item[size] $item[addinfo_plaintext]"));
            $txt .= "$item[quantity];$prodotto;$item[pricetotal];";
            }
            // ccustom3 is a custom field "name on the bell"
            $via = $order['customer']['post']['caddress']['value'] . ($order['customer']['post']['ccustom3']['value'] ? " c/o {$order[customer][post][ccustom3][value]}" : '');
            $ora = date('H:i d/m', strtotime($order['customer']['post']['wppizza_preorder']['value']));
            if($order['customer']['post']['ccustom6']['value'])
            $pagamento = 'Bancomat';
            $txt .= "*{$order[summary][delivery][value]}*;{$order[summary][total][value]};;{$order[customer][post][cname][value]};$via;$ora;;;$pagamento;{$order[customer][post][ctel][value]};*{$order[customer][post][ccustom2][value]}#\r\n";
            file_put_contents('/homepages/1/d720204031/htdocs/clickandbuilds/NazSpice/ordini.txt', $txt, FILE_APPEND);
            }
            #35289
            Olly
            Admin & Mod

              a) you dont need any of the require(WPPIZZA_PATH.’classes/class.wppizza.order.php’); etc
              this is wppizza v2 stuff
              please see https://docs.wp-pizza.com/developers/?section=action-wppizza_on_order_execute
              all details are in the $order_details parameters
              b) i cannot tell you what else you need for your goodcom printer to work. i have no knowledge about it. you will have to refer to the manufacturer information

              (of course, if someone else reads this, has knowledge about it and wants to chime in, please go ahead)

              #35290
              proof
              Participant

                thanks for that,

                i know what is needed to get the printer working.

                it is this function that im having trouble getting to work with V3 of wppizza. i will make a few changes and update 🙂

                #35327
                proof
                Participant

                  So, I have set the printer to print automatically from the email sent after an order.

                  The printer only supports plain text, but the plain text sent in the email appears to have some html from somewhere.

                  Where does this html come from? Is the email pure plain text?

                  Many thanks

                  #35329
                  Olly
                  Admin & Mod

                    what exact html are you getting ?

                    #35336
                    proof
                    Participant

                      hi ollly,

                      prints out this

                      
                      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                      <html xmlns="http://www.w3.org/1999/xhtml">
                      <head>
                      <title></title>
                      <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
                      </head>
                      <body style="font-family: monospace;">
                      <pre>
                      ORDER RECEIPT
                      </body>
                      </html>
                      #35342
                      Olly
                      Admin & Mod

                        ok, that’s because you are using (I assume ?!) a gmail/googlemail, hotmail or yahoo address

                        none of these understand plaintext properly (not my fault – they used to , but not anymore. not the last time i checked anyway).
                        for instance plaintext is not displayed in those using monospaced fonts unless you jump through many hoops and it would ask too much of the average user to set this up. therefore plaintext email would look like a right old mess

                        therefore the plugin forces html with the “pre” tags to make this legible. you will find that not using a gmail/hotmail/yahoo address will give you proper plaintext

                        alternatively there is also a filter that checks for those email addresses you could use to unset this behaviour for gmail
                        like so

                        
                        /* not tested as such but should work */
                        add_filter('wppizza_email_plaintext_to_webmail_domains', 'my_filter');
                        function my_filter($email_domains){
                        unset($email_domains[0]);//where 0 = @gmail. | 1 = @googlemail. | 2 = @outlook | 3 = @yahoo.| 4 =@hotmail.
                        return $email_domains
                        }
                        

                        but if you send plaintext emails to customers that have gmail accounts and use that filter, they would get the same mess

                        #35355
                        proof
                        Participant

                          this works perfectly for gmail, but not for outlook.com

                          all other properties of $email_domains end with ‘.’ see below

                          //where 0 = @gmail. | 1 = @googlemail. | 2 = @outlook <——– NO DOT HERE | 3 = @yahoo.| 4 =@hotmail.

                          but outlook does not have a .

                          if it can work with outlook then all my problems have been solved

                          Also if anyone wants details of how to set up goodcom printers to auto print, reply here. printer needs no PC just a sim card with mobile data.

                          I have semi working script for callback, enabling shop to accept/decline order with a reason for rejection. Email does not have this function.

                          Thanks again Olly

                          #35357
                          Olly
                          Admin & Mod

                            the missing dot is just a typo here in this thread (it’s in the plugin though)

                            #35359
                            proof
                            Participant

                              All set,

                              created new plain text email template and use this to send email to shop

                              use second template in HTML to send to customer

                              the only thing to make it possibly a little better would be to decrease the amount of white space between each parameter.

                              rather than this

                              Order Date :                                     February 27, 2018 3:49 pm
                              Order ID :                                                             138
                              Payment Due :                                                      £ 20.89
                              Delivery Type :                                               For Delivery
                              Paid By :                                                 Cash on Delivery
                              Transaction Id :                                          COD1519746586138
                              Note :                               Please allow 45 minutes for delivery.

                              if it could do this

                              Order Date :February 27, 2018 3:49 pm
                              Order ID :138
                              Payment Due :£ 20.89
                              Delivery Type :For Delivery
                              Paid By :Cash on Delivery
                              Transaction Id :COD1519746586138
                              Note :Please allow 45 minutes for delivery.
                              #35360
                              Olly
                              Admin & Mod

                                i don’t find this very legible (just my opinion)
                                however (not exactly the same but will make it somewhat more condensed), it force wraps at 74 characters
                                if you want it to wrap sooner ,you could set a couple of constants to be less

                                https://docs.wp-pizza.com/developers/?section=constants

                                notably
                                WPPIZZA_PLAINTEXT_MAX_LINE_LENGTH
                                and
                                WPPIZZA_PLAINTEXT_MAX_LINE_LENGTH_WORDWRAP

                                #35470
                                justin
                                Participant

                                  Hi Proof & Olly!

                                  I’m working on building a website for a friend of mine who runs a Pizza & Pasta delivery service.

                                  We’re hoping to use WP Pizza & some addons to get the job done. My friend has bought a Goodcom wireless printer and we’ve been attempting to integrate with WP Pizza. As you mentioned the previous post https://www.wp-pizza.com/topic/integration-with-goodcom-wireless-order-printer/ is outdated.

                                  Would you be so kind as to share the code you have so far?

                                  Thanks!

                                  #35472
                                  Olly
                                  Admin & Mod

                                    please read the thread .
                                    it says it all there . i.e

                                    https://docs.wp-pizza.com/developers/?section=action-wppizza_on_order_execute

                                    #35473
                                    Olly
                                    Admin & Mod

                                      but of course , if proof wants to chime in here with a v3 implementation
                                      please do

                                      #35474
                                      justin
                                      Participant

                                        Hi Olly 🙂

                                        Thank you for the quick response!

                                        I’m not sure if I’m on the right track I need to get the print template into a .txt file for the Wireless Goodcom Printer.

                                        
                                        add_filter('wppizza_on_order_execute_get_print_templates_by_id', 'my_prefix_my_filter');
                                        function my_prefix_my_filter($template_ids){
                                        /* 
                                        add details of a template id defined in WPPizza -> Templates -> Print
                                        for it to be available in subsequent wppizza_on_order_execute action hook as 3rd parameter
                                        */
                                        $template_ids[] = 1;/* get details of print template with id 3 */
                                        $txt = $template_ids;
                                        return $template_ids;
                                        file_put_contents('../ordini.txt', $txt, FILE_APPEND);
                                        }
                                        
                                        #35475
                                        Olly
                                        Admin & Mod

                                          @justin
                                          technically speaking you should really start your own topic, but given that this is somewhat closely related let’s keep it going here for now as it might be interesting for anyone else that deals with goodcom printers (sorry proof)

                                          now, regarding your code above (@justin)
                                          a) your $txt = ... and file_put_contents.. will do nothing (for starters your return statement is before the file_put_contents.. )

                                          b) your $template_ids[] = 1; however makes the third parameter in wppizza_on_order_execute https://docs.wp-pizza.com/developers/?section=action-wppizza_on_order_execute contain the template stuff.
                                          so you can now use that parameter in that wppizza_on_order_execute hook

                                          i.e simplify your above filter to just be

                                          
                                          add_filter('wppizza_on_order_execute_get_print_templates_by_id', 'my_prefix_my_filter');
                                          function my_prefix_my_filter($template_ids){
                                          $template_ids[] = 1;
                                          return $template_ids;
                                          }

                                          and then do what you need to do with third parameter in the wppizza_on_order_execute
                                          i.e

                                          
                                          add_action('wppizza_on_order_execute', 'my_prefix_my_action', 10, 3);
                                          function my_prefix_my_action($order_id, $order_details, $print_templates){
                                          /* 
                                          do something here with the now available $print_templates parameter 
                                          like  file_put_contents('../ordini.txt', $mystuff, FILE_APPEND);
                                          etc etc etc 
                                          */
                                          }
                                          
                                          #35481
                                          justin
                                          Participant

                                            Hi @Olly,

                                            My apologies, I’m not quite following.

                                            I can’t seem to output any data from the templates or order_detail arrays.

                                            
                                            add_filter('wppizza_on_order_execute_get_print_templates_by_id', 'my_prefix_my_filter');
                                            function my_prefix_my_filter($template_ids){
                                            $template_ids[] = 1;
                                            return $template_ids;
                                            }
                                            add_action('wppizza_on_order_execute', 'my_prefix_my_action', 10, 3);
                                            function my_prefix_my_action($order_id, $order_details, $print_templates){
                                            $txt = "Start";
                                            $txt .= $order_id;
                                            foreach ($order_details as $item => $val) {
                                            $txt .= "$item = ";
                                            $txt .= print_r($val);
                                            }	
                                            $txt .= $order_details['$delivery_type'];
                                            $txt .= $order_details['$customer']['name'];
                                            $txt .= $order_details['$customer']['email'];
                                            $txt .= $order_details['$customer']['address'];
                                            $txt .= $order_details['$customer']['telephone'];
                                            $txt .= $order_details['$customer']['comments'];
                                            foreach($order_details['items'] as $item) {
                                            $txt .= "$item[name];$item[quantity];$item[pricetotal];";
                                            }
                                            file_put_contents('../ordini.txt', $txt, FILE_APPEND);
                                            }
                                            

                                            Output ordini.txt

                                            
                                            Start53site = 1ordervars = 1customer = 1order = 1summary = 1localization = 1
                                            
                                          Viewing 20 posts - 1 through 20 (of 55 total)
                                          • The topic ‘GoodCom printers’ is closed to new replies.