• Resolved mellow1

    (@cdsigns)


    Dear sir / madam,

    We use the plugin for several restaurants and are very happy with it. They prefer to print the orders for the kitchen. You have been great and helped us already to add the print button to the order overview detailpage.

    The kitchen would also like to have this “print order” button within the notification pop up of the dashboard. So if the vendor receives a new order, currently they see the pop up with the order summary. We would like to add the “print now” button to this notification pop up.

    We are not sure which file to edit to make the button appear here. We have a demo-site available if you need access or maybe you can provide the snippet or file name we need to make changes to.

    Thank you very much

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter mellow1

    (@cdsigns)

    Could you please let us know if you need any link or further information to help us out?

    Thank you!

    Plugin Author WC Lovers

    (@wclovers)

    Kindly show me screenshots – where you have print button now and where you want to have this?

    Thread Starter mellow1

    (@cdsigns)

    Currently the print button is at the detail page where a store vendor can check an order: Screenshot-2020-08-17-at-19-04-54

    We would like to add the print button to the notification pop up: idea shown within the red border.
    order-Notification-Popup

    Plugin Author WC Lovers

    (@wclovers)

    Sorry, print will not work from here.

    Print only works from a page where all details exists, hence we can print that page content.

    Thread Starter mellow1

    (@cdsigns)

    Thank you for the very quick reply. I now understand why the print button in that pop up is not possible.

    We have a different idea, could you please help me out with that?

    The order notification pop up has a link with the order ID, so you can click the notification and the order detail page is opened.

    Could you help us change this link, so if the user click the order ID in the pop up, the detail page is opened and also the print prompt? We found that it is possible with javascript to open a certain url with the print prompt, but can’t implement it within the code from the file we need: /core/class-wcfm-notification.php

    We are not sure but think it should be somewhere in here

    // Vendor Notification
        if( $WCFM->is_marketplace ) {
    			foreach ( $order->get_items() as $item_id => $item ) {
    				$product      = $order->get_product_from_item( $item );
    				$product_id   = 0;
    				if ( is_object( $product ) ) {
    					$product_id   = $item->get_product_id();
    				}
    				if( $product_id ) {
    					$author_id = -1;
    					$message_to = wcfm_get_vendor_id_by_post( $product_id );
    					
    					if( $message_to ) {
    						$wcfm_messages = sprintf( __( 'You have received an Order <b>#%s</b> for <b>%s</b>', 'wc-frontend-manager' ), '<a target="_blank" class="wcfm_dashboard_item_title" href="' . get_wcfm_view_order_url($order_id) . '">' . $order->get_order_number() . '</a>', get_the_title( $product_id ) );
    						$this->wcfm_send_direct_message( $author_id, $message_to, $author_is_admin, $author_is_vendor, $wcfm_messages, 'order', apply_filters( 'wcfm_is_allow_order_notification_email', false ) );
    					}
    					
    					do_action( 'wcfm_after_new_order_vendor_notification', $message_to, $product_id, $order_id );
    				}
    			}
    		}

    This is the example we found for open link in new window with print prompt: https://stackoverflow.com/questions/12276416/how-to-open-a-link-new-tab-with-print-command but we are unable to insert this javascript into the above php file

    • This reply was modified 4 years, 6 months ago by mellow1.
    Plugin Author WC Lovers

    (@wclovers)

    Understand.

    Can you please show me a screenshot for the previous code we provided you for adding “Print” button under order details page.

    Thread Starter mellow1

    (@cdsigns)

    Yes, you’ve provided a snippet to add the print button on the order detail page.

    add_action( 'wcfm_after_order_quick_actions', function( $order_id ) {
    	?>
    	<a id="wcfm_order_print" class="add_new_wcfm_ele_dashboard text_tip" style="" href="<?php echo $order_id; ?>" data-tip="<?php _e( 'Print Order', 'wc-frontend-manager' ); ?>"><span class="wcfmfa fa-print"></span><span class="text"><?php _e( 'Print', 'wc-frontend-manager' ); ?></span></a>
    	<script>
    	jQuery(document).ready(function($) {
    		$('#wcfm_order_print').click(function( event ) {
    			event.preventDefault();
    			
    			Pagelink = "order_details";
    			var pwa = window.open(Pagelink, "_new");
    			pwa.document.open();
    			
    			pwa.document.write( "<html><head><script>function step1(){\n" +
    				"setTimeout('step2()', 10);}\n" +
    				"function step2(){window.print();window.close()}\n" +
    				"</scri" + "pt></head><body onload='step1()'>\n<table><tr><td><h2>Order #" + $(this).attr('href') + "</h2></td></tr><tr><td><table>" + $('#orders_details_general_expander table').html() + "</table></td></tr><tr><td><br /><hr /><br /><table>" + $('#orders_details_items_expander .woocommerce_order_items').html() + '</table></td></tr><tr><td><br /><hr /><br /><table style="width:50%;float:right;">' + $('#orders_details_items_expander .wc-order-totals').html() + '</table></td></tr></table></body></html>' );
    			pwa.document.close();
    		});
    	});
    	</script>
    	<?php
    }, 20 );
    Plugin Author WC Lovers

    (@wclovers)

    Thanks, kindly add this snippet to your site –

    add_action( 'end_wcfm_orders_details', function( $order_id ) {
    	?>
    	<script>
    	jQuery(document).ready(function($) {
    		if( $('#wcfm_order_print').length > 0 ) {
    			$('#wcfm_order_print').click();
    		}
    	});
    	</script>
    	<?php
    }, 500 );
    Thread Starter mellow1

    (@cdsigns)

    Thank you for the code snippet. I’ve added a new snippet to my website. If I click the link in the order notification pop up the link is not correct, it tries to open this page:

    https://myfakeurlsite.nl/store-manager/settings/.%20get_wcfm_view_order_url(order_id/

    and for example the last order the link should be: https://myfakeurlsite.nl/store-manager/orders-details/49968/

    Plugin Author WC Lovers

    (@wclovers)

    Is this issue started after adding this latest code?

    Are you able to access orders from notification dashboard orders’ links?

    Thread Starter mellow1

    (@cdsigns)

    Thank you for the tip! There was a mix up somewhere in the php-file that broke the link.

    We now have the pop up working with the print-button working like a charm, thank you very much!

    • This reply was modified 4 years, 6 months ago by mellow1.
    Plugin Author WC Lovers

    (@wclovers)

    Great, thanks for the update ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Print order button in notification’ is closed to new replies.