LookupFilters.php
1 week ago
LookupFiltersFactory.php
1 week ago
LookupTable.php
1 week ago
LookupTableFactory.php
1 week ago
LookupFilters.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\Attributes; |
| 4 | |
| 5 | class LookupFilters implements \IWPML_Action { |
| 6 | |
| 7 | private $sitepress; |
| 8 | |
| 9 | private $wpdb; |
| 10 | |
| 11 | public function __construct( \SitePress $sitepress, \wpdb $wpdb ) { |
| 12 | $this->sitepress = $sitepress; |
| 13 | $this->wpdb = $wpdb; |
| 14 | } |
| 15 | |
| 16 | public function add_hooks() { |
| 17 | add_filter( 'woocommerce_get_filtered_term_product_counts_query', [ $this, 'adjustAttributeWidgetCount' ] ); |
| 18 | } |
| 19 | |
| 20 | public function adjustAttributeWidgetCount( $query ) { |
| 21 | |
| 22 | $query['join'] .= " INNER JOIN {$this->wpdb->prefix}icl_translations AS icl_t ON {$this->wpdb->posts}.ID = icl_t.element_id |
| 23 | AND icl_t.element_type = 'post_product'"; |
| 24 | |
| 25 | $query['where'] .= $this->wpdb->prepare(" AND icl_t.language_code = %s", $this->sitepress->get_current_language() ); |
| 26 | |
| 27 | return $query; |
| 28 | } |
| 29 | } |
| 30 |