Forum Replies Created
- AuthorPosts
-
RE: Side Issue
I’m not entirely sure what I’m doing wrong. I have a 3 week old newborn so I’m a tad tired. I can’t seem to print_r the arrays? They appear to just print a single “1” character rather than the array.I was missing
, true);
// Save Order To TXT File // 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(); //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 = "#Gourmet*$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];"; foreach($item['extend_data']['addingredients'] as $extra) { $txt .= print_r($item); $txt .= print_r($extra); $txt .= print_r($item['extend_data']); $txt .= print_r($item['extend_data']['addingredients']); $txt .= var_dump($item); $txt .= var_dump($extra); } } //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]};{$order['customer']['cemail']['value']};#\r\n"; file_put_contents('/home2/seoexpe1/public_html/orders.txt', $txt, FILE_APPEND); } // Save Order To TXT File //
Hi Olly,
Thanks for taking a look 🙂
I wasn’t aware at the time but it appears only the Pizza’s with add ingredients enabled aren’t progressing to the thank you page. E.g. Atlantic Large 12″
Thanks Olly,
The development site is hosted in the subfolder here: https://seoexpertgoldcoast.com.au/gourmet/
Thanks Olly!
Hi Olly,
Thank you so much! ^.^ Your reference to W3C Schools helped perfectly.
I’m not very proficient with Javascript yet.
For anyone else who may need this:
return this.optional(element) || /(banana|lemon|mango|pineapple)/i.test(value);
BTW, my friend would like to have these rules for payment/pickup/delivery:
Delivery: Credit Card only (We’ll be using your stripe extension)
Pickup: Credit Card or CashCould you give me a point in the right direction? Thanks again!
@Olly
I suggested this extension to our friend, they declined saying they don’t want to deliver to certain streets in the postcode -.-
So we plan to add the street names in replacement for John|Smith|David|Luke
Thanks Olly, I understand now. I’ve added the “My Rule” to the address field.
I’m getting an error I’m sure it has to do with this line, I’m not exactly sure how to include “match(/(banana|lemon|mango|pineapple)/i)” in the test string.
return this.optional(element) || test(value).match(/(banana|lemon|mango|pineapple)/i);
Error:
jquery.validate.min.js?ver=3.2.10:4 Uncaught ReferenceError: test is not defined at a.validator.jQuery.validator.methods.my_rule ((index):278) at a.validator.check (jquery.validate.min.js?ver=3.2.10:4) at a.validator.element (jquery.validate.min.js?ver=3.2.10:4) at a.validator.onfocusout (jquery.validate.min.js?ver=3.2.10:4) at HTMLTextAreaElement.b (jquery.validate.min.js?ver=3.2.10:4) at HTMLFormElement.dispatch (jquery.js?ver=1.12.4:3) at HTMLFormElement.r.handle (jquery.js?ver=1.12.4:3) at Object.trigger (jquery.js?ver=1.12.4:3) at Object.a.event.trigger (jquery-migrate.min.js?ver=1.4.1:2) at Object.simulate (jquery.js?ver=1.12.4:3) jQuery.validator.methods.my_rule @ (index):278 check @ jquery.validate.min.js?ver=3.2.10:4 element @ jquery.validate.min.js?ver=3.2.10:4 onfocusout @ jquery.validate.min.js?ver=3.2.10:4 b @ jquery.validate.min.js?ver=3.2.10:4 dispatch @ jquery.js?ver=1.12.4:3 r.handle @ jquery.js?ver=1.12.4:3 trigger @ jquery.js?ver=1.12.4:3 a.event.trigger @ jquery-migrate.min.js?ver=1.4.1:2 simulate @ jquery.js?ver=1.12.4:3 c @ jquery.js?ver=1.12.4:3 jquery.validate.min.js?ver=3.2.10:4 Uncaught ReferenceError: test is not defined at a.validator.jQuery.validator.methods.my_rule ((index):278) at a.validator.check (jquery.validate.min.js?ver=3.2.10:4) at a.validator.checkForm (jquery.validate.min.js?ver=3.2.10:4) at a.validator.form (jquery.validate.min.js?ver=3.2.10:4) at HTMLFormElement.<anonymous> (jquery.validate.min.js?ver=3.2.10:4) at HTMLFormElement.dispatch (jquery.js?ver=1.12.4:3) at HTMLFormElement.r.handle (jquery.js?ver=1.12.4:3)
The functions.php file looks like below:
/*-----------------------php (see also https://docs.wp-pizza.com/developers/?section=filters-actions-functions)-----------------------------------------------*/ //to add your own rule - let's say 'my_rule' add_filter('wppizza_filter_validation_rules','my_function'); function my_function($validation_rules){ $validation_rules['my_rule']= array( 'lbl'=> 'My Rule', 'parameters'=>false, 'callback'=>false, 'enabled'=>true); return $validation_rules; } function validation() {?> <script> /*-----------------------js-----------------------------------------------*/ // then add the rule like so via wp_footer action hook (or add it to an already existing js file) // adjust the validation pattern as appropriate for your validation rule jQuery(document).ready(function($){ jQuery.validator.methods.my_rule = function (value, element) { return this.optional(element) || test(value).match(/(banana|lemon|mango|pineapple)/i); } // adding a custom error message if validation fails instead of the default (not actually tested but should work just the same) jQuery.extend(jQuery.validator.messages, { my_rule: 'some error message', }) }); </script> <?php } // ENQUEUE SCRIPTS AND STYLES function enqueue_theme_scripts(){ wp_enqueue_script( 'customjs', get_template_directory_uri() . '/ordervalidation.js', array(), '1.0.0', true ); add_action( 'wp_footer', 'validation', 50 ); } add_action( 'wp_enqueue_scripts', 'enqueue_theme_scripts' );
Thank you!
Hi Olly,
Thank you for the reference, I’ve never used that plugin before.
Could you please offer some more assistance?
@olly Thanks Olly!
@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.
@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 :\
@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!
@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?
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
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); }
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!
- AuthorPosts