I'm new on plugin development.
I'm try to create a custom Printable form page in wp-admin to create Customer Postal Address.
very Similar <a href="https://wordpress.org/plugins/woocommerce-order-address-print/" rel="nofollow noreferrer">This plugin</a>
when administrator click on <strong>"print Address"</strong> link , pop-up
page with customer address and information for print address
<a href=" " rel="nofollow noreferrer"><img src=" " alt="enter image description here"></a>
<strong>The Problem is :</strong>
I get fatal Error when click on <strong>print order</strong> anchor tag and i can't run any
action on
:
<strong>Fatal error: Call to undefined function add_action() in C:\xampp\htdocs\wp-content\plugins\address generator\template.php on line 4</strong>
<strong>Template.php</strong>
I'm try to create a custom Printable form page in wp-admin to create Customer Postal Address.
very Similar <a href="https://wordpress.org/plugins/woocommerce-order-address-print/" rel="nofollow noreferrer">This plugin</a>
when administrator click on <strong>"print Address"</strong> link , pop-up
Code:
template.php
<a href=" " rel="nofollow noreferrer"><img src=" " alt="enter image description here"></a>
<strong>The Problem is :</strong>
I get fatal Error when click on <strong>print order</strong> anchor tag and i can't run any
Code:
wordpress
Code:
template.php
<strong>Fatal error: Call to undefined function add_action() in C:\xampp\htdocs\wp-content\plugins\address generator\template.php on line 4</strong>
Code:
<?php
/**
* Plugin Name: Address Generator
* Plugin URI: http://CGTV.ir
* Description:Generate Postal Label for Parcel
* Version: 1.0 or
* Author: Hamed Mayahian
* Author URI: CGTV.ir
* License: A "Slug" license name e.g. GPL12
*/
// ADDING COLUMN TITLES (Here 2 columns)
/*define( 'MY_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
include( MY_PLUGIN_PATH . 'template.php');
*/
require_once(ADDRESS__PLUGIN_DIR .'template.php');
add_filter( 'manage_edit-shop_order_columns', 'custom_shop_order_column',11);
function custom_shop_order_column($columns)
{
//add columns
$columns['my-column1'] = __( 'چاپ آدرس','theme_slug');
return $columns;
}
// adding the data for each orders by column (example)
add_action( 'manage_shop_order_posts_custom_column' , 'cbsp_credit_details', 10, 2 );
function cbsp_credit_details( $column )
{
global $post, $woocommerce, $the_order;
$order_id = $the_order->id;
switch ( $column )
{
case 'my-column1' :
$myVarOne = wc_get_order_item_meta( $order_id, '_the_meta_key1', true );
echo $myVarOne;
echo "<a target='_blank' href='".plugins_url( 'template.php' , __FILE__ )."?order=$order_id'>Print Address</a>";
break;
}
}
<strong>Template.php</strong>
Code:
<?php
add_action('init', 'my_init', 1);
function my_init(){
global $post, $woocommerce, $the_order;
$id = $_GET['order'];
$order = new WC_Order($id);
$address = $order->get_billing_address();
$customer_id = get_current_user_id();
if($_GET['order'] == "") {
// no username entered
echo "آدرس پیدا نشد";
} else {
echo "Hello, " . $address;
}
}
?>