Created
April 3, 2025 06:04
-
-
Save pramodjodhani/8d1ccef03ec82001d17cbc3b32e761da to your computer and use it in GitHub Desktop.
Iconic WDS - Modify the max dates setting for a specific product.
This file contains hidden or 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 | |
/** | |
* Iconic WDS - Modify the max dates setting for a specific product. | |
*/ | |
iconic_wds_modify_wds_max_dates_setting(); | |
add_action('wp_loaded', 'iconic_wds_modify_wds_max_dates_setting', 11); | |
function iconic_wds_modify_wds_max_dates_setting() { | |
global $iconic_wds; | |
if ( ! isset( $iconic_wds ) ) { | |
return; | |
} | |
// Todo - modify these values with yours. | |
$disable_product_id = 10; | |
$max_days = 5; | |
// Check if WooCommerce is active and cart is available | |
if (!function_exists('WC') || is_null(WC()->cart)) { | |
return; | |
} | |
// Check if product ID 10 is in cart | |
$has_product = false; | |
foreach (WC()->cart->get_cart() as $cart_item) { | |
$product = $cart_item['data']; | |
$product_id = $product->get_parent_id() ? $product->get_parent_id() : $product->get_id(); | |
// Check both product_id and variation_id (for variable products) | |
if ($product_id == $disable_product_id) { | |
$has_product = true; | |
break; | |
} | |
} | |
// Update the setting if product is found | |
if ($has_product && isset($iconic_wds->settings)) { | |
$iconic_wds->settings['datesettings_datesettings_maximum'] = $max_days; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment