Inventory_Presser_Contact_Form_7::add_mail_tags( $output,  $name,  $html,  $mail_tag = null )


Source Source

File: includes/integrations/class-contact-form-7.php

	public function add_mail_tags( $output, $name, $html, $mail_tag = null ) {
		$name = preg_replace( '/^wpcf7\./', '_', $name ); // for back-compat
		$submission = WPCF7_Submission::get_instance();
		if ( ! $submission ) {
			return $output;
		}

		if ( 'invp_adf_timestamp' == $name
			&& $timestamp = $submission->get_meta('timestamp') 
		) {
			return wp_date('c', $timestamp);
		}

		if ( 'invp_adf_vehicle' == $name ) {
			add_filter('wp_mail_content_type', array( $this, 'html_mail_content_type' ));

			//What name in posted_data is the vehicle field?
			foreach( $submission->get_contact_form()->scan_form_tags() as $form_tag ) {
				if( $form_tag->basetype != 'invp_vehicle' ) {
					continue;
				}

				$post_id = $this->extract_post_id_from_value( $submission->get_posted_data()[$form_tag->name] );
				/*
				<vehicle>
					<id>286535725</id>
					<year>2017</year>
					<make>NISSAN</make>
					<model>ROGUE</model>
					<vin>5N1AT2MV8HC876642</vin>
					<stock>876642-A</stock>
				</vehicle>
				*/
				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 )
				);
			}
		}
		return $output;
	}