Hi I need to customise the script below so that the site can take orders between 11am to 12am (asia/kuala lumpur). It should be only applicable to checkout page (it disables it) outside the operation time.
Script: // Custom conditional function that checks for parent product categories from a product category slug function has_parent_term( $product_id, $category_slug ) {
// Convert category term slug to term id $category_id = get_term_by('slug', $category_slug, 'product_cat')->term_id; $parent_term_ids = array(); // Initializing
// Loop through the current product category terms to get only parent main category term foreach( get_the_terms( $product_id, 'product_cat' ) as $term ){ if( $term->parent > 0 ){ $parent_term_ids[] = $term->parent; // Set the parent product category $parent_term_ids[] = $term->term_id; // (and the child) } else { $parent_term_ids[] = $term->term_id; } } return in_array( $category_id, array_unique($parent_term_ids) ); }
// Custom conditional function that checks from a time range function is_on_time( $start_time, $end_time, $time_zone = 'UTC' ) { // Set the default time zone (http://php.net/manual/en/timezones.php) date_default_timezone_set($time_zone);
return ( $start >= $now && $end get_cart() as $cart_item ) { // Check for product category term and parent term if ( has_parent_term( $cart_item['product_id'], 't-shirts' ) ) $found = true; // category is found }
// Checking product category and time if ( $found && ! is_on_time( '6:00', '23:59', 'Europe/Paris' ) ){ // Avoiding checkout displaying a custom error notice wc_add_notice( __("Sorry too late, time is now off. You are not allowed to checkout", "woocommerce" ), 'error' ); } }
Crypto Promotion/Marketing Expert Category: Cryptocurrency, Digital Marketing, Facebook Marketing, Internet Marketing, Social Media Marketing Budget: $15 - $25 USD