PluginProbe
Route ‑ Shipping Protection / 2.4.5
Route ‑ Shipping Protection v2.4.5
2.4.19 2.4.18 2.4.17 2.4.16 2.4.15 2.4.14 2.4.13 2.4.12 2.4.11 2.4.10 2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.2.4 2.2.5 2.2.6 2.2.8 2.2.9 2.3.0 2.3.1 All 153 releases
routeapp / integrations / checkout / class-checkout-for-woocommerce.php

class-checkout-for-woocommerce.php in Route ‑ Shipping Protection 2.4.5, at integrations/checkout/class-checkout-for-woocommerce.php

48 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5
6 class Routeapp_Integration_With_CheckoutWc {
7 public function __construct() {
8 if ($this->is_active()) {
9 add_action( 'woocommerce_init', [ $this, 'actions' ] );
10 }
11 }
12
13 public function actions() {
14 add_filter( 'wfacp_advanced_fields', function($field) {
15 $field['route_widget_field'] = [
16 'type' => 'hidden',
17 'default' => true,
18 'label' => 'Route Widget',
19 'validate' => [],
20 'id' => 'route_widget_field',
21 'required' => false,
22 'wrapper_class' => [],
23 'class' => [ 'route-widget-field' ],
24 ];
25 return $field;
26 } );
27
28 add_filter( 'woocommerce_form_field_args', function( $args, $key ) {
29 if ( $key == 'route_widget_field' ) {
30 echo do_shortcode('[route]');
31 }
32 return $args;
33 }, 10, 2 );
34 }
35
36 public function is_active() {
37 $active_plugins = (array) get_option( 'active_plugins', array() );
38
39 if ( is_multisite() ) {
40 $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
41 }
42
43 return in_array( 'checkout-for-woocommerce/checkout-for-woocommerce.php', $active_plugins ) || array_key_exists( 'checkout-for-woocommerce/checkout-for-woocommerce.php', $active_plugins );
44 }
45 }
46
47 Routeapp_Plugin_Integrations::register( new Routeapp_Integration_With_CheckoutWc(), 'checkout-for-woocommerce' );
48