Last active
August 18, 2023 13:31
-
-
Save kartikparmar/bc1e6132bf195a5e1aeb5332458f5aa0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function bkap_show_hide_persons_based_on_date( $data ) { | |
$persons_to_hide = array( | |
'84217' => array( // 84217 is product id | |
array( | |
'dates' => '2023-06-25,2023-06-22', // in Y-m-d format. | |
'person_ids' => array( 84226, 84227 ), // 84226, 84227 are persons ids to hide | |
), | |
array( | |
'dates' => '2023-06-27,2023-06-30', // in Y-m-d format. | |
'person_ids' => array( 84224, 84225 ), // 84224, 84225 are persons id to hide | |
), | |
), | |
'84218' => array( // 84218 is another new product id. This is main array. | |
array( // array 1. | |
'dates' => '2023-06-28,2023-06-22', | |
'person_ids' => array( 84226, 84227 ), | |
), | |
array( // array 2. | |
'dates' => '2023-06-30,2023-06-29', | |
'person_ids' => array( 84224, 84225 ), | |
), | |
), | |
'12345' => array( // 12345 is another new product id | |
array( | |
'dates' => '2023-06-25,2023-06-22', | |
'person_ids' => array( 84226, 84227 ), | |
), | |
array( | |
'dates' => '2023-06-27,2023-06-30', | |
'person_ids' => array( 84224, 84225 ), | |
), | |
), | |
); | |
$product_id = get_the_ID(); | |
if ( isset( $persons_to_hide[ $product_id ] ) ) { | |
$data['persons_to_hide'] = $persons_to_hide[ $product_id ]; | |
} | |
return $data; | |
} | |
add_filter( 'bkap_init_parameter_localize_script_additional_data', 'bkap_show_hide_persons_based_on_date', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment