"GET", //set request type post or get CURLOPT_POST =>false, //set to GET CURLOPT_USERAGENT => $user_agent, //set user agent CURLOPT_COOKIEFILE =>"cookie.txt", //set cookie file CURLOPT_COOKIEJAR =>"cookie.txt", //set cookie jar CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } $response = str_replace( ']', '}', str_replace( '[', '{', $response['content'] ) ); // print_r($response);die(); $response = preg_replace( "/\r|\n/", "", $response ); $products = json_decode($response); $products = json_decode(json_encode($products), true); // print_r($products);exit; // $products = $response['content']; // print_r($products['product']);exit; // SETUP ALL VARIABLES foreach( $products as $product ) : // TITLE $vars['title'] = $product['title']; if( $product['part_number'] ) $vars['title'] .= ' - ' . $product['part_number']; // DESCRIPTION $vars['description'] = $product['description']; // IMAGES $vars['images']['main'] = $product['product_image']; foreach( $product['filters'] as $filter ) : //if( isset( $filter['selected'] ) ) : if($filter['title'] == "") : if( $filter['image'] != '' ) $vars['images']['main'] = $filter['image']; $featured = true; endif; endforeach; foreach( $product['other_views'] as $image_key => $image_val ) : if( $image_val != '' ) : if( ! isset( $print_var['images']['other'] ) ) $print_var['images']['other'] = '

Other Views:

'; $print_var['images']['other'] .= ''; endif; endforeach; if( ! isset( $print_var['images']['other'] ) ) $vars['images']['other'] = ''; // FILTER VARIABLES $print_var['filters'] = $print_var['options'] = ''; $count = 0; foreach( $product['filters'] as $filter ) : $active = ( $filter['title'] == "" ) ? ' class="active"' : ''; if(isset($filter['thumbnail']) && $filter['thumbnail'] !=''){ $print_var['filters'] .= '

' . $filter['title'] . '

'; }elseif($filter['thumbnail'] =='' && !isset($filter['thumbnail'])){ $print_var['filters'] .= '

' . $filter['title'] . '

'; } $i = 0; $total = 0; //if( isset( $featured ) && isset( $filter['selected'] ) ) : if( isset( $featured ) && ($filter['title'] == "") ) : $vars['filter_title'] = $filter['title']; // $print_var['options'] .=''; elseif( $count == 0 && ! isset( $featured ) ) : $vars['filter_title'] = $filter['title']; foreach( $filter['options'] as $filter_key => $filter_value ) : if( $filter_value != 'false' ) $print_var['options'] .= '
' . $filter_key . ': ' . $filter_value . '
'; endforeach; endif; $count ++; endforeach; endforeach; // print_r($vars);die; // SETUP HTML FOR PDF $html = '

' . $vars['title'] . ' - ()

' . $vars['description'] . '

' . $print_var['images']['other'] . '

Additional Filter Options


'; //echo $html;exit; // echo ''; // echo $html; // print_a($products); include( __DIR__.'/../../../../pdf/mpdf.php' ); // echo __DIR__;die(); $mpdf = new mPDF('c'); $mpdf->SetDisplayMode('fullpage'); $stylesheets[] = file_get_contents( __DIR__.'/../../../../style/pdf-print.css'); foreach( $stylesheets as $stylesheet ) $mpdf->WriteHTML( $stylesheet, 1 ); $mpdf->WriteHTML( $html ); $mpdf->Output(); exit; ?>