Skip to content

Commit

Permalink
Patch updates before v1.0.0 major release
Browse files Browse the repository at this point in the history
  • Loading branch information
kgkrishnavbi committed Oct 25, 2019
1 parent b172d25 commit 074316d
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 72 deletions.
49 changes: 8 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
=== Plugin Name ===
Contributors: (this should be a list of wordpress.org userid's)
Donate link: https://kgopalkrishna.com
Tags: comments, spam
Requires at least: 3.0.1
Tested up to: 3.4
Stable tag: 4.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: woocommerce, order, view
Requires at least: 5.0.0
Tested up to: 5.2.3
Stable tag: 1.0
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Here is a short description of the plugin. This should be no more than 150 characters. No markup here.
This plugin gives a strict View-Only access to Woocommerce orders for specified user roles.

== Description ==

Expand Down Expand Up @@ -39,23 +39,8 @@ you put the stable version, in order to eliminate any doubt.

== Installation ==

This section describes how to install the plugin and get it working.

e.g.

1. Upload `wc-order-view.php` to the `/wp-content/plugins/` directory
1. Activate the plugin through the 'Plugins' menu in WordPress
1. Place `<?php do_action('plugin_name_hook'); ?>` in your templates

== Frequently Asked Questions ==

= A question that someone might have =

An answer to that question.

= What about foo bar? =

Answer to foo bar dilemma.

== Screenshots ==

Expand All @@ -68,25 +53,7 @@ directory take precedence. For example, `/assets/screenshot-1.png` would win ove
== Changelog ==

= 1.0 =
* A change since the previous version.
* Another change.

= 0.5 =
* List versions from most recent at top to oldest at bottom.

== Upgrade Notice ==

= 1.0 =
Upgrade notices describe the reason a user should upgrade. No more than 300 characters.

= 0.5 =
This version fixes a security related bug. Upgrade immediately.

== Arbitrary section ==

You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated
plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or
"installation." Arbitrary sections will be shown below the built-in sections outlined above.
* Initial release.

== A brief Markdown Example ==

Expand Down
4 changes: 2 additions & 2 deletions admin/class-wc-order-view-admin-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ function column_cb( $item ) {
function column_order_id( $item ) {

$order_id = "";
$order_id .= '<a href="#" class="order-preview" data-order-id="' . $item[ 'order_id' ] . '" title="Preview">Preview</a>';
$order_id .= '<a href="#" class="order-view"><strong>#' . $item[ 'order_id' ] .' '. $item[ 'name' ] . '</strong></a>';
$order_id .= '<a href="admin.php?page=wc-order-view&action=view&order_id=' . $item[ 'order_id' ] . '" class="order-preview" data-order-id="' . $item[ 'order_id' ] . '" title="Preview">Preview</a>';
$order_id .= '<a href="admin.php?page=wc-order-view&action=view&order_id=' . $item[ 'order_id' ] . '" class="order-view"><strong>#' . $item[ 'order_id' ] .' '. $item[ 'name' ] . '</strong></a>';

return $order_id;

Expand Down
4 changes: 3 additions & 1 deletion admin/class-wc-order-view-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function wc_order_view_menus() {

$hook = add_menu_page( 'WC Orders', 'WC Orders', 'products_admin', 'wc-order-view', array ( $this, 'wc_order_view_page') , 'dashicons-list-view', 55 );
$hook = add_submenu_page('wc-order-view', 'All Orders', 'All Orders', 'products_admin', 'wc-order-view', array( $this , 'wc_order_view_page' ));
add_submenu_page('wc-order-view', 'Order View - Settings', 'Settings', 'products_admin', 'wc-order-view-settings', array( $this , 'wc_order_view_settings_page' ));
add_submenu_page('wc-order-view', 'Order View - Settings', 'Settings', 'administrator', 'wc-order-view-settings', array( $this , 'wc_order_view_settings_page' ));

add_action( "load-$hook", array( $this, 'screen_option' ) );

Expand Down Expand Up @@ -169,6 +169,8 @@ public function wc_order_view_page() {

if( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == "view" ) {

$post = new WP_Post( $_GET[ 'order_id' ] );

$order = new WC_Order( $_GET[ 'order_id' ] );

$user = $order->get_user();
Expand Down
186 changes: 158 additions & 28 deletions admin/partials/wc-order-view-order-details-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,101 @@
/**
* Objects available in this context.
*
* @var WP_Post $post The wordpress post object of the woocommerce order in this context .
* @var WC_Order $order The woocommerce order object initialized with the current order id.
* @var WP_User $user The wordpress user object initialized with the user associated with the current order.
*/

defined( 'ABSPATH' ) || exit;

$billing_fields = apply_filters(
'woocommerce_admin_billing_fields', array(
'first_name' => array(
'label' => __( 'First name', 'woocommerce' ),
'show' => false,
),
'last_name' => array(
'label' => __( 'Last name', 'woocommerce' ),
'show' => false,
),
'company' => array(
'label' => __( 'Company', 'woocommerce' ),
'show' => false,
),
'address_1' => array(
'label' => __( 'Address line 1', 'woocommerce' ),
'show' => false,
),
'address_2' => array(
'label' => __( 'Address line 2', 'woocommerce' ),
'show' => false,
),
'city' => array(
'label' => __( 'City', 'woocommerce' ),
'show' => false,
),
'postcode' => array(
'label' => __( 'Postcode / ZIP', 'woocommerce' ),
'show' => false,
),
'country' => array(
'label' => __( 'Country', 'woocommerce' ),
'show' => false,
),
'state' => array(
'label' => __( 'State / County', 'woocommerce' ),
'show' => false,
),
'email' => array(
'label' => __( 'Email address', 'woocommerce' ),
),
'phone' => array(
'label' => __( 'Phone', 'woocommerce' ),
),
)
);

$shipping_fields = apply_filters(
'woocommerce_admin_shipping_fields', array(
'first_name' => array(
'label' => __( 'First name', 'woocommerce' ),
'show' => false,
),
'last_name' => array(
'label' => __( 'Last name', 'woocommerce' ),
'show' => false,
),
'company' => array(
'label' => __( 'Company', 'woocommerce' ),
'show' => false,
),
'address_1' => array(
'label' => __( 'Address line 1', 'woocommerce' ),
'show' => false,
),
'address_2' => array(
'label' => __( 'Address line 2', 'woocommerce' ),
'show' => false,
),
'city' => array(
'label' => __( 'City', 'woocommerce' ),
'show' => false,
),
'postcode' => array(
'label' => __( 'Postcode / ZIP', 'woocommerce' ),
'show' => false,
),
'country' => array(
'label' => __( 'Country', 'woocommerce' ),
'show' => false,
),
'state' => array(
'label' => __( 'State / County', 'woocommerce' ),
'show' => false,
),
)
);

if ( WC()->payment_gateways() ) {
$payment_gateways = WC()->payment_gateways->payment_gateways();
} else {
Expand All @@ -29,6 +118,8 @@

$payment_method = $order->get_payment_method();

$order_type_object = get_post_type_object( $post->post_type );

$payment_gateway = wc_get_payment_gateway_by_order( $order );
$line_items = $order->get_items( apply_filters( 'woocommerce_admin_order_item_types', 'line_item' ) );
$discounts = $order->get_items( 'discount' );
Expand Down Expand Up @@ -112,9 +203,10 @@
<h2 class="woocommerce-order-data__heading">
<h2 class="woocommerce-order-data__heading">
<?php
/* translators: 1: order number */
/* translators: 1: order type 2: order number */
printf(
esc_html__( 'Order #%1$s details', 'wc-order-view' ),
esc_html__( '%1$s #%2$s details', 'wc-order-view' ),
esc_html( $order_type_object->labels->singular_name ),
esc_html( $order->get_order_number() )
);
?>
Expand Down Expand Up @@ -156,15 +248,15 @@
</p>
<div class="order_data_column_container">
<div class="order_data_column">
<h3>General</h3>
<h3><?php esc_html_e( 'General', 'wc-order-view' ); ?></h3>
<p class="form-field form-field-wide">
<label for="order_date">Date Created:</label>
<input class="date-picker" type="text" name="order_date" maxlength="10" value="<?php echo $order->get_date_created()->format ('Y-m-d'); ?>" readonly /> @
<input class="hour" type="number" name="order_date_hour" min="0" max="23" step="1" value="<?php echo $order->get_date_created()->format ('H'); ?>" readonly /> :
<input class="minute" type="number" name="order_date_minute" min="0" max="59" step="1" value="<?php echo $order->get_date_created()->format ('i'); ?>" readonly />
<label for="order_date"><?php _e( 'Date created:', 'wc-order-view' ); ?></label>
<input class="date-picker" type="text" name="order_date" maxlength="10" value="<?php echo esc_attr( date_i18n( 'Y-m-d', strtotime( $post->post_date ) ) ); ?>" readonly /> &lrm;
<input class="hour" type="number" name="order_date_hour" min="0" max="23" step="1" value="<?php echo esc_attr( date_i18n( 'H', strtotime( $post->post_date ) ) ); ?>" readonly /> :
<input class="minute" type="number" name="order_date_minute" min="0" max="59" step="1" value="<?php echo esc_attr( date_i18n( 'i', strtotime( $post->post_date ) ) ); ?>" readonly />
</p>
<p class="form-field form-field-wide wc-order-status">
<label for="order_status">Status:</label>
<label for="order_status"><?php _e( 'Status:', 'wc-order-view' ); ?></label>
<input class="" type="text" name="order_status" value="<?php echo ucfirst( $order->get_status() ); ?>" readonly />
</p>
<p class="form-field form-field-wide wc-customer-user">
Expand All @@ -174,34 +266,72 @@
</label>
<input class="" type="text" name="order_status" value="<?php echo $user->first_name . ' ' . $user->last_name . ' (#' . $user->ID . ' - ' . $user->user_email . ')' ?>" readonly />
</p>
<?php do_action( 'woocommerce_admin_order_data_after_order_details', $order ); ?>
</div>
<div class="order_data_column">
<h3>Billing</h3>
<h3><?php esc_html_e( 'Billing', 'wc-order-view' ); ?></h3>
<div class="address">
<?php if( ! empty( $order->get_formatted_billing_address() ) ) : ?>
<p><?php echo $order->get_formatted_billing_address(); ?></p>
<?php else : ?>
<p class="none_set"><strong>Address:</strong>No billing address set.</p>
<?php endif; ?>
<p>
<strong>Email Address:</strong>
<a href="mailto:<?php echo $order->get_billing_email(); ?>"><?php echo $order->get_billing_email(); ?></a>
</p>
<p>
<strong>Phone:</strong>
<a href="tel:<?php echo $order->get_billing_phone(); ?>"><?php echo $order->get_billing_phone(); ?></a>
</p>
<?php
// Display values.
if ( $order->get_formatted_billing_address() ) {
echo '<p>' . wp_kses( $order->get_formatted_billing_address(), array( 'br' => array() ) ) . '</p>';
} else {
echo '<p class="none_set"><strong>' . __( 'Address:', 'wc-order-view' ) . '</strong> ' . __( 'No billing address set.', 'wc-order-view' ) . '</p>';
}
foreach ( $billing_fields as $key => $field ) {
if ( isset( $field['show'] ) && false === $field['show'] ) {
continue;
}
$field_name = 'billing_' . $key;
if ( isset( $field['value'] ) ) {
$field_value = $field['value'];
} elseif ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field_value = $order->{"get_$field_name"}( 'edit' );
} else {
$field_value = $order->get_meta( '_' . $field_name );
}
if ( 'billing_phone' === $field_name ) {
$field_value = wc_make_phone_clickable( $field_value );
} else {
$field_value = make_clickable( esc_html( $field_value ) );
}
if ( $field_value ) {
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>';
}
}
?>
</div>
<?php do_action( 'woocommerce_admin_order_data_after_billing_address', $order ); ?>
</div>
<div class="order_data_column">
<h3>Shipping</h3>
<h3><?php esc_html_e( 'Shipping', 'wc-order-view' ); ?></h3>
<div class="address">
<?php if( ! empty( $order->get_formatted_shipping_address() ) ) : ?>
<p><?php echo $order->get_formatted_shipping_address(); ?></p>
<?php else : ?>
<p class="none_set"><strong>Address:</strong>No shipping address set.</p>
<?php endif; ?>
<?php
// Display values.
if ( $order->get_formatted_shipping_address() ) {
echo '<p>' . wp_kses( $order->get_formatted_shipping_address(), array( 'br' => array() ) ) . '</p>';
} else {
echo '<p class="none_set"><strong>' . __( 'Address:', 'wc-order-view' ) . '</strong> ' . __( 'No shipping address set.', 'wc-order-view' ) . '</p>';
}
if ( ! empty( $shipping_fields ) ) {
foreach ( $shipping_fields as $key => $field ) {
if ( isset( $field['show'] ) && false === $field['show'] ) {
continue;
}
$field_name = 'shipping_' . $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field_value = $order->{"get_$field_name"}( 'edit' );
} else {
$field_value = $order->get_meta( '_' . $field_name );
}
if ( $field_value ) {
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>';
}
}
}
?>
</div>
<?php do_action( 'woocommerce_admin_order_data_after_shipping_address', $order ); ?>
</div>
</div>
<div class="clear"></div>
Expand Down

0 comments on commit 074316d

Please sign in to comment.