admin updates

This commit is contained in:
Mike Jolley 2016-11-18 19:56:17 +00:00
parent b1565cf0d6
commit b81bde4f5a
7 changed files with 25 additions and 39 deletions

View File

@ -50,7 +50,7 @@ class WC_Meta_Box_Order_Actions {
if ( ! empty( $mails ) ) {
foreach ( $mails as $mail ) {
if ( in_array( $mail->id, $available_emails ) && 'no' !== $mail->enabled ) {
echo '<option value="send_email_' . esc_attr( $mail->id ) . '">' . esc_html( $mail->title ) . '</option>';
echo '<option value="send_email_' . esc_attr( $mail->id ) . '">' . sprintf( __( 'Resend %s', 'woocomerce' ), esc_html( $mail->title ) ) . '</option>';
}
}
}

View File

@ -153,7 +153,7 @@ class WC_Meta_Box_Order_Data {
$payment_gateways = array();
}
$payment_method = $order->get_payment_method() ? $order->get_payment_method() : '';
$payment_method = $order->get_payment_method();
$order_type_object = get_post_type_object( $post->post_type );
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
@ -228,18 +228,18 @@ class WC_Meta_Box_Order_Data {
<?php
$statuses = wc_get_order_statuses();
foreach ( $statuses as $status => $status_name ) {
echo '<option value="' . esc_attr( $status ) . '" ' . selected( $status, 'wc-' . $order->get_status(), false ) . '>' . esc_html( $status_name ) . '</option>';
echo '<option value="' . esc_attr( $status ) . '" ' . selected( $status, 'wc-' . $order->get_status( 'edit' ), false ) . '>' . esc_html( $status_name ) . '</option>';
}
?>
</select></p>
<p class="form-field form-field-wide wc-customer-user">
<label for="customer_user"><?php _e( 'Customer:', 'woocommerce' ) ?> <?php
if ( $order->get_user_id() ) {
if ( $order->get_user_id( 'edit' ) ) {
$args = array(
'post_status' => 'all',
'post_type' => 'shop_order',
'_customer_user' => absint( $order->get_user_id() ),
'_customer_user' => $order->get_user_id( 'edit' ),
);
printf( '<a href="%s">%s</a>',
esc_url( add_query_arg( $args, admin_url( 'edit.php' ) ) ),
@ -290,7 +290,7 @@ class WC_Meta_Box_Order_Data {
$field_name = 'billing_' . $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . make_clickable( esc_html( call_user_func( array( $order, 'get_' . $field_name ) ) ) ) . '</p>';
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . make_clickable( esc_html( $order->{"get_$field_name"}( 'edit' ) ) ) . '</p>';
}
}
@ -376,7 +376,7 @@ class WC_Meta_Box_Order_Data {
$field_name = 'shipping_' . $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . make_clickable( esc_html( call_user_func( array( $order, 'get_' . $field_name ) ) ) ) . '</p>';
echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . make_clickable( esc_html( $order->{"get_$field_name"}( 'edit' ) ) ) . '</p>';
}
}
}

View File

@ -81,21 +81,17 @@ class WC_Meta_Box_Order_Downloads {
* @param WP_Post $post
*/
public static function save( $post_id, $post ) {
global $wpdb;
if ( isset( $_POST['download_id'] ) ) {
$download_ids = $_POST['download_id'];
$product_ids = $_POST['product_id'];
if ( isset( $_POST['permission_id'] ) ) {
$permission_ids = $_POST['permission_id'];
$downloads_remaining = $_POST['downloads_remaining'];
$access_expires = $_POST['access_expires'];
$product_ids_max = max( array_keys( $product_ids ) );
$data_store = WC_Data_Store::load( 'customer-download' );
$max = max( array_keys( $permission_ids ) );
for ( $i = 0; $i <= $product_ids_max; $i ++ ) {
if ( ! isset( $product_ids[ $i ] ) ) {
for ( $i = 0; $i <= $max; $i ++ ) {
if ( ! isset( $permission_ids[ $i ] ) ) {
continue;
}
$download = $data_store::get_download_from_order( $post_id, absint( $product_ids[ $i ] ), $download_ids[ $i ] );
$download = new WC_Customer_Download( $permission_ids[ $i ] );
$download->set_downloads_remaining( wc_clean( $downloads_remaining[ $i ] ) );
$download->set_access_expires( array_key_exists( $i, $access_expires ) && '' !== $access_expires[ $i ] ? strtotime( $access_expires[ $i ] ) : '' );
$download->save();

View File

@ -17,8 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<tr>
<td>
<label><?php _e( 'Downloads remaining', 'woocommerce' ); ?></label>
<input type="hidden" name="product_id[<?php echo $loop; ?>]" value="<?php echo esc_attr( $download->get_product_id() ); ?>" />
<input type="hidden" name="download_id[<?php echo $loop; ?>]" value="<?php echo esc_attr( $download->get_product_id() ); ?>" />
<input type="hidden" name="permission_id[<?php echo $loop; ?>]" value="<?php echo esc_attr( $download->get_id() ); ?>" />
<input type="number" step="1" min="0" class="short" name="downloads_remaining[<?php echo $loop; ?>]" value="<?php echo esc_attr( $download->get_downloads_remaining() ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'woocommerce' ); ?>" />
</td>
<td>

View File

@ -171,7 +171,7 @@ if ( wc_tax_enabled() ) {
<td class="total">
<div class="view"><?php echo $order->get_formatted_order_total(); ?></div>
<div class="edit" style="display: none;">
<input type="text" class="wc_input_price" id="_order_total" name="_order_total" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $order->get_total( true ) ) ); ?>" />
<input type="text" class="wc_input_price" id="_order_total" name="_order_total" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $order->get_total( 'edit' ) ) ); ?>" />
<div class="clear"></div>
</div>
</td>

View File

@ -176,7 +176,7 @@ class WC_Order_Item_Product extends WC_Order_Item {
}
/**
* Get any associated downloadable files.
* Get any associated downloadable files. @todo
* @return array
*/
public function get_item_downloads() {
@ -190,7 +190,7 @@ class WC_Order_Item_Product extends WC_Order_Item {
$data_store = WC_Data_Store::load( 'customer-download' );
$download_ids = $data_store->get_downloads( array(
'user_email' => $order->get_billing_email(),
'order_key' => $order->get_order_key(),
'order_id' => $order->get_id(),
'product_id' => $this->get_variation_id() ? $this->get_variation_id() : $this->get_product_id(),
'return' => 'ids',
) );

View File

@ -112,7 +112,14 @@ class WC_Customer_Download_Data_Store implements WC_Customer_Download_Data_Store
'%s',
);
$wpdb->update( $wpdb->prefix . 'woocommerce_downloadable_product_permissions', $data, $format );
$wpdb->update(
$wpdb->prefix . 'woocommerce_downloadable_product_permissions',
$data,
array(
'permission_id' => $download->get_id(),
),
$format
);
$download->apply_changes();
}
@ -182,22 +189,6 @@ class WC_Customer_Download_Data_Store implements WC_Customer_Download_Data_Store
return new WC_Customer_Download( $data );
}
/**
* Get a download object from an order.
*
* @param int $order_id
* @param int $product_id
* @param string $download_id
* @return WC_Customer_Download
*/
private function get_download_from_order( $order_id, $product_id, $download_id ) {
global $wpdb;
$raw_download = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = %d AND product_id = %d AND download_id = %s", $order_id, $product_id, $download_id ) );
return $raw_download ? new WC_Customer_Download( $raw_download ) : false;
}
/**
* Get array of download ids by specified args.
*