Skip to content

Commit

Permalink
fix POS visibility quick edit
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbot committed May 23, 2024
1 parent 39911fb commit 3d453b0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
17 changes: 16 additions & 1 deletion includes/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
namespace WCPOS\WooCommercePOS;

use WCPOS\WooCommercePOS\Admin\Products\Single_Product;
use WCPOS\WooCommercePOS\Admin\Products\List_Products;
use WCPOS\WooCommercePOS\Admin\Updaters\Pro_Plugin_Updater;

/**
*
*/
class AJAX {
/**
* WooCommerce AJAX actions that we need to hook into on the Product admin pages.
Expand All @@ -22,7 +26,7 @@ class AJAX {
* @var string[]
*/
private $list_products_actions = array(
// 'inline-save', // this is a core WordPress action and it won't call our hook
'inline_save', // this is a core WordPress action and it won't call our hooks?? I don't know why.
);

/**
Expand Down Expand Up @@ -73,6 +77,17 @@ public function __construct() {
'quick_edit_save',
)
);

/**
* @TODO - I need to fix this AJAX mess.
* When a quick edit is saved, WooCommerce returns a re-rendered row to replace the existing row.
* Because it's via AJAX, our 'manage_product_posts_custom_column' hook won't run, so it won't include our updated value.
*
* I have loaded the List_Products class here for the wp_ajax_inline_save hook .
*/
if ( 'inline-save' === $_REQUEST['action'] ) {
new List_Products();
}
}

/**
Expand Down
17 changes: 11 additions & 6 deletions includes/Admin/Products/templates/quick-edit-visibility-select.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</div>
</div>
<script>
(function () {
document.addEventListener('DOMContentLoaded', function() {
// we create a copy of the WP inline edit post function
const wp_inline_edit = window.inlineEditPost.edit;

Expand All @@ -46,14 +46,19 @@
const edit_row = document.getElementById('edit-' + post_id);

// get the data
const val = document.getElementById('woocommerce_pos_inline_' + post_id).dataset.visibility;
let val = '';
let elem = document.getElementById('woocommerce_pos_inline_' + post_id);
if (elem) {
val = elem.dataset.visibility;
}

// populate the data
const select = edit_row.querySelector('select[name="_pos_visibility"]');
select.value = val;
if (select) {
select.value = val;
}
}
}
})();
};
});
</script>
</fieldset>

2 changes: 1 addition & 1 deletion includes/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function payment_complete_order_status( string $status, int $id, WC_Abstr
* @return array
*/
public function hidden_order_itemmeta( array $meta_keys ): array {
return array_merge( $meta_keys, array( '_woocommerce_pos_uuid', '_woocommerce_pos_tax_status' ) );
return array_merge( $meta_keys, array( '_woocommerce_pos_uuid', '_woocommerce_pos_tax_status', '_woocommerce_pos_data' ) );
}

/**
Expand Down

0 comments on commit 3d453b0

Please sign in to comment.