weymeels weymeels - 8 months ago 53
Ajax Question

how put my product->get_image in js

i need to put my $product->get_image in ajax but i don t know how to do

i want to put my $product->get_image(...) to $details = Array("..., "img"=>"$imgL");

here s my code


define('WP_USE_THEMES', false);
global $qode_options_theme16;
global $wp_query;


$args = array('post_type' => 'product','meta_value' => $sku);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post(); global $product;

$imgL=$product->get_image( $size = 'shop_large', $attr = array(), $placeholder = true );
$prix = $product->get_price();
$nom = $product->get_formatted_name();



$details = Array("prix"=>"$prix", "nom"=>"$nom", "sku"=>"$sku", "img"=>"$imgL");
echo json_encode($details);


thanks in advance


Please call the code like this:

 $imgL=$product->get_image( 'shop_large', array(), true );