HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: //proc/thread-self/cwd/wp-content/plugins/woocommerce-zapier/legacy/Plugin/CheckoutFieldEditor.php
<?php

namespace OM4\Zapier\Plugin;

use OM4\Zapier\Payload\Plugin\CheckoutFieldEditor as Payload;
use OM4\Zapier\Plugin;
use OM4\Zapier\Trigger\Base;

defined( 'ABSPATH' ) || exit;

/**
 * Functionality that is enabled when the Checkout Field Editor plugin is activated.
 *
 * Plugin URL: https://woocommerce.com/products/woocommerce-checkout-field-editor/
 *
 * Class CheckoutFieldEditor
 *
 * @deprecated 2.0.0
 */
class CheckoutFieldEditor {

	/**
	 * Option names that store the Checkout Field editor field specification(s).
	 *
	 * @var array
	 */
	private $checkout_field_sections = array(
		'wc_fields_billing',
		'wc_fields_shipping',
		'wc_fields_additional',
	);

	/**
	 * Trigger keys that the checkout field editor data should be added to.
	 *
	 * @var array
	 */
	private $trigger_keys = array(
		// New Order.
		'wc.new_order',
		// New Order Status Change.
		'wc.order_status_change',
	);

	/**
	 * Constructor
	 */
	public function __construct() {

		foreach ( $this->trigger_keys as $trigger_key ) {
			add_filter( "wc_zapier_data_{$trigger_key}", array( $this, 'order_data_override' ), 10, 2 );
		}

		foreach ( $this->checkout_field_sections as $field_section_name ) {
			add_action( "update_option_{$field_section_name}", array( $this, 'checkout_fields_updated' ), 10, 0 );
		}

	}

	/**
	 * When sending WooCommerce Order data to Zapier, also send any additional
	 * checkout fields that have been created by the Checkout Field Editor
	 * plugin.
	 *
	 * @param array                   $order_data Order data that will be overridden.
	 * @param OM4\Zapier\Trigger\Base $trigger    Trigger that initiated the data send.
	 *
	 * @return mixed
	 */
	public function order_data_override( $order_data, Base $trigger ) {

		$checkout_payload = new Payload();
		foreach ( $this->checkout_field_sections as $field_section_name ) {
			$field_specification = get_option( $field_section_name, array() );
			foreach ( $field_specification as $field_name => $field_data ) {
				if ( $field_data['enabled'] && ! isset( $order_data[ $field_name ] ) ) {
					if ( $trigger->is_sample() ) {
						// We're sending sample data.
						// Send the label of the custom checkout field as the field's value.
						$checkout_payload->$field_name = $field_data['label'];
					} else {
						// We're sending real data.
						// Send the saved value of this checkout field.
						// If the order doesn't contain this custom field, an empty string will be used as the value.
						$checkout_payload->$field_name = get_post_meta( $order_data['id'], $field_name, true );
					}
				}
			}
		}
		return $order_data + $checkout_payload->to_array();
	}

	/**
	 * Executed whenever the checkout field definitions are updated/saved.
	 * Schedule the feed refresh to occur asynchronously.
	 *
	 * @return void
	 */
	public function checkout_fields_updated() {
		Plugin::resend_sample_data_async( $this->trigger_keys );
	}
}