PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 5.8.5
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v5.8.5
6.0.3 6.0.2 6.0.1 6.0.0 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.7.9.2 5.7.9.1 5.7.8 5.7.9 5.7.6 5.7.7 5.7.5 5.7.4 5.7.3 5.7.2 5.7.1 trunk 5.6.0 5.6.1 All 34 releases
automatorwp / integrations / woocommerce / woocommerce.php

woocommerce.php in AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI 5.8.5, at integrations/woocommerce/woocommerce.php

193 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: AutomatorWP - WooCommerce integration
4 * Plugin URI: https://automatorwp.com/add-ons/woocommerce/
5 * Description: Connect AutomatorWP with WooCommerce.
6 * Version: 1.1.0
7 * Author: AutomatorWP
8 * Author URI: https://automatorwp.com/
9 * Text Domain: automatorwp-woocommerce-integration
10 * Domain Path: /languages/
11 * Requires at least: 4.4
12 * Tested up to: 5.7
13 * License: GNU AGPL v3.0 (http://www.gnu.org/licenses/agpl.txt)
14 *
15 * @package AutomatorWP\WooCommerce
16 * @author AutomatorWP
17 * @copyright Copyright (c) AutomatorWP
18 */
19
20 final class AutomatorWP_Integration_WooCommerce {
21
22 /**
23 * @var AutomatorWP_Integration_WooCommerce $instance The one true AutomatorWP_Integration_WooCommerce
24 * @since 1.0.0
25 */
26 private static $instance;
27
28 /**
29 * Get active instance
30 *
31 * @access public
32 * @since 1.0.0
33 * @return AutomatorWP_Integration_WooCommerce self::$instance The one true AutomatorWP_Integration_WooCommerce
34 */
35 public static function instance() {
36
37 if( ! self::$instance ) {
38
39 self::$instance = new AutomatorWP_Integration_WooCommerce();
40
41 if( ! self::$instance->pro_installed() ) {
42
43 self::$instance->constants();
44 self::$instance->includes();
45
46 }
47
48 self::$instance->hooks();
49 }
50
51 return self::$instance;
52 }
53
54 /**
55 * Setup plugin constants
56 *
57 * @access private
58 * @since 1.0.0
59 * @return void
60 */
61 private function constants() {
62 // Plugin version
63 define( 'AUTOMATORWP_WOOCOMMERCE_VER', '1.1.0' );
64
65 // Plugin file
66 define( 'AUTOMATORWP_WOOCOMMERCE_FILE', __FILE__ );
67
68 // Plugin path
69 define( 'AUTOMATORWP_WOOCOMMERCE_DIR', plugin_dir_path( __FILE__ ) );
70
71 // Plugin URL
72 define( 'AUTOMATORWP_WOOCOMMERCE_URL', plugin_dir_url( __FILE__ ) );
73 }
74
75 /**
76 * Include plugin files
77 *
78 * @access private
79 * @since 1.0.0
80 * @return void
81 */
82 private function includes() {
83
84 if( $this->meets_requirements() ) {
85
86 // Includes
87 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/filters.php';
88 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/functions.php';
89 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/tags.php';
90
91 // Triggers
92 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/triggers/view-product.php';
93 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/triggers/purchase-product.php';
94 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/triggers/purchase-product-category.php';
95 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/triggers/purchase-product-tag.php';
96 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/triggers/complete-purchase.php';
97 // WooCommerce Memberships
98 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/triggers/membership-created.php';
99 // WooCommerce Subscriptions
100 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/triggers/purchase-subscription.php';
101
102 // Anonymous Triggers
103 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/triggers/anonymous-purchase-product.php';
104 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/triggers/anonymous-purchase-product-category.php';
105 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/triggers/anonymous-purchase-product-tag.php';
106 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/triggers/anonymous-complete-purchase.php';
107
108 // Actions
109 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/actions/add-user-to-coupon.php';
110 // WooCommerce Memberships
111 require_once AUTOMATORWP_WOOCOMMERCE_DIR . 'includes/actions/add-membership.php';
112
113 }
114 }
115
116 /**
117 * Setup plugin hooks
118 *
119 * @access private
120 * @since 1.0.0
121 * @return void
122 */
123 private function hooks() {
124
125 add_action( 'automatorwp_init', array( $this, 'register_integration' ) );
126
127 }
128
129 /**
130 * Registers this integration
131 *
132 * @since 1.0.0
133 */
134 function register_integration() {
135
136 automatorwp_register_integration( 'woocommerce', array(
137 'label' => 'WooCommerce',
138 'icon' => plugin_dir_url( __FILE__ ) . 'assets/woocommerce.svg',
139 ) );
140
141 }
142
143 /**
144 * Check if there are all plugin requirements
145 *
146 * @since 1.0.0
147 *
148 * @return bool True if installation meets all requirements
149 */
150 private function meets_requirements() {
151
152 if ( ! class_exists( 'AutomatorWP' ) ) {
153 return false;
154 }
155
156 if ( ! class_exists( 'WooCommerce' ) ) {
157 return false;
158 }
159
160 return true;
161
162 }
163
164 /**
165 * Check if the pro version of this integration is installed
166 *
167 * @since 1.0.0
168 *
169 * @return bool True if pro version installed
170 */
171 private function pro_installed() {
172
173 if ( ! class_exists( 'AutomatorWP_WooCommerce' ) ) {
174 return false;
175 }
176
177 return true;
178
179 }
180
181 }
182
183 /**
184 * The main function responsible for returning the one true AutomatorWP_Integration_WooCommerce instance to functions everywhere
185 *
186 * @since 1.0.0
187 * @return \AutomatorWP_Integration_WooCommerce The one true AutomatorWP_Integration_WooCommerce
188 */
189 function AutomatorWP_Integration_WooCommerce() {
190 return AutomatorWP_Integration_WooCommerce::instance();
191 }
192 add_action( 'automatorwp_pre_init', 'AutomatorWP_Integration_WooCommerce' );
193