| @@ -213,11 +213,21 @@ | ||
| 213 | 213 | * |
| 214 | 214 | * @return array |
| 215 | 215 | */ |
| 216 | 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 | + | |
| 217 | 227 | return [ |
| 218 | 228 | 'nonce' => wp_create_nonce( 'sellkit_elementor' ), |
| 219 | - 'wcNeedShipping' => ( function_exists( 'WC' ) ) ? WC()->cart->needs_shipping() : '', | |
| 229 | + 'wcNeedShipping' => $needs_shipping, | |
| 220 | 230 | 'url' => [ |
| 221 | 231 | 'assets' => sellkit()->plugin_url() . 'assets/', |
| 222 | 232 | ], |
| 223 | 233 | ]; |