| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Connect and EU VAT Compliance for WooCommerce |
| 4 |
* Plugin URI: https://close.technology/wordpress-plugins/connect-ecommerce/ |
| 5 |
* Description: Connects Ecommerce WooCommerce to ERPs and CRMs. Syncs products, customers, orders and stock. Includes EU VAT Compliance. Import European Taxes and check VAT compliance. |
| 6 |
* Author: Closetechnology |
| 7 |
* Author URI: https://close.technology/ |
| 8 |
* Version: 3.4.0 |
| 9 |
* Requires PHP: 7.4 |
| 10 |
* Requires at least: 6.3 |
| 11 |
* Text Domain: woocommerce-es |
| 12 |
* Requires Plugins: woocommerce |
| 13 |
* License: GPL-2.0+ |
| 14 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 15 |
* |
| 16 |
* Prefix: conecom_ |
| 17 |
* |
| 18 |
* @package WordPress |
| 19 |
*/ |
| 20 |
|
| 21 |
defined( 'ABSPATH' ) || exit; |
| 22 |
|
| 23 |
define( 'CONECOM_VERSION', '3.4.0' ); |
| 24 |
define( 'CONECOM_FILE', __FILE__ ); |
| 25 |
define( 'CONECOM_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 26 |
define( 'CONECOM_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
| 27 |
define( 'CONECOM_SYNC_PRODUCTS_PER_BATCH', 50 ); |
| 28 |
define( |
| 29 |
'CONECOM_VAT_FIELD_SLUGS', |
| 30 |
array( |
| 31 |
'_billing_vat', |
| 32 |
'_billing_nif', |
| 33 |
'_billing_vat_number', |
| 34 |
'billing_vat', |
| 35 |
'billing_cif', |
| 36 |
'_wc_shipping/connect_ecommerce/billing_vat', // Gutenberg compatibility. |
| 37 |
'VAT Number', |
| 38 |
) |
| 39 |
); |
| 40 |
|
| 41 |
require_once CONECOM_PLUGIN_PATH . 'vendor/autoload.php'; |
| 42 |
|
| 43 |
/** |
| 44 |
* Gets the options for the plugin. |
| 45 |
* |
| 46 |
* @return array |
| 47 |
*/ |
| 48 |
function conecom_get_options() { |
| 49 |
/** |
| 50 |
* Default values |
| 51 |
*/ |
| 52 |
global $wpdb; |
| 53 |
|
| 54 |
return apply_filters( |
| 55 |
'conecom_options_plugin', |
| 56 |
array( |
| 57 |
'clientify' => array( |
| 58 |
'name' => 'Clientify', |
| 59 |
'slug' => 'conecom-clientify', |
| 60 |
'version' => CONECOM_VERSION, |
| 61 |
'plugin_name' => 'Connect WooCommerce Clientify', |
| 62 |
'plugin_slug' => 'connect-ecommerce-clientify', |
| 63 |
'disable_modules' => array( 'subscription' ), |
| 64 |
'api_pagination' => 100, |
| 65 |
'product_price_tax_option' => true, |
| 66 |
'product_price_rate_option' => false, |
| 67 |
'product_option_stock' => false, |
| 68 |
'order_send_attachments' => true, |
| 69 |
'order_sync_partial' => true, |
| 70 |
'order_import_free_order' => true, |
| 71 |
'order_only_order_completed' => 'completed', |
| 72 |
'settings_logo' => CONECOM_PLUGIN_URL . 'includes/Connector/assets/logo.svg', |
| 73 |
'settings_admin_message' => sprintf( |
| 74 |
// translators: %s url of contact. |
| 75 |
__( 'Put the connection API key settings in order to connect and sync products. You can go here <a href = "%s" target = "_blank">App Test API</a>.', 'woocommerce-es' ), |
| 76 |
'https://app.test.com/api' |
| 77 |
), |
| 78 |
'settings_special_tabs' => array(), |
| 79 |
'settings_fields' => array( 'apipassword' ), |
| 80 |
'table_sync' => $wpdb->prefix . 'sync_conecom-clientify', |
| 81 |
'file' => __FILE__, |
| 82 |
), |
| 83 |
'brevo' => array( |
| 84 |
'name' => 'Brevo', |
| 85 |
'slug' => 'conecom-brevo', |
| 86 |
'version' => CONECOM_VERSION, |
| 87 |
'plugin_name' => 'Connect WooCommerce Brevo', |
| 88 |
'plugin_slug' => 'connect-ecommerce-brevo', |
| 89 |
'disable_modules' => array( 'subscription', 'product' ), |
| 90 |
'api_pagination' => 100, |
| 91 |
'product_price_tax_option' => false, |
| 92 |
'product_price_rate_option' => false, |
| 93 |
'product_option_stock' => false, |
| 94 |
'order_send_attachments' => false, |
| 95 |
'order_sync_partial' => true, |
| 96 |
'order_import_free_order' => true, |
| 97 |
'order_only_order_completed' => 'completed', |
| 98 |
'order_tags' => true, |
| 99 |
'settings_logo' => CONECOM_PLUGIN_URL . 'includes/Connector/assets/brevo-logo.svg', |
| 100 |
'settings_admin_message' => sprintf( |
| 101 |
// translators: %s url of Brevo API keys page. |
| 102 |
__( 'Put your Brevo API key in order to connect and sync orders. You can find it here <a href = "%s" target = "_blank">Brevo API Keys</a>.', 'woocommerce-es' ), |
| 103 |
'https://app.brevo.com/settings/keys/api' |
| 104 |
), |
| 105 |
'settings_special_tabs' => array(), |
| 106 |
'settings_fields' => array( 'apipassword' ), |
| 107 |
'table_sync' => $wpdb->prefix . 'sync_conecom-brevo', |
| 108 |
'file' => __FILE__, |
| 109 |
), |
| 110 |
) |
| 111 |
); |
| 112 |
} |
| 113 |
|
| 114 |
add_action( 'init', 'conecom_loads' ); |
| 115 |
/** |
| 116 |
* Connect WooCommerce loads. |
| 117 |
* |
| 118 |
* @return void |
| 119 |
*/ |
| 120 |
function conecom_loads() { |
| 121 |
require_once CONECOM_PLUGIN_PATH . 'includes/Plugin_Main.php'; |
| 122 |
require_once CONECOM_PLUGIN_PATH . 'includes/Connector/class-api-clientify.php'; |
| 123 |
require_once CONECOM_PLUGIN_PATH . 'includes/Connector/class-api-brevo.php'; |
| 124 |
|
| 125 |
$conecom_options = conecom_get_options(); |
| 126 |
new CLOSE\ConnectEcommerce\Base( $conecom_options ); |
| 127 |
} |
| 128 |
|
| 129 |
if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 130 |
require_once CONECOM_PLUGIN_PATH . 'includes/CLI/Import_Products_Command.php'; |
| 131 |
|
| 132 |
/** |
| 133 |
* Registers our command when cli get's initialized. |
| 134 |
* |
| 135 |
* @since 1.0.0 |
| 136 |
* @author David Perez |
| 137 |
*/ |
| 138 |
function conecom_import_products_register_commands() { |
| 139 |
WP_CLI::add_command( 'conecom', 'Import_Products_Command' ); |
| 140 |
} |
| 141 |
|
| 142 |
add_action( 'cli_init', 'conecom_import_products_register_commands', 20 ); |
| 143 |
} |
| 144 |
|
| 145 |
register_activation_hook( __FILE__, 'conecom_activation' ); |
| 146 |
/** |
| 147 |
* Runs on plugin activation: migrates legacy settings and queues the setup wizard redirect. |
| 148 |
* |
| 149 |
* @return void |
| 150 |
*/ |
| 151 |
function conecom_activation() { |
| 152 |
CLOSE\ConnectEcommerce\Helpers\HELPER::move_settings(); |
| 153 |
|
| 154 |
if ( ! get_option( 'conecom_wizard_complete' ) ) { |
| 155 |
set_transient( 'conecom_wizard_redirect', true, 30 ); |
| 156 |
} |
| 157 |
} |
| 158 |
|