Support

Account

Forum Replies Created

  • This line:

    add_action(‘acf/save_post’, ‘yl_send_review_email_function’, 5);

    I added later on. I know it’s not gonna work because it has to de triggered bij Cron Job but I was just testing/trying everything to see what happens.

  • I have created a code to auto send booking emails after a booking status is updated. Depending on the booking status, a certain e-mail text is called. This function works perfectly so feel free to use it 😉

    // Send notification emails to guests
    function yl_send_booking_email_after_status_update($post_id) {

    // Get submitted values.
    $values = $_POST[‘acf’];

    // Check if a specific value was updated.
    if ( isset($_POST[‘acf’][‘field_5fbcef66c1d3f’]) ) {

    $send_email = $_POST[‘acf’][‘field_5fbcef66c1dce’];
    $booking_status = $_POST[‘acf’][‘field_5fbcef66c1d3f’];

    $to = $_POST[‘acf’][‘field_5fbcef66c18b8’];

    if ( $send_email == ‘yes’ && $booking_status != ‘gesloten’ ) {

    if ( $booking_status == ‘bevestigd’ ) {
    $subject = get_field(‘booking_email_subject_confirmed’, ‘booking_settings’);
    $message = get_field(‘booking_email_message_confirmed’, ‘booking_settings’);
    } elseif ( $booking_status == ‘gewijzigd’ ) {
    $subject = get_field(‘booking_email_subject_changed’, ‘booking_settings’);
    $message = get_field(‘booking_email_message_changed’, ‘booking_settings’);
    } elseif ( $booking_status == ‘geannuleerd’ ) {
    $subject = get_field(‘booking_email_subject_canceled_by_guest’, ‘booking_settings’);
    $message = get_field(‘booking_email_message_canceled_by_guest’, ‘booking_settings’);
    } elseif ( $booking_status == ‘door ons geannuleerd’ ) {
    $subject = get_field(‘booking_email_subject_canceled_by_us’, ‘booking_settings’);
    $message = get_field(‘booking_email_message_canceled_by_us’, ‘booking_settings’);
    }

    $headers = array
    (
    ‘From: ‘ . get_bloginfo(‘name’) . ‘ <‘ . get_bloginfo(‘admin_email’) . ‘>’,
    ‘X-Mailer: PHP/’ . phpversion(),
    ‘MIME-Version: 1.0’,
    ‘Content-type: text/html; charset=iso-8859-1’
    );
    $headers = implode( “\r\n” , $headers );

    wp_mail( $to, $subject, $message, $headers );

    }

    }

    }

    add_action(‘acf/save_post’, ‘yl_send_booking_email_after_status_update’, 5);

    Now I want to chanllange myself a bit further. I want to auto send (via cron job) a ‘Review request’ email ‘X hours’ after the booking date/time. But I’m stuck for a while now.

    Emails do get send but only with pre text. The actuall content of the booking (name, date, time, etc) is left blank.

    When I use $post_id in the function, no emails are being send. I hope I made myself a bit clear.

    Here’s what I have:

    // Send review emails to guests
    function yl_send_review_email_function($post_id) {

    // Get submitted values.
    $values = $_POST[‘acf’];

    $send_email = $_POST[‘acf’][‘field_5fbcef66c1dce’];
    $booking_status = $_POST[‘acf’][‘field_5fbcef66c1d3f’];
    $review_delay = get_field(‘booking_settings_review_delay’, ‘booking_settings’);

    $to = ‘[email protected]’;

    $subject = get_field(‘booking_email_subject_review’, ‘booking_settings’);
    $message = get_field(‘booking_email_message_review’, ‘booking_settings’) . ‘<br /><br />’ . $send_email . ‘<br /><br />’ . $booking_status . ‘ dit no ‘ . $review_delay;

    $headers = array
    (
    ‘From: ‘ . get_bloginfo(‘name’) . ‘ <‘ . get_bloginfo(‘admin_email’) . ‘>’,
    ‘X-Mailer: PHP/’ . phpversion(),
    ‘MIME-Version: 1.0’,
    ‘Content-type: text/html; charset=iso-8859-1’
    );
    $headers = implode( “\r\n” , $headers );

    wp_mail( $to, $subject, $message, $headers );

    $status = ‘gesloten’;
    update_field( ‘booking_status’, $status );

    }

    add_action(‘acf/save_post’, ‘yl_send_review_email_function’, 5);

    // Time schedule for Cron Job Event
    function yl_cron_schedules($schedules){
    if(!isset($schedules[“1min”])){
    $schedules[“1min”] = array(
    ‘interval’ => 1*60,
    ‘display’ => __(‘Once every minute’)
    );
    }
    if(!isset($schedules[“5min”])){
    $schedules[“5min”] = array(
    ‘interval’ => 5*60,
    ‘display’ => __(‘Once every 5 minutes’)
    );
    }
    if(!isset($schedules[“30min”])){
    $schedules[“30min”] = array(
    ‘interval’ => 30*60,
    ‘display’ => __(‘Once every 30 minutes’)
    );
    }
    return $schedules;
    }

    add_filter(‘cron_schedules’,’yl_cron_schedules’);

    // Schedule Cron Job Event
    if (!wp_next_scheduled(‘yl_booking_review_mailer’)) {
    //You can now use ‘5min’, ’20min’ or any of the default here
    wp_schedule_event( time(), ‘1min’, ‘yl_booking_review_mailer’ );
    }

    add_action( ‘yl_booking_review_mailer’, ‘yl_send_review_email_function’ );

    PS. I left the needed IF STATEMENTS out to be sure that’s nog stopping emails going out.

  • Nobody?

    I use the WordPress Cusomizer and I’m using a shortcode to collect te data.

    [yl_product_relations]

  • I removed ->ID and that was a step in the right direction. I now do see the relations but STILL ONLY from the LATEST PRODUCT (see screeny 2).

    Current view

  • I was missing this line:

    $exception_date = getDate($exception_dates);

    As it turned out, the exceptions weren’t real dates after all.

  • Close this topic…. irrelevant after investigation.

  • Thanks for explaining John,

    I thought it had to be something like that…

    I am going for a different approach then.

  • 
    add_filter( 'woocommerce_product_get_price', 'yl_get_dish_price', 20, 2 );
    add_filter( 'woocommerce_product_get_regular_price', 'yl_get_dish_price', 20, 2 );
    function yl_get_dish_price( $price, $product ) {
        if ( $product->is_type('dish') ) {
            $price = get_field( 'price', $product->get_id() );
        }
        return $price;
    }
    
  • The following code adds the CPT (dish in my case) to the WooCommerce cart but the price is incorrect. It always displays € 10,00

    
    class YL_Dish_Product extends WC_Product  {
    
        protected $post_type = 'dish';
    
        public function get_type() {
            return 'dish';
        }
    
        public function __construct( $product = 0 ) {
            $this->supports[]   = 'ajax_add_to_cart';
    
            parent::__construct( $product );
    
        }
        // maybe overwrite other functions from WC_Product
    
    }
    
    class YL_Data_Store_CPT extends WC_Product_Data_Store_CPT {
    
        public function read( &$product ) { // this is required
            $product->set_defaults();
            $post_object = get_post( $product->get_id() );
    
            if ( ! $product->get_id() || ! $post_object || 'dish' !== $post_object->post_type ) {
    
                throw new Exception( __( 'Invalid product.', 'woocommerce' ) );
            }
    
            $product->set_props(
                array(
                    'name'              => $post_object->post_title,
                    'slug'              => $post_object->post_name,
                    'date_created'      => 0 < $post_object->post_date_gmt ? wc_string_to_timestamp( $post_object->post_date_gmt ) : null,
                    'date_modified'     => 0 < $post_object->post_modified_gmt ? wc_string_to_timestamp( $post_object->post_modified_gmt ) : null,
                    'status'            => $post_object->post_status,
                    'description'       => $post_object->post_content,
                    'short_description' => $post_object->post_excerpt,
                    'parent_id'         => $post_object->post_parent,
                    'menu_order'        => $post_object->menu_order,
                    'reviews_allowed'   => 'open' === $post_object->comment_status,
                )
            );
    
            $this->read_attributes( $product );
            $this->read_downloads( $product );
            $this->read_visibility( $product );
            $this->read_product_data( $product );
            $this->read_extra_data( $product );
            $product->set_object_read( true );
        }
    
        // maybe overwrite other functions from WC_Product_Data_Store_CPT
    
    }
    
    class YL_WC_Order_Item_Product extends WC_Order_Item_Product {
        public function set_product_id( $value ) {
            if ( $value > 0 && 'dish' !== get_post_type( absint( $value ) ) ) {
                $this->error( 'order_item_product_invalid_product_id', __( 'Invalid product ID', 'woocommerce' ) );
            }
            $this->set_prop( 'product_id', absint( $value ) );
        }
    
    }
    
    function YL_woocommerce_data_stores( $stores ) {
        // the search is made for product-$post_type so note the required 'product-' in key name
        $stores['product-dish'] = 'YL_Data_Store_CPT';
        return $stores;
    }
    add_filter( 'woocommerce_data_stores', 'YL_woocommerce_data_stores' , 11, 1 );
    
    function YL_woo_product_class( $class_name ,  $product_type ,  $product_id ) {
        if ($product_type == 'dish')
            $class_name = 'YL_Dish_Product';
        return $class_name; 
    }
    add_filter('woocommerce_product_class','YL_woo_product_class',25,3 );
    
    function my_woocommerce_product_get_price( $price, $product ) {
    
        if ($product->get_type() == 'dish' ) {
            $price = 10;  // or get price how ever you see fit     
        }
        return $price;
    }
    add_filter('woocommerce_get_price','my_woocommerce_product_get_price',20,2);
    add_filter('woocommerce_product_get_price', 'my_woocommerce_product_get_price', 10, 2 );
    
    // required function for allowing posty_type to be added; maybe not the best but it works
    function YL_woo_product_type($false,$product_id) { 
        if ($false === false) { // don't know why, but this is how woo does it
            global $post;
            // maybe redo it someday?!
            if (is_object($post) && !empty($post)) { // post is set
                if ($post->post_type == 'dish' && $post->ID == $product_id) 
                    return 'dish';
                else {
                    $product = get_post( $product_id );
                    if (is_object($product) && !is_wp_error($product)) { // post not set but it's a dish
                        if ($product->post_type == 'dish') 
                            return 'dish';
                    } // end if 
                }    
    
            } else if(wp_doing_ajax()) { // has post set (usefull when adding using ajax)
                $product_post = get_post( $product_id );
                if ($product_post->post_type == 'dish') 
                    return 'dish';
            } else { 
                $product = get_post( $product_id );
                if (is_object($product) && !is_wp_error($product)) { // post not set but it's a dish
                    if ($product->post_type == 'dish') 
                        return 'dish';
                } // end if 
    
            } // end if  // end if 
    
        } // end if 
        return false;
    }
    add_filter('woocommerce_product_type_query','YL_woo_product_type',12,2 );
    
    function YL_woocommerce_checkout_create_order_line_item_object($item, $cart_item_key, $values, $order) {
    
        $product                    = $values['data'];
        if ($product->get_type() == 'dish') {
            return new YL_WC_Order_Item_Product();
        } // end if 
        return $item ;
    }   
    add_filter( 'woocommerce_checkout_create_order_line_item_object', 'YL_woocommerce_checkout_create_order_line_item_object', 20, 4 );
    
    function cod_woocommerce_checkout_create_order_line_item($item,$cart_item_key,$values,$order) {
        if ($values['data']->get_type() == 'dish') {
            $item->update_meta_data( '_dish', 'yes' ); // add a way to recognize custom post type in ordered items
            return;
        } // end if 
    
    }
    add_action( 'woocommerce_checkout_create_order_line_item', 'cod_woocommerce_checkout_create_order_line_item', 20, 4 );
    
    function YL_woocommerce_get_order_item_classname($classname, $item_type, $id) {
        global $wpdb;
        $is_IA = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id = {$id} AND meta_key = '_dish'");
    
        if ('yes' === $is_IA) { // load the new class if the item is our custom post
            $classname = 'YL_WC_Order_Item_Product';
        } // end if 
        return $classname;
    }
    add_filter( 'woocommerce_get_order_item_classname', 'YL_woocommerce_get_order_item_classname', 20, 3 );
    

    Any idea how to get the price field right? This doesn’t work:

    
    add_filter('woocommerce_get_price', 'yl_get_dish_price', 20,2);
    function yl_get_dish_price($price,$post) {
    	if ($post->post_type === 'dish') {
    		$price = get_field('price', $post->ID);
    	}
    	return $price;
    }
    
  • Tnx. I was a little afraid it would be done with javascript.

    I tried to figure out how (many times) with this tutorial:
    https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields

    I know how to call javascript to a field but I don’t know what code I should use to add it…

    Would it be something like this?

    
    // Customization to datepicker and timepicker
    function yl_add_label_class_to_acf_fields() {
    
    	?>
    	<script type="text/javascript">
    	(function($) {
    
    		// Check ACF
    		if(typeof acf === 'undefined')
    			return;
    		// Date picker & Google Maps compatibility
    		$('.acf-label').addClass('uk-form-label');
    
    	})(jQuery);	
    	</script>
    
    	<?php
    
    }
    
    add_action('acf/input/admin_footer', 'yl_add_label_class_to_acf_fields');
    
  • This also does not work:

    
    function my_acf_init() {
        acf_update_setting('remove_wp_meta_box', false);
    }
    
    add_action('acf/init', 'my_acf_init');
    
  • Anyone?

    I also tried to give it a priority like this:

    add_filter('acf/settings/remove_wp_meta_box', '__return_false', 20);

    But that also did not work 🙁

  • @pekka I’m trying to accomplish pretty much the same thing.

    I have a repeater field with 2 subfields (1 of them is a Post Object field) and I want to pre populate them when creating a new post.

    What was the complete code you used?

    PS. Do I need the code within ‘load-post-new.php’ too?

    tnx

  • Just to be clear…

    I know how to get all these values within a template file, simply because there I can use it like this:

    
            $measurement_client_object					        	= get_field_object('measurement_client');
            $measurement_client						    	        = get_field('measurement_client');
            $measurement_client_name                    	    	= get_the_title($measurement_client->ID);
            $measurement_client_street_and_number	               	= get_field('company_street_and_number', $measurement_client->ID);
            $measurement_client_postal_code			               	= get_field('company_postal_code', $measurement_client->ID);
            $measurement_client_city				              	= get_field('company_city', $measurement_client->ID);
            $measurement_client_phone_number		              	= get_field('company_phone_number', $measurement_client->ID);
            $measurement_client_website				             	= get_field('company_website', $measurement_client->ID);
            $measurement_client_email_addresses                     = get_field('company_email_addresses', $measurement_client->ID);
            $measurement_client_contacts			    	        = get_field('company_contacts', $measurement_client->ID);
            $measurement_client_locations			    	        = get_field('company_locations', $measurement_client->ID);
            $measurement_client_internal_note		    	        = get_field('company_internal_note', $measurement_client->ID);
    

    But within my function.php I can’t get the values like that and I believe I have to use $_POST[‘acf’].

    I call the code to send out WP emails.

    Here’s my code (option ‘basic’ is not working yet, option ‘extra’ does work, option ‘all’ is easily created when I have option ‘basic’ working):

    
    // Get submitted values.
    $values				= $_POST['acf'];
    $measurement_status	= $_POST['acf']['field_5e1475a714c93'];
    $measurement_mail	= $_POST['acf']['field_5f71d9ee8536c'];
    
    if ( $measurement_status == 'completed' && $measurement_mail ) {
    
        $measurement_mail_report_recipients = $_POST['acf']['field_5f6d7d925b2fc'];
    
        if ( $measurement_mail_report_recipients == 'basic' ) {
    
            $measurement_client_id					= intval($_POST['acf']['field_5e147914518a6']);
            $measurement_client						= $_POST['acf']['field_5e147914518a6'];
            $measurement_client_email_addresses		= $_POST['acf']['field_5e14527c1945b']->$measurement_client->$measurement_client_id;
    
            if ( $measurement_client_email_addresses ) {
                $list = array();
                foreach( $measurement_client_email_addresses as $measurement_client_email_address ) {
                    $list[] = $measurement_client_email_address['field_5e1452c41945c'];
                }
                $to = implode(',', $list);
            }
    
        } elseif ( $measurement_mail_report_recipients == 'extra' ) {
    
            $measurement_mail_extra_recipients = $_POST['acf']['field_5f71d4eaaf381'];
    
            if ( $measurement_mail_extra_recipients ) {
                $list = array();
                foreach( $measurement_mail_extra_recipients as $measurement_mail_extra_recipient ) {
                    $list[] = $measurement_mail_extra_recipient['field_5f71d55aaf382'];
                }
                $to = implode(',', $list);
            }
    
        } elseif ( $measurement_mail_report_recipients == 'all' ) {
    
            $to = '[email protected]';
    
        }
    
        // Get subject, message and header for mail and send
    
    }
    

    Within option ‘basic’ I want to retrieve email addresses from the CLIENT group and I don’t know how because these values are within another group 🙁

  • My English is not to bad but when I have to express myself technically it sometimes gets a little bit off. Let me try to make it clearer by explaining my situation.

    I have a group: CLIENT
    – Name field (Post title)
    – Address field (text)
    – Phone field (number)
    – Email addresses field (repeater)

    I have a group: MEASUREMENT
    – Client field (Post object from CLIENT group)
    – Measurement field (number)
    – Some other unimportant fields

    When I add a measurement post (and within that post I have selected the Client via the Post Object field) I want to be able to mail the measurement details to the email addresses from the Clients ‘Email addresses field (repeater)’ but that field is NOT in this Group but in the CLIENT group.

    I know how to get sub field values from a repeater field in the SAME GROUP but I don’t know how to get sub field values from a repeater field in ANOTHER GROUP (via a Post Object field) using $_POST[‘acf’].

    With get_field I know I can get the values like this:
    get_field('company_email_addresses', $measurement_client->ID);

    But how does this work with $_POST[‘acf’]?

  • Thanks for your reply.

    I guess I’m not getting it completely..? I tried this:

    
    $measurement_client_id = intval($_POST['acf']['field_5e147914518a6']);
    $measurement_client = get_post($measurement_client_id);
    $measurement_client_email_addresses = get_field('field_5e14527c1945b', $measurement_client_id);
    
    $measurement_client_id = intval($_POST['acf']['field_5e147914518a6']);
    $measurement_client = get_post($measurement_client_id);
    $measurement_client_email_addresses = get_field('field_5e14527c1945b', $measurement_client->ID);
    
    $measurement_client_id = intval($_POST['acf']['field_5e147914518a6']);
    $measurement_client = get_post($measurement_client_id);
    $measurement_client_email_addresses = get_field('company_email_addresses', $measurement_client_id);
    

    The CLIENT field is an Post Object field within the Measurement group and I want to mail the measurement report to the clients emailaddress (a repeater field within the Client group).

    My logic in above code examples is as follows:
    – I know the Client (Post Object field within the Measurement post)
    – I now know the Client Post ID
    – So I could get the email address repeater field within the Client post right?

    No luck. Am I missing something here?

    Tnx John

  • Here’s the code I was looking for:

    
    			$values	= $_POST['acf'];
    			$measurement_mail_extra_recipients = $_POST['acf']['field_5f71d4eaaf381'];
    
    			if ( $measurement_mail_extra_recipients ) {
    				$list = array();
    				foreach( $measurement_mail_extra_recipients as $measurement_mail_extra_recipient ) {
    					$list[] = $measurement_mail_extra_recipient['field_5f71d55aaf382', $measurement_client];
    				}
    				$to = implode(',', $list);
    			}
    
  • Or even just ADDING these classes would also do the trick….

  • I’ve tried to play around with:

    function my_acf_render_field( $field ) {
        echo 'test';
    }
    
    // Apply to all fields.
    add_action('acf/render_field', 'my_acf_render_field', 5);
    
    // Apply to image fields.
    // add_action('acf/render_field/type=image', 'my_acf_render_field');
    
    // Apply to fields named "hero_text".
    // add_action('acf/render_field/name=hero_text', 'my_acf_render_field');
    
    // Apply to field with key "field_123abcf".
    // add_action('acf/render_field/key=field_123abcf', 'my_acf_render_field');

    and your example does have some effect but only adds html before (or after) the regular html…

    NOTE: I can’t just rewrite the whole html output because I have some select fields that are flexible populated.

  • That’s exactly what I need!!!!!!!!!

    I only guess my conditional logic is not thought thru correctly… Because the date-conditions are all there (WOOOHOOOOOOO 😉 but the fields react different than what I was exception.

    OPTION PAGE has the following fields

    BOOKING EXCEPTIONS FIELD (repeater) with 2 sub fields:

    DATE FIELD = booking_setting_exceptions_date
    SESSION FIELD = booking_setting_exceptions_session

    FRONTEND FORM has the following fields

    DATE FIELD = field_5ed4178dd63d7
    SESSION FIELD = field_5ed4181bd63dc

    So what I want is that when the DATE and SESSION fields (from option page) match with the DATE and SESSION fields (from user input in frontend form) the field booking_time_session_1 should be hidden.

    In simple words: Within the option page I want to be able to disable specific dates with specific time sessions.

    // Apply conditions to fields
    add_filter('acf/prepare_field/name=booking_time_session_1', 'yl_check_booking_setting_exceptions');
    function yl_check_booking_setting_exceptions($field){
    	$conditions = array();
    	if (have_rows('booking_setting_exceptions', 'booking_settings')) {
    		while (have_rows('booking_setting_exceptions', 'booking_settings')) {
    			the_row();
    			$date = date_i18n('Ymd', strtotime(get_sub_field('booking_setting_exceptions_date', 'booking_settings')));
    			$session = get_sub_field('booking_setting_exceptions_date', 'booking_settings');
    			if (empty($date)) {
    				// no date, skip this row
    				continue;
    			}
    			// Add the condition to the field
    			$conditions[] =
    				array(
    					array(
    					'field'   => 'field_5ed4178dd63d7', DATE field in the form
    					'operator'  => '!=', // If Value is different, then show the field
    					'value'   => $date, // DATE option page value
    				),
    				array(
    					'field'   => 'field_5ed4181bd63dc', // SESSION field in the form
    					'operator'  => '!=', // If Value is different, then show the field
    					'value'   => $session, // SESSION option page value
    				)
    			);
    		} // end while have_rows
    	} // end if have_rows
    	$field['conditional_logic'] = $conditions;
    	// Return
    	return $field;
    }
  • So that’s it?

    I got everything right except the last piece of the puzzle and there’s nobody willing to help me trough?

  • I think I should FOREACH a part of the array. ? Is that a correct thinking?

    Although this does not work, could you help me please? This is the last part in a long journey to develop my own booking system:

    // Apply conditions to fields
    add_filter('acf/prepare_field/name=bookings_field_time_session_1', 'yl_check_booking_exeptions_session_1');
    function yl_check_booking_exeptions_session_1( $field ) {
    
        // Retrieve option values. Date value should be like: 20200611 (unformatted)
        $rows = get_field('bookings_settings_disabled_exceptions', 'bookings');
    
    	if( $rows ) {
    
            foreach ( $rows as $row ) {
                $option_date = get_sub_field('bookings_settings_disabled_date', 'bookings', false);
                $date = date_i18n('Ymd', strtotime($option_date));
                $session = get_sub_field('bookings_settings_disabled_session', 'bookings', false);
    
                $arrays =
                    array(
                        array(
                            'field'     => 'field_5ed4181bd63dc', // Time field session 1 in the form
                            'operator'  => '!=', // If Value is different, then show the field
                            'value'     => $session, // Compare against option page value
                        ),
                        array(
                            'field'     => 'field_5ed4178dd63d7', // Datepicker fiels in the form
                            'operator'  => '!=', // If Value is different, then show the field
                            'value'     => $date, // Compare against option page value
                        )
                    );
                }
    
                if ( $session == '1' ) {
                    $field['conditional_logic'] = array(
                        $arrays
                    );
                }
            }
    
            // Return
            return $field;
    
        }
    
    }
  • Thanks for looking into my code.

    But it still only outputs 1 condition (session / date combi) although I have 3 entries in the option page… and the other entries don’t have any effect

    This is the condition output I get for for the field:

    data-conditions="[[{"field":"field_5ed4181bd63dc","operator":"==","value":"1"},{"field":"field_5ed4178dd63d7","operator":"!=","value":"20200627"}],[]]"

    The whole code is this:

    // Apply conditions to fields
    add_filter('acf/prepare_field/name=bookings_field_time_session_1', 'yl_check_booking_exeptions_session_1');
    function yl_check_booking_exeptions_session_1( $field ) {
    
        // Retrieve option values. Date value should be like: 20200611 (unformatted)
    	if( have_rows('bookings_settings_disabled_exceptions', 'bookings') ) {
    		while ( have_rows('bookings_settings_disabled_exceptions', 'bookings') ) {
    			the_row();
    			$option_date = get_sub_field('bookings_settings_disabled_date', 'bookings', false);
    			$date = date_i18n('Ymd', strtotime($option_date));
    			$session = get_sub_field('bookings_settings_disabled_session', 'bookings', false);
    
    			if ( $session == '1' ) {
    				// Add the condition to the field
    				$field['conditional_logic'] = array(
    				  // the first nested array holds OR conditions
    				  // there would be a separate nested array for each OR condition
    				  array(
    					// the second nesting is AND conditions
    					array(
    					  'field'     => 'field_5ed4181bd63dc', // Time field session 1 in the form
    					  'operator'  => '!=', // If Value is different, then show the field
    					  'value'     => $session, // Compare against option page value
    					),
    					array(
    					  'field'     => 'field_5ed4178dd63d7', // Datepicker fiels in the form
    					  'operator'  => '!=', // If Value is different, then show the field
    					  'value'     => $date, // Compare against option page value
    					)
    				  ),
    				  array(
    					// this is an example, if there was an OR condition those would go here
    				  )
    				);
    			}
    
    		}
    
    	}
    
    	// Return
    	return $field;
    
    }
Viewing 25 posts - 1 through 25 (of 31 total)