admin管理员组文章数量:1278880
my company is working with different restaurants to digitize their menus so that people dont touch the menu cards in this Covid 19 pandemic, so every table in a restaurant will have a unique qr placed on it, when a customer scans it the menu will open and he can order it from there, the issue i am facing is how to set all those unique urls linked with the table number, and how to show the table number on the dashboard of woocommerce so that the restaurant knows the table number from which the order came. thanks and regards Aetzad
my company is working with different restaurants to digitize their menus so that people dont touch the menu cards in this Covid 19 pandemic, so every table in a restaurant will have a unique qr placed on it, when a customer scans it the menu will open and he can order it from there, the issue i am facing is how to set all those unique urls linked with the table number, and how to show the table number on the dashboard of woocommerce so that the restaurant knows the table number from which the order came. thanks and regards Aetzad
Share Improve this question asked Aug 6, 2020 at 15:20 Aetzad AsgharAetzad Asghar 155 bronze badges2 Answers
Reset to default 1I don't have a WooCommerce currently to test this out on, so it's very rough and ready, and may not even work... But, I think the logic is fairly sound. Give this a go:
// Store session value for table number
add_action('init', 'store_table_number');
function store_table_number() {
if( $_GET['dining'] ) {
global $tableNo;
$tableNo = array( 'number' => $_GET['dining'] );
}
}
// Add Table Number field to checkout
add_filter( 'woocommerce_checkout_fields' , 'table_number_checkout' );
function table_number_checkout( $fields ) {
$fields['order']['table_number'] = array(
'label' => __('Table Number', 'woocommerce'),
'placeholder' => _x('Table', 'placeholder', 'woocommerce'),
'value' => $GLOBALS['tableNo']['number'],
'required' => false,
'class' => array('form-row-wide'),
'clear' => true
);
return $fields;
}
// Output table number in WP Admin panel
add_action( 'woocommerce_admin_order_data_after_shipping_address', 'table_number_admin', 10, 1 );
function table_number_admin($order){
echo '<p><strong>'.__('Table Number').':</strong> ' . get_post_meta( $order->get_id(), '_table_number', true ) . '</p>';
}
The above will be added to your functions.php file. The first function starts the session and stores the value of your URL variable. The second adds a table number field to the WooCommerce checkout page, referenced from here. And finally, the third function adds a table number field to the order screen in your WordPress admin, which will ultimately allow you to configure your email output. Again referenced from the above link.
From what you have described, could you not simply pass in a variable in the url string which then gets stored in a session for the guest? Your URL might look something like this:
https://www.therestaurant/menu?dining=22
You can then of course retrieve that table number using a PHP get:
$tableNumber = $_GET['dining'];
This would give you the facility to take the user straight to the order / menu page on your site, whilst still storing their table to later send with the form submission to the kitchen and would let you easily add / remove / relabel tables on the fly.
Hope it helps. Ben.
本文标签: pluginsWoocommerce different URL for every table placed in the restaurant
版权声明:本文标题:plugins - Woocommerce different URL for every table placed in the restaurant 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741211545a2359221.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论