weymeels weymeels - 1 year ago 88
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

Answer Source

Please call the code like this:

 $imgL=$product->get_image( 'shop_large', array(), true );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download