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: /var/www/html/ielts-store/wp-content/plugins/woocommerce-zapier/legacy/Plugin/Subscriptions.php
<?php

namespace OM4\Zapier\Plugin;

use OM4\WooCommerceZapier\Plugin\Subscriptions\Plugin;
use OM4\Zapier\Payload\Plugin\Subscription\Order as Payload;
use OM4\Zapier\Trigger\Base;
use WC_Subscriptions;

defined( 'ABSPATH' ) || exit;

/**
 * Functionality that is enabled when the WooCommerce Subscriptions plugin is active.
 * Plugin URL: https://woocommerce.com/products/woocommerce-subscriptions/
 *
 * @deprecated 2.0.0
 */
class Subscriptions {

	/**
	 * Trigger keys that the subscriptions 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() {

		// Version check.
		if ( ! $this->is_available() ) {
			// Logging and displaying notice handled in OM4\WooCommerceZapier\Plugin\Subscriptions\Plugin.
			return;
		}

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

	/**
	 * Whether or not the WC Subscriptions plugin is active, and running a version newer than our minimum supported version.
	 *
	 * @return bool
	 */
	public static function is_available() {
		return class_exists( 'WC_Subscriptions' ) && version_compare( WC_Subscriptions::$version, Plugin::MINIMUM_SUPPORTED_VERSION, '>=' );
	}

	/**
	 * Load Subscriptions-related Triggers from the subscriptions sub directory.
	 *
	 * @deprecated 2.0.0
	 *
	 * @param array $directories The array of directories to scan for PHP files.
	 *
	 * @return array
	 */
	public function wc_zapier_trigger_directories( $directories ) {
		_deprecated_function( 'OM4\Zapier\Plugin\Subscriptions::wc_zapier_trigger_directories', '2.0' );
		return $directories;
	}

	/**
	 * When sending WooCommerce Order data to Zapier, also send any additional WC subscriptions fields.
	 *
	 * @param array                   $order_data Order data that will be overridden.
	 * @param OM4\Zapier\Trigger\Base $trigger    Trigger that initiated the data send.
	 *
	 * @return array
	 */
	public function order_data_override( $order_data, Base $trigger ) {
		if ( $trigger->is_sample() ) {
			$payload = Payload::from_sample();
		} else {
			// Sending live data.
			$payload    = new Payload();
			$renewal_id = get_post_meta( $order_data['id'], '_subscription_renewal', true );
			if ( ! empty( $renewal_id ) ) {
				$payload->is_subscription_renewal = true;
				$payload->subscription_id         = (int) $renewal_id;
			} else {
				$payload->is_subscription_renewal = false;
				$payload->subscription_id         = 0;
			}
		}

		return $order_data + $payload->to_array();
	}
}