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