"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'] ) ); $response = preg_replace( "/\r|\n/", "", $response ); //print_r($response);die(); $products = json_decode($response); // print_r($products);exit; $products = json_decode(json_encode($products), true); // SETUP ALL VARIABLES foreach( $products as $product ) : // TITLE $vars['title'] = $product['title']; // DESCRIPTION $vars['description'] = nl2br( $product['description'] ); // GLASSES OPTIONS $print_var['options'] = ''; $product_count = 0; foreach( $product['accessories'] as $option ) : if( isset( $option['selected'] ) ) : $vars['images']['main'] = $option['image']; if($varSelected ==""){$varSelected="";}else{ $varSelected = ' - ('.$option['title'].')'; } $featured = true; endif; $active = isset( $option['selected'] ) ? ' class="active"' : ''; $print_var['options'] .= '

' . $option['title'] . '

'; $product_count++; endforeach; if( ! isset( $featured ) ) : foreach( $product['accessories'] as $option ) : $vars['images']['main'] = $option['image']; break; endforeach; endif; foreach( $product['categories'] as $key => $cat ) $categories[] = $key; // TABLE $print_var['table'] = ''; if( isset( $product['table']['rows'] ) ) : $table = $product['table']['rows']; $print_var['table'] = '

Additional Product Information

 
'; foreach( $table as $rows ) : foreach( $rows as $key => $cell ) : if( count( array_intersect( $categories, array( 8, 9, 10, 14, 22 ) ) ) > 0 && in_array( $key, array( 'Item Name', 'Visor Size' ) ) ) : else : $width = count( array_intersect( $categories, array( 8, 9, 10, 14, 22 ) ) ) > 0 && $key == 'Description' ? '75%': $cell['width']; $print_var['table'] .= ''; endif; endforeach; break; endforeach; $print_var['table'] .= ''; foreach( $table as $rows ) : $print_var['table'] .= ''; foreach( $rows as $key => $cell ) : if( count( array_intersect( $categories, array( 8, 9, 10, 14, 22 ) ) ) > 0 && in_array( $key, array( 'Item Name', 'Visor Size' ) ) ) : else : $print_var['table'] .= ''; endif; endforeach; $print_var['table'] .= ''; endforeach; $print_var['table'] .= '
' . $key . '
' . $cell['value'] . '
'; endif; endforeach; $retro = ''; if($retro != ""){ $style1 = 'style="width:70%;float:left;"'; $style2 = 'style="width:30%;float:left;"'; }else{ $style1 = ''; $style2 = ''; } // SETUP HTML FOR PDF $html = '

' . $vars['title'] . $varSelected .'

' . $vars['description'] . '

'; if( $product_count > 1 ) $html .= '

More Photos


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