GoodCom printers

Viewing 20 posts - 21 through 40 (of 55 total)
  • Author
    Posts
  • #35482
    Olly
    Admin & Mod

      please check what $order_details actually contains

      stuff like

      $txt .= $order_details[‘$delivery_type’];

      makes no sense

      and using print_r in a variable should also be print_r($var, true) in any event

      #35483
      justin
      Participant

        @Olly I believe the $order_details contains the order details required to build the string I need for the Wireless Printer.

        After reviewing the Goodcom documentation it’s apparent I need to create a custom string to save in the .txt file supported by the Wireless Printer I don’t expect the templates would be generating at the moment the documentation explains an example string E.g #01*1*10005*1;Chicken,3.00;4;Tom;Address;15:47 03-08-10;113;7;cod:;**Comment#

        Is there documentation of the order_details and arrays ordervars, customer, order, summary, localization so I can refer to this and build the string?

        #35484
        proof
        Participant

          Hi Justin

          I will update soon

          #35485
          justin
          Participant

            @proof Hi Proof, excellent thank you!

            #35486
            Olly
            Admin & Mod

              simply save the $order_details array into a file somewhere and have a look at the array
              it should be quite self explanatory what is what

              i.e something like file_put_contents(‘../ordini.txt’, print_r($order_details , true));

              and then build your actual string as you need it

              (and perhaps the same with the other parameters like the $print_templates vars etc etc )

              #35487
              Olly
              Admin & Mod

                @proof

                thanks for chiming in.
                after all i can only give abstract advice as i know nothing about these printers so anything more concrete would be appreciated
                cheers

                #35518
                proof
                Participant

                  let me know if you need any more help

                  add_action( 'wppizza_on_order_execute', 'print_order', 1);
                  function print_order($order_id, $order, $print_templates) {
                  //declare new ORDER class and assign order details to var order
                  $order = new WPPIZZA_ORDER();
                  $order = $order->session_formatted();
                  [EDIT/NOTE BY ADMIN - AS PEOPLE STILL SEEM TO USE IT: THE ABOVE TWO LINES SHOULD NOT BE THERE. SEE COMMENTS FURTHER DOWN]	
                  //check if delivery or pickup
                  $pickup_delivery = ($order['ordervars']['order_type']['value_formatted'] == 'For Delivery' ? 1 : 2);
                  //check if order has been paid
                  $order_paid = ($order['ordervars']['payment_method']['value_formatted'] == 'Cash' ? 7 : 6);
                  //add pickup_delivery and order_id to txt file
                  $txt = "#NazSpice*$pickup_delivery*$order_id*";
                  //add each item from order into txt file, including ONE extra option
                  foreach($order['order']['items'] as $item) {
                  $txt .= "$item[quantity];$item[title];$item[pricetotal_formatted];$item[price_label];";
                  }
                  //add all other order details into txt file
                  $txt .= "*{$order[summary][delivery_charges][0][label]}*{$order[summary][discount][0][value_formatted]};{$order[summary][total][0][value_formatted]};{$order[ordervars][wp_user_id][value_formatted]};{$order[customer][cname][value]};{$order['customer']['caddress']['value']};{$order[customer][ctel][value]};{$order[ordervars][order_date][value_formatted]};$order_paid;{$order[ordervars][payment_gateway][value]};{$order[customer][ccomments][value]}*{$order[customer][ccustom1][value]}#\r\n";
                  file_put_contents('../ordini.txt', $txt, FILE_APPEND);
                  }
                  #35519
                  justin
                  Participant

                    @proof Hey proof! Thank you very very much!

                    We are struggling to connect to the wireless printer interface, we navigate to the screen that displays “Terminal ID: 426 Please set the parameters on the browser.” on the wireless printer.

                    How did you access the interface to update the settings? It appears Goodcom use the “Remote Terminal” program to update the settings?

                    On a side note, in the scenario of a pizza shop which has “extra toppings” where would you include this information in the $txt string? Would you add it after the item name in the name section? Something like ;$item[title] . ” ” . $item[extra];

                    Thanks again!

                    #35520
                    proof
                    Participant

                      I’ll have to get back to you on the rest but

                      http://goodcom.cn/dl/login.php

                      to set the parameters 🙂

                      #35521
                      justin
                      Participant

                        @proof You’re a legend! Thank you! I have no idea why they didn’t provide us this link… lol It’s not in the instruction booklet :\

                        #35522
                        Olly
                        Admin & Mod

                          Hi
                          don’t mean to criticize and as mentioned I know nothing about those printers.
                          maybe I’m missing something, but what’s the supposed benefit of doing this ?

                          
                          //declare new ORDER class and assign order details to var order
                          $order = new WPPIZZA_ORDER();
                          $order = $order->session_formatted();
                          
                          #35524
                          Olly
                          Admin & Mod

                            As a sidenote while I am here, I would also suggest something a bit more dynamic regarding the “all other order details” as they are variable and not always the same everywhere
                            perhaps something along these lines (will no doubt need tweaking according to what goodcom printers really need, but as a starting point)

                            
                            $additional_data = array();
                            /* customer data */
                            $customer_data = array();
                            foreach($order[customer] as $k=>$v){
                            $customer_data[$k]=$v['value'];//or value_formatted
                            }
                            $additional_data[] = '{'.implode('};{', $customer_data).'}';//tweak as required
                            /* order vars */
                            $ordervars= array();
                            foreach($order[ordervars] as $k=>$v){
                            $ordervars[$k]=$v['value'];//or value_formatted
                            }
                            $additional_data[] = '{'.implode('};{', $ordervars).'}';//tweak as required
                            /* add $order[summary] too (this will always be 2 levels deep to account for multiple taxrates for example) so somewhat as above but a 2 level/nested foreach loop*/
                            /* then put it together - assuming it needs "*" between things - probably needs tweaking too as i dont know what those printers need but I would think one gets the idea*/
                            $txt .= implode('*', $additional_data);
                            
                            #35523
                            justin
                            Participant

                              @proof How did you program the order callback? I was thinking a custom php script that email’s the customer the pickup time? Or an Ajax time update on the order confirmation page?

                              On a side note I noticed the user manual (ref: Image1, Image2) explains to keep the ordini.txt small. To delete orders once they’re accepted? How did you do this? I can only think of either a) not doing it b) clear the whole txt file (which might clear new orders coming in at the same time) c) create a php script to selectively delete the accepted order leaving the others.

                              #35526
                              Olly
                              Admin & Mod

                                @proof
                                ah, i know where you are going wrong here regarding my note to the benefits of //declare new ORDER class and assign order details to var order and assuming your action hook usage is as you posted it

                                it should be

                                add_action( 'wppizza_on_order_execute', 'print_order', 10, 3);
                                /*or if you want */
                                add_action( 'wppizza_on_order_execute', 'print_order', 1, 3);
                                

                                not
                                add_action( 'wppizza_on_order_execute', 'print_order', 1);
                                otherwise the 2nd and 3rd parameter will not be available to you !!!

                                #35527
                                justin
                                Participant

                                  @olly Thanks Olly!

                                  #35532
                                  proof
                                  Participant

                                    Hi guys,

                                    You will have to forgive my understanding of the script. I am still fairly new to it all. The script I posted does work with MY printer setup, I have a custom receipt layout which is something you will have to do if you want more than one extra option/topping

                                    I have a callback provided by goodcom, I would like to have the thank you page keep loading until the shop accepts the order and also set the order to acknowledged. The callback provided does nothing apart from telling the printer it’s all good

                                    I also have not figured the deleting of orders from the txt file. I have opted to delete the file at certain times.

                                    #35533
                                    Olly
                                    Admin & Mod

                                      I’m not disputing that it works for you (how could I . I dont have one of these printers)
                                      All I’m saying is that you are causing unnecessary overheads by getting the parameters again when they already exist
                                      and if you one day decide to add another customer formfield for example (or remove one for that matter) you will have to add it to this script again wheras a simple foreach loop in the first place would already take care of that

                                      again. i would suggest you change your action as mentioned, get rid of the ‘new order class’ etc and use the parameter available
                                      (and perhaps brush up on how wordpress action/filter priorities and parameters work )

                                      #35538
                                      proof
                                      Participant

                                        I was just clarifying to Justin that the script is built for my configuration of the printer and for him to have more than one topping/extra he would have to configure the printer to handle that.

                                        I assume you have no tools to do this with?

                                        I most certainly value your feedback, I know just enough to figure it out, but obviously as you’ve mentioned there is better ways of doing it.

                                        Can you think of any way to keep the thank you page loading until shop accepts order? With the order being set to acknowledged and the order deleted from the txt file when accepted

                                        The callback has a simple if(order accepted) which executes once shop has accepted

                                        #35544
                                        Olly
                                        Admin & Mod
                                          #38113
                                          Olly
                                          Admin & Mod

                                            [previously closed topic reopened by admin]

                                          Viewing 20 posts - 21 through 40 (of 55 total)
                                          • The topic ‘GoodCom printers’ is closed to new replies.