Skip to content

Commit

Permalink
WPML support for conditional product categories for checkboxes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed Jan 9, 2025
1 parent 417996c commit fe1b654
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion includes/class-wc-gzd-legal-checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public function set_supporting_locations( $locations ) {
* @return array
*/
public function get_show_for_categories() {
return $this->settings['show_for_categories'];
return apply_filters( 'woocommerce_gzd_legal_checkbox_show_for_categories', $this->settings['show_for_categories'], $this );
}

public function set_show_for_categories( $category_ids ) {
Expand Down
15 changes: 15 additions & 0 deletions includes/compatibility/class-wc-gzd-compatibility-wpml.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ public function load() {
add_filter( 'wcml_emails_options_to_translate', array( $this, 'register_email_options' ), 10, 1 );
add_filter( 'wcml_emails_section_name_prefix', array( $this, 'filter_email_section_prefix' ), 10, 2 );

// Translate product category condition for checkboxes
add_filter(
'woocommerce_gzd_legal_checkbox_show_for_categories',
function ( $product_categories ) {
$product_categories = array_map(
function ( $product_category ) {
return apply_filters( 'wpml_object_id', $product_category, 'category' );
},
(array) $product_categories
);

return $product_categories;
}
);

$this->filter_page_ids();

/**
Expand Down

0 comments on commit fe1b654

Please sign in to comment.