| @@ -5,9 +5,9 @@ | ||
| 5 | 5 | use RadiusTheme\SB\Helpers\BuilderFns; |
| 6 | 6 | use RadiusTheme\SB\Helpers\ElementorDataMap; |
| 7 | 7 | use RadiusTheme\SB\Helpers\Fns; |
| 8 | 8 | use RadiusTheme\SB\Traits\SingletonTrait; |
| 9 | - | |
| 9 | +use RadiusTheme\SB\Controllers\PluginsSupport; | |
| 10 | 10 | // Do not allow directly accessing this file. |
| 11 | 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | 12 | exit( 'This script cannot be accessed directly.' ); |
| 13 | 13 | } |
| @@ -19,9 +19,8 @@ | ||
| 19 | 19 | /** |
| 20 | 20 | * SingletonTrait. |
| 21 | 21 | */ |
| 22 | 22 | use SingletonTrait; |
| 23 | - | |
| 24 | 23 | /** |
| 25 | 24 | * Construct function |
| 26 | 25 | */ |
| 27 | 26 | private function __construct() { |
| @@ -26,19 +25,10 @@ | ||
| 26 | 25 | */ |
| 27 | 26 | private function __construct() { |
| 28 | 27 | add_action( 'init', [ $this, 'plugins_support' ], 9 ); |
| 29 | 28 | add_action( 'init', [ $this, 'themes_support' ], 9 ); |
| 30 | - add_filter( 'woocommerce_locate_template', [ $this, 'locate_template' ], 10, 2 ); | |
| 31 | - if ( defined( 'RTSB_DEVELOPER_MODE' ) && RTSB_DEVELOPER_MODE ) { | |
| 32 | - $this->developer_support(); | |
| 33 | - } | |
| 34 | - } | |
| 29 | + add_filter( 'woocommerce_locate_template', [ $this, 'shipping_method_support' ], 10, 3 ); | |
| 35 | 30 | |
| 36 | - /** | |
| 37 | - * @return void | |
| 38 | - */ | |
| 39 | - public function developer_support() { | |
| 40 | - add_filter( 'rtsb/builder/preview/access', '__return_false', 5 ); | |
| 41 | 31 | } |
| 42 | 32 | |
| 43 | 33 | /** |
| 44 | 34 | * Theme Support |
| @@ -48,16 +38,11 @@ | ||
| 48 | 38 | public function plugins_support() { |
| 49 | 39 | // Check for plugin using plugin name. |
| 50 | 40 | $active_plugin = apply_filters( 'active_plugins', get_option( 'active_plugins' ) ); |
| 51 | 41 | $supports = [ |
| 52 | - 'woo-address-book/woocommerce-address-book.php' => PluginsSupport\WooAddressBook::class, | |
| 53 | 42 | 'woo-product-variation-gallery/woo-product-variation-gallery.php' => PluginsSupport\RtwpvgSupport::class, |
| 54 | 43 | 'woo-product-variation-swatches-pro/woo-product-variation-swatches-pro.php' => PluginsSupport\RtwpvsSupport::class, |
| 55 | - 'products-visibility-by-user-roles/addify_product_visibility.php' => PluginsSupport\AddifyVisibilityByRoles::class, | |
| 56 | - 'woocommerce-payments/woocommerce-payments.php' => PluginsSupport\WooPaymentsSupport::class, | |
| 57 | - 'woocommerce-paypal-payments/woocommerce-paypal-payments.php' => PluginsSupport\PayPalPPCPSupport::class, | |
| 58 | 44 | ]; |
| 59 | - $supports = apply_filters( 'rtsb/plugins/support', $supports ); | |
| 60 | 45 | foreach ( $supports as $active_path => $class ) { |
| 61 | 46 | $is_active = in_array( $active_path, $active_plugin, true ); |
| 62 | 47 | if ( $is_active && class_exists( $class ) && method_exists( $class, 'instance' ) ) { |
| 63 | 48 | $class::instance(); |
| @@ -72,9 +57,9 @@ | ||
| 72 | 57 | public function themes_support() { |
| 73 | 58 | $themeClass = ucwords( str_replace( [ '_', '-', ' ' ], '', rtsb()->current_theme ) ); |
| 74 | 59 | |
| 75 | 60 | $supportClass = apply_filters( |
| 76 | - 'RadiusTheme/SB/ThemesSupport/Class', // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase | |
| 61 | + 'RadiusTheme/SB/ThemesSupport/Class', | |
| 77 | 62 | [ |
| 78 | 63 | 'ThemesSupport' => 'RadiusTheme\SB\Controllers\ThemesSupport\\' . $themeClass . '\\ThemeSupport', |
| 79 | 64 | 'TheTheme' => '\ThemeSupport', |
| 80 | 65 | ] |
| @@ -91,22 +76,25 @@ | ||
| 91 | 76 | } |
| 92 | 77 | } |
| 93 | 78 | |
| 94 | 79 | /** |
| 95 | - * Filters and overrides the default WooCommerce template paths for specific templates | |
| 96 | - * based on builder context and available Elementor widgets. | |
| 80 | + * Theme Support | |
| 97 | 81 | * |
| 98 | - * - Replaces the checkout review order template if a custom widget is present. | |
| 99 | - * - Replaces the single product description tab template if on a product page. | |
| 100 | - * | |
| 101 | - * @param string $template The path to the template to include. | |
| 102 | - * @param string $template_name The name of the template. | |
| 103 | - * | |
| 104 | - * @return string Modified or original template path. | |
| 82 | + * @return void | |
| 105 | 83 | */ |
| 106 | - public function locate_template( $template, $template_name ) { | |
| 107 | - if ( 'single-product/tabs/description.php' === $template_name && BuilderFns::is_product() ) { | |
| 108 | - $template = Fns::locate_template( 'elementor/single-product/tab-description' ); | |
| 84 | + public function shipping_method_support( $template, $template_name, $template_path ) { | |
| 85 | + if ( 'checkout/review-order.php' !== $template_name || ! BuilderFns::is_checkout() ) { | |
| 86 | + return $template; | |
| 109 | 87 | } |
| 88 | + | |
| 89 | + $id = BuilderFns::is_builder_preview() ? get_the_ID() : BuilderFns::builder_page_id_by_type( 'checkout' ); | |
| 90 | + $elmap = ElementorDataMap::instance(); | |
| 91 | + $get_widget = $elmap->get_widget_data( 'rtsb-shipping-method', [], $id ); | |
| 92 | + if ( ! empty( $get_widget ) ) { | |
| 93 | + $template = Fns::locate_template( 'elementor/checkout/customized-order-review' ); | |
| 94 | + } | |
| 95 | + | |
| 110 | 96 | return $template; |
| 111 | 97 | } |
| 98 | + | |
| 99 | + | |
| 112 | 100 | } |