| 1 |
<?php |
| 2 |
|
| 3 |
namespace Sellkit\Admin\Funnel; |
| 4 |
|
| 5 |
defined( 'ABSPATH' ) || die(); |
| 6 |
|
| 7 |
/** |
| 8 |
* Class Funnel. |
| 9 |
* |
| 10 |
* @since 1.1.0 |
| 11 |
*/ |
| 12 |
class Funnel { |
| 13 |
|
| 14 |
const SELLKIT_FUNNELS_TEMPLATE_SOURCE = 'https://templates.getsellkit.com'; |
| 15 |
|
| 16 |
/** |
| 17 |
* Funnel_Importer constructor. |
| 18 |
* |
| 19 |
* @since 1.1.0 |
| 20 |
*/ |
| 21 |
public function __construct() { |
| 22 |
if ( class_exists( 'Elementor\Plugin' ) ) { |
| 23 |
sellkit()->load_files( [ |
| 24 |
'admin/funnel/importer/page-builders/elementor-importer', |
| 25 |
] ); |
| 26 |
} |
| 27 |
|
| 28 |
sellkit()->load_files( |
| 29 |
[ |
| 30 |
'admin/funnel/importer/page-builders/importer-base', |
| 31 |
'admin/funnel/importer/step-importer', |
| 32 |
'admin/funnel/importer/ajax-handler', |
| 33 |
] |
| 34 |
); |
| 35 |
|
| 36 |
add_action( 'wp_ajax_sellkit_steps_bump_get_product_data', [ $this, 'get_product_data' ] ); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Gets products data. |
| 41 |
* |
| 42 |
* @since 1.1.0 |
| 43 |
*/ |
| 44 |
public function get_product_data() { |
| 45 |
check_ajax_referer( 'sellkit', 'nonce' ); |
| 46 |
|
| 47 |
$product_id = filter_input( INPUT_GET, 'product_id', FILTER_SANITIZE_NUMBER_INT ); |
| 48 |
|
| 49 |
if ( ! sellkit()->has_valid_dependencies() ) { |
| 50 |
wp_send_json_error( __( 'Please install and activate WooCommerce.', 'sellkit' ) ); |
| 51 |
} |
| 52 |
|
| 53 |
$product = wc_get_product( $product_id ); |
| 54 |
|
| 55 |
if ( empty( $product ) ) { |
| 56 |
wp_send_json_error( __( 'Product does not exist', 'sellkit' ) ); |
| 57 |
} |
| 58 |
|
| 59 |
wp_send_json_success( [ |
| 60 |
'thumbnail' => get_the_post_thumbnail_url( $product_id ), |
| 61 |
'regularPrice' => $product->get_regular_price(), |
| 62 |
] ); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
new Funnel(); |
| 67 |
|