Inventory_Presser_WPForms::adf_vehicle_xml()

Creates the vehicle piece of an ADF XML lead.


Return Return

(string)


Top ↑

Source Source

File: includes/integrations/class-wpforms.php

		protected function adf_vehicle_xml() {
			$form_post_id = intval( $_POST['wpforms']['id'] ?? '' );
			$fields       = wpforms_get_form_fields( $form_post_id );

			$field_id = 0;
			foreach ( $fields as $field ) {
				if ( 'vehicle' !== $field['type'] ) {
					continue;
				}
				$field_id = $field['id'];
				break;
			}

			if ( 0 === $field_id ) {
				return '';
			}

			$value   = sanitize_text_field( wp_unslash( $_POST['wpforms']['fields'][ $field_id ] ?? '' ) );
			$post_id = $this->extract_post_id_from_value( $value );

			if ( empty( $post_id ) ) {
				return '';
			}
			return sprintf(
				'<vehicle><id>%s</id><year>%s</year><make>%s</make><model>%s</model><vin>%s</vin><stock>%s</stock></vehicle>',
				INVP::get_meta( 'car_id', $post_id ),
				invp_get_the_year( $post_id ),
				invp_get_the_make( $post_id ),
				invp_get_the_model( $post_id ),
				invp_get_the_vin( $post_id ),
				invp_get_the_stock_number( $post_id )
			);
		}