is_in_stock()) return;
$sale_price = get_post_meta($product->id, '_price', true);
$regular_price = get_post_meta($product->id, '_regular_price', true);
if (!empty($regular_price) && !empty($sale_price) && $regular_price > $sale_price){
$sale = ceil((($regular_price - $sale_price) / $regular_price) * 100);
$content = '-' . $sale . '%';
return $content;
}
}
add_action( 'wp_ajax_nopriv_construction_lite_ajax_woocommerce', 'construction_lite_ajax_woocommerce' );
add_action( 'wp_ajax_construction_lite_ajax_woocommerce', 'construction_lite_ajax_woocommerce' );
function construction_lite_ajax_woocommerce() {
$product_id = isset( $_POST['product_id'] ) ? sanitize_text_field( wp_unslash( $_POST['product_id'] ) ) : '';
$construction_lite_feature_posts = new WP_Query(array('post_type' => 'product', 'post__in' => array($product_id)));
if($construction_lite_feature_posts->have_posts()):
while($construction_lite_feature_posts->have_posts()):$construction_lite_feature_posts->the_post();
$construction_lite_price = get_post_meta($product_id,'_regular_price',true);
echo esc_html( $construction_lite_price );
$construction_lite_woo_image_src = wp_get_attachment_image_src(get_post_thumbnail_id(),'');
$construction_lite_woo_image_url = $construction_lite_woo_image_src[0];?>
cart->get_cart_contents_count()); ?>