Repalced virtual product with template category
This commit is contained in:
@@ -12,8 +12,9 @@ class Wiaas_Template_Admin_Ajax {
|
||||
*/
|
||||
public static function init() {
|
||||
|
||||
// Ajax add bundled product.
|
||||
// Ajax template category
|
||||
add_action('wp_ajax_wiaas_add_template_product', array(__CLASS__, 'ajax_add_wiaas_template_product'));
|
||||
add_action('wp_ajax_wiaas_template_category_search', array(__CLASS__, 'ajax_wiaas_template_category_search'));
|
||||
|
||||
// Ajax add bundled product.
|
||||
add_action('wp_ajax_wiaas_select_template', array(__CLASS__, 'ajax_handle_template_selection'));
|
||||
@@ -22,7 +23,6 @@ class Wiaas_Template_Admin_Ajax {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function ajax_handle_template_selection() {
|
||||
|
||||
$selected_template_id = intval($_POST['selected_template']);
|
||||
@@ -48,31 +48,47 @@ class Wiaas_Template_Admin_Ajax {
|
||||
|
||||
|
||||
/**
|
||||
* Handles adding products to template via ajax.
|
||||
* Handles adding template categories to template via ajax.
|
||||
*/
|
||||
public static function ajax_add_wiaas_template_product() {
|
||||
|
||||
// check_ajax_referer( 'wc_bundles_add_bundled_product', 'security' );
|
||||
check_ajax_referer('wc_bundles_add_bundled_product', 'security');
|
||||
|
||||
$loop = intval($_POST['id']);
|
||||
$product_id = intval($_POST['product_id']);
|
||||
$title = $_POST['title'];
|
||||
$options = $_POST['options'];
|
||||
$product = wc_get_product($product_id);
|
||||
$title = $product->get_title();
|
||||
|
||||
|
||||
$response = array(
|
||||
'markup' => '',
|
||||
'message' => ''
|
||||
);
|
||||
|
||||
if ($product) {
|
||||
ob_start();
|
||||
include('views/html-wiaas-template-product.php');
|
||||
$response['markup'] = ob_get_clean();
|
||||
|
||||
wp_send_json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function ajax_wiaas_template_category_search() {
|
||||
|
||||
$term = ($_POST['term']);
|
||||
$response = array();
|
||||
|
||||
$terms = get_terms(array(
|
||||
'taxonomy' => 'template_category',
|
||||
'name__like' => $term
|
||||
));
|
||||
|
||||
foreach ($terms as $t) {
|
||||
error_log($t->name);
|
||||
error_log($t->term_id);
|
||||
$response[$t->term_id] = $t->name;
|
||||
|
||||
ob_start();
|
||||
include('views/html-wiaas-template-product.php');
|
||||
$response['markup'] = ob_get_clean();
|
||||
} else {
|
||||
$response['message'] = __('The selected product is invalid.', 'woocommerce-product-bundles');
|
||||
}
|
||||
|
||||
wp_send_json($response);
|
||||
|
||||
Reference in New Issue
Block a user