| @@ -57,8 +57,9 @@ | ||
| 57 | 57 | add_action( 'elementor/frontend/after_register_styles', [ $this, 'frontend_register_styles' ], 10 ); |
| 58 | 58 | add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'frontend_enqueue_styles' ], 10 ); |
| 59 | 59 | add_action( 'elementor/frontend/after_enqueue_scripts', [ $this, 'frontend_enqueue_scripts' ], 10 ); |
| 60 | 60 | add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'editor_enqueue_styles' ], 10 ); |
| 61 | + add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'editor_enqueue_scripts' ], 20 ); | |
| 61 | 62 | |
| 62 | 63 | spl_autoload_register( [ $this, 'autoload' ] ); |
| 63 | 64 | remove_theme_support( 'wc-product-gallery-lightbox' ); |
| 64 | 65 | } |
| @@ -212,11 +213,21 @@ | ||
| 212 | 213 | * |
| 213 | 214 | * @return array |
| 214 | 215 | */ |
| 215 | 216 | public function get_localize_data() { |
| 217 | + $needs_shipping = ''; | |
| 218 | + | |
| 219 | + if ( function_exists( 'WC' ) ) { | |
| 220 | + $cart = WC()->cart; | |
| 221 | + | |
| 222 | + if ( $cart && method_exists( $cart, 'needs_shipping' ) ) { | |
| 223 | + $needs_shipping = $cart->needs_shipping(); | |
| 224 | + } | |
| 225 | + } | |
| 226 | + | |
| 216 | 227 | return [ |
| 217 | 228 | 'nonce' => wp_create_nonce( 'sellkit_elementor' ), |
| 218 | - 'wcNeedShipping' => ( function_exists( 'WC' ) ) ? WC()->cart->needs_shipping() : '', | |
| 229 | + 'wcNeedShipping' => $needs_shipping, | |
| 219 | 230 | 'url' => [ |
| 220 | 231 | 'assets' => sellkit()->plugin_url() . 'assets/', |
| 221 | 232 | ], |
| 222 | 233 | ]; |
| @@ -283,8 +294,23 @@ | ||
| 283 | 294 | 'sellkit-element-icons', |
| 284 | 295 | sellkit()->plugin_url() . 'assets/dist/css/editor' . $suffix . '.css', |
| 285 | 296 | [], |
| 286 | 297 | sellkit()->version() |
| 298 | + ); | |
| 299 | + } | |
| 300 | + | |
| 301 | + /** | |
| 302 | + * Enqueue editor scripts. | |
| 303 | + * | |
| 304 | + * @since 1.7.4 | |
| 305 | + */ | |
| 306 | + public function editor_enqueue_scripts() { | |
| 307 | + wp_localize_script( | |
| 308 | + 'sellkit-editor', | |
| 309 | + 'sellkitPromotion', | |
| 310 | + [ | |
| 311 | + 'activeTheme' => wp_get_theme()->get( 'Name' ), | |
| 312 | + ] | |
| 287 | 313 | ); |
| 288 | 314 | } |
| 289 | 315 | } |
| 290 | 316 | |