WPPizza – A Restaurant Plugin for WordPress › Support › General Support › GoodCom printers
- AuthorPosts
- 3 March, 2018 at 1:53 am #35482
please check what
$order_details
actually containsstuff 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
3 March, 2018 at 1:58 am #35483@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?
3 March, 2018 at 2:00 am #35484Hi Justin
I will update soon
3 March, 2018 at 2:02 am #354853 March, 2018 at 2:04 am #35486simply save the $order_details array into a file somewhere and have a look at the array
it should be quite self explanatory what is whati.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 )
3 March, 2018 at 2:11 am #35487thanks 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
cheers4 March, 2018 at 2:00 am #35518let 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); }
4 March, 2018 at 2:05 am #35519@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!
4 March, 2018 at 2:11 am #35520I’ll have to get back to you on the rest but
http://goodcom.cn/dl/login.php
to set the parameters 🙂
4 March, 2018 at 2:16 am #35521@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 :\
4 March, 2018 at 2:19 am #35522Hi
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();
4 March, 2018 at 2:41 am #35524As 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);
4 March, 2018 at 2:42 am #35523@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.
4 March, 2018 at 2:52 am #35526@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 itit 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 !!!4 March, 2018 at 5:54 am #35527@olly Thanks Olly!
4 March, 2018 at 12:54 pm #35532Hi 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.
4 March, 2018 at 1:07 pm #35533I’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 thatagain. 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 )4 March, 2018 at 1:34 pm #35538I 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
4 March, 2018 at 6:05 pm #3554420 June, 2018 at 2:28 am #38113[previously closed topic reopened by admin]
- AuthorPosts
- The topic ‘GoodCom printers’ is closed to new replies.