AllTraits.php
1 year ago
Asset_Builder.php
9 months ago
Bootstrap.php
2 weeks ago
Compatibility_Support.php
2 months ago
Elements_Manager.php
7 months ago
Helper.php
1 month ago
Migration.php
5 months ago
Plugin_Usage_Tracker.php
5 months ago
WPDeveloper_Core_Installer.php
5 months ago
WPDeveloper_Notice.php
2 months ago
WPDeveloper_Plugin_Installer.php
5 months ago
WPDeveloper_Setup_Wizard.php
2 months ago
index.php
3 years ago
Compatibility_Support.php
89 lines
| 1 | <?php |
| 2 | namespace Essential_Addons_Elementor\Classes; |
| 3 | |
| 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | exit; |
| 6 | } // Exit if accessed directly |
| 7 | |
| 8 | class Compatibility_Support { |
| 9 | public function __construct() { |
| 10 | if ( $this->is_mondialrelay_plugin_active() ) { |
| 11 | add_action( 'eael_mondialrelay_order_after_shipping', [$this, 'eael_mondialrelay_shipping_action'] ); |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Handles Mondial Relay shipping method integration |
| 17 | * Checks if the plugin is active and adds necessary shipping form actions |
| 18 | * |
| 19 | * @return void |
| 20 | */ |
| 21 | public function eael_mondialrelay_shipping_action() { |
| 22 | // Check if Mondial Relay plugin is active |
| 23 | if (!$this->is_mondialrelay_plugin_active()) { |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | // Get the chosen shipping method |
| 28 | $chosen_shipping_methods = WC()->session->get('chosen_shipping_methods'); |
| 29 | if (empty($chosen_shipping_methods)) { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | // Parse shipping method details |
| 34 | $method_string = $chosen_shipping_methods[0]; |
| 35 | // Ensure method_string is a string and contains a colon |
| 36 | if ( !is_string($method_string) || strpos($method_string, ':') === false ) { |
| 37 | return; |
| 38 | } |
| 39 | list($method_id, $instance_id) = explode(':', $method_string, 2); |
| 40 | |
| 41 | // Add shipping form if Mondial Relay is selected |
| 42 | if ($method_id === 'mondialrelay_official_shipping') { |
| 43 | add_action( 'woocommerce_review_order_after_shipping', [$this, 'eael_mondialrelay_shipping_form_after'] ); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Checks if Mondial Relay plugin is active |
| 49 | * |
| 50 | * @return bool |
| 51 | */ |
| 52 | private function is_mondialrelay_plugin_active() { |
| 53 | // Include plugin.php to ensure plugin functions are available |
| 54 | if ( ! function_exists( 'is_plugin_active_for_network' ) ) { |
| 55 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 56 | } |
| 57 | |
| 58 | $plugin_path = 'mondialrelay-wordpress/mondialrelay-wordpress.php'; |
| 59 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound |
| 60 | return in_array( $plugin_path, apply_filters('active_plugins', get_option('active_plugins' ) ) ) || is_plugin_active_for_network( $plugin_path ); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Renders the Mondial Relay shipping form in the WooCommerce checkout page. |
| 65 | * This method adds a table row customly from EA plugin |
| 66 | * @since 1.0.0 |
| 67 | * @return void |
| 68 | */ |
| 69 | public function eael_mondialrelay_shipping_form_after() { |
| 70 | ?> |
| 71 | <tr class="mrwp" style="display:none"> |
| 72 | <th><?php echo esc_html__('Livraison Mondial Relay','essential-addons-for-elementor-lite');?> |
| 73 | <br> |
| 74 | <em id="parcel_shop_info" class="parcel_shop_info"><?php echo esc_html__("Vous n'avez pas encore choisi de Point Relais®",'essential-addons-for-elementor-lite');?></em> |
| 75 | </th> |
| 76 | <td><a id="modaal_link" class="modaal_link" href="#modaal"><?php echo esc_html__('Choisir un Point Relais®', 'essential-addons-for-elementor-lite'); ?></a></td> |
| 77 | </tr> |
| 78 | <script> |
| 79 | jQuery(".modaal_link").modaal({ |
| 80 | overlay_opacity: .4, |
| 81 | after_open: mrwpModaalOpen, |
| 82 | after_callback_delay: 100, |
| 83 | before_open: mrwpResetSearch, |
| 84 | content_source: "#modaal" |
| 85 | }); |
| 86 | </script> |
| 87 | <?php |
| 88 | } |
| 89 | } |