Open axi opened 1 month ago
My quickfix right before the closing of the WC_Accommodation_Booking_Admin_Panels::save_product_data()
method
// Quick Fix
$wpdb->update(
$wpdb->prefix . 'wc_product_meta_lookup',
[
'min_price' => $product->get_base_cost(),
'max_price' => $product->get_base_cost(),
],
[
'product_id' => $post_id,
],
'%d'
);
What I expected
I expect the orderby=price-asc order by to be working correctly
What happened instead
Values saved in lookup_table are wrong, resulting order is wrong
Steps to reproduce the issue
Note: It looks like this happen only after an "update", not on creation.
Create an accommodation product with the following:
Create another accommodation product with the following:
When using sorting by price asc, we want the cheapest first (Product1) but we have Product2 first. This is because lookup_table gets a calculated value that take the min number of nights into account...
Check the following query
WC_Accommodation_Booking_Admin_Panels::save_product_data() tries to solve that l424:
but at that time, price is already set in lookup table.