не можете поправить?
LEFT JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id)
и AND wp_term_relationships.term_taxonomy_id IN (83,85) )
в проверке WHERE , так как это запрос стороннего плагина фильтра и в нем формируется список таксономий. Я лишь хочу этот запрос дополнить своей таблицей, где добавляю к фильтру minPrice и maxPrice. SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
LEFT JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id)
WHERE 1=1
AND wp_posts.ID NOT IN (25220)
AND ( wp_posts.ID NOT IN (
SELECT object_id
FROM wp_term_relationships
WHERE term_taxonomy_id IN (0) )
AND wp_term_relationships.term_taxonomy_id IN (83,85) )
AND wp_posts.post_type = 'product'
AND (wp_posts.post_status = 'publish'
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_name ASC
LIMIT 0, 20
SELECT
wp_posts.ID,
wp_posts.post_title,
(wpml.min_price * coalesce(t2.meta_value*80, t3.meta_value*80,1)) minPrice,
(wpml.max_price * coalesce(t2.meta_value*80, t3.meta_value*80,1)) maxPrice
FROM
wp_posts
JOIN wp_wc_product_meta_lookup wpml ON (wp_posts.ID = wpml.product_id)
JOIN wp_term_relationships tr ON (wp_posts.ID = tr.object_id AND tr.term_taxonomy_id IN ( 83, 85 ) )
LEFT JOIN wp_postmeta as t2 ON (tr.object_id = t2.post_id
AND t2.meta_key = 'convert_to_rub'
AND t2.meta_value = 1)
LEFT JOIN wp_termmeta as t3 ON (tr.term_taxonomy_id = t3.term_id
AND t3.meta_key = 'convert_to_rub'
AND t3.meta_value = 1)
WHERE
1 = 1
AND wp_posts.post_type = 'product'
AND minPrice > 0
--GROUP BY wp_posts.ID
ORDER BY wp_posts.post_name ASC
ID | post_title | ...
----------------------
10| H5030001 |
11| Y1001002 |
30| H5030005 |
object_id | term_taxonomy_id
-----------------------------------
10 | 3
11 | 2
30 | 3
term_taxonomy_id = 2 это например Обои бумажные,
term_taxonomy_id = 3 это например Обои флизелиновые
product_id | min_price | max_price | ...
---------------------------------------------
10 | 30 | 35 |
11 | 5 | 5 |
30 | 15000 | 20000. |
post_id | meta_key | meta_value |
---------------------------------------------
10 | convert_to_rub | 1 |
30 | convert_to_rub | 0 |
* Товар H5030001 надо конвертировать по курсу
term_id | meta_key | meta_value |
---------------------------------------------
2 | convert_to_rub | 1 |
* Категорию Обои бумажные надо конвертировать по курсу
function relatedNavUpdate(el = null) {
const relatedList = el ? [el] : main.querySelectorAll('.products-wrapper');
relatedList.forEach( (e) => {
var ul = e.querySelector('ul.products'),
leftArrow = e.querySelector(".arrow-left"),
rightArrow = e.querySelector(".arrow-right");
if ( ul && ul.scrollLeft < 10 )
leftArrow.classList.contains('visible') && leftArrow.classList.remove('visible');
else
!leftArrow.classList.contains('visible') && leftArrow.classList.add('visible');
if ( ul && ul.scrollWidth - ul.scrollLeft - ul.clientWidth < 10 )
rightArrow.classList.contains('visible') && rightArrow.classList.remove('visible');
else
!rightArrow.classList.contains('visible') && rightArrow.classList.add('visible');
});
}