Woocommerce get image galleries by product id

Posted by LaravelIndia - 1 year ago

show images from the product gallery programmatically in Woocommerce

There are 2 option available Like..

  • -Display the image URL
  • -Display Image instead of URL

    $product_id = '9898';
    $get_product = new WC_product($product_id);
    $attachment_ids = $get_product->get_gallery_attachment_ids();
    
    foreach( $attachment_ids as $attachment_id ) 
        {
          echo $Original_image_url = wp_get_attachment_url( $attachment_id );
          echo wp_get_attachment_image($attachment_id, 'full');
    
        }