Ask your WordPress questions! Pay money and get answers fast! (more info)

old WordPress

  • REFUNDED

old

Answers (1)

2012-12-02

John Cotton answers:

hi

I don't use cart66 so I don't know anything about it's structure or how it uses meta data.

However, since it clearly uses non-wp tables (eg wp_cart66_products) I would be surprised if many plugins worked with it since they won't know about those extra tables.

So the easiest way to solve this will almost certainly be to modify the file SQL that wp_query uses to ORDER/FILTER as necessary.

Since I don't know the table structure, I can't tell you what the SQL should be, but here's the code structure:



function oomskaap_price_range_limiter( $query ) {
if ( empty( $_GET['pricestart'] ) || empty( $_GET['priceend'] ) ) {
add_action( 'posts_where', 'oomskaap_price_range_limiter_where' );
add_action( 'posts_orderby', 'oomskaap_price_range_limiter_orderby' );
}
}
add_action( 'pre_get_posts', 'oomskaap_price_range_limiter' );

function oomskaap_price_range_limiter_where( $query ) {
// return some SQL to affect the where clause
}

function oomskaap_price_range_limiter_orderby( $query ) {
// return some SQL to affect the order by clause
}




By using the above, you can modify/append the SQL to the tables/rows/values you want. I would start by output the current SQL and then looking at how it needs changing. Post it here if you wish and I might be able to comment further.