42 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * Plugin Name: Mont58 Coffee Label
 | 
						|
 * Plugin URI: https://example.com/
 | 
						|
 * Description: A plugin for displaying coffee labels.
 | 
						|
 * Version: 1.0.0
 | 
						|
 * Author: Autonomic Co-op
 | 
						|
 * Author URI: https://autonomic.zone/
 | 
						|
 * License: GPL2
 | 
						|
*/
 | 
						|
 | 
						|
 | 
						|
// Add a sidepanel on WooCommerce order pages
 | 
						|
add_action('add_meta_boxes', 'mont58_coffee_label_add_sidepanel');
 | 
						|
 | 
						|
function mont58_coffee_label_add_sidepanel() {
 | 
						|
  add_meta_box(
 | 
						|
    'mont58_coffee_label_sidepanel',
 | 
						|
    'Order Label',
 | 
						|
    'mont58_coffee_label_render_sidepanel',
 | 
						|
    'shop_order',
 | 
						|
    'side',
 | 
						|
    'high'
 | 
						|
  );
 | 
						|
}
 | 
						|
 | 
						|
function mont58_coffee_label_render_sidepanel($post) {
 | 
						|
  // Render the content of the sidepanel here
 | 
						|
  $order_id = $post->ID;
 | 
						|
  echo '<a href="/coffee-label?order_id=' . $order_id . '" class="button button-primary">View Label</a>';
 | 
						|
}
 | 
						|
 | 
						|
// Load custom template
 | 
						|
function load_custom_template($template) {
 | 
						|
  if (is_page('coffee-label')) {
 | 
						|
    return plugin_dir_path(__FILE__) . 'template-order-label.php';
 | 
						|
  }
 | 
						|
 | 
						|
  return $template;
 | 
						|
}
 | 
						|
 | 
						|
add_filter('template_include', 'load_custom_template'); |