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_trendpress_ajax_woocommerce', 'trendpress_ajax_woocommerce' );
add_action( 'wp_ajax_trendpress_ajax_woocommerce', 'trendpress_ajax_woocommerce' );
function trendpress_ajax_woocommerce() {
$product_id = $_POST['product_id'];
$trendpress_feature_posts = new WP_Query(array('post_type' => 'product', 'post__in' => array($product_id)));
if($trendpress_feature_posts->have_posts()):
while($trendpress_feature_posts->have_posts()):$trendpress_feature_posts->the_post();
echo $trendpress_price = get_post_meta($product_id,'_regular_price',true);
$trendpress_woo_image_src = wp_get_attachment_image_src(get_post_thumbnail_id(),'');
$trendpress_woo_image_url = $trendpress_woo_image_src[0];?>
cart->get_cart_contents_count()); ?>