Qry($sql); if ($RES->GetNumRows()==1) { $row=$RES->GetARow(); $PRODUCT = new Product($row['id']); $product_info=$PRODUCT->GetProductInfo(); // SET IMAGES FOR THE PRODUCT $product_images_folder=DIRECTORY_PUBLIC.PRODUCT_IMAGES_FOLDER_NAME."/"; $m_image_location=$product_images_folder.$product_info['image_m']; $l_image_location=$product_images_folder.$product_info['image_l']; if ($product_info['image_m'] && file_exists($m_image_location) && !is_dir($m_image_location)) { if ($product_info['image_l'] && file_exists($l_image_location) && !is_dir($l_image_location)) { $large_image_size=getimagesize($l_image_location); $product_info['enlarge_image_popup_width']=$large_image_size[0]+40; $product_info['enlarge_image_popup_height']=$large_image_size[1]+60; } else $product_info['image_l']=''; } else { $product_info['image_m']=''; $product_info['image_l']=''; } // FIND OUT IF THIS IS A PRE ORDER ITEM $datediff=datediff($product_info['date_available'],DATE_NOW,'d'); if ($datediff['d'] > 0) $SMARTY->Assign('pre_order_item',true); $SMARTY->Assign('product_info',$product_info); // GET CATEGORY INFORMATION $sql="SELECT c.* FROM categories c, products_to_categories m WHERE m.product_id=".$product_info['id']." AND m.category_id=c.id"; $RES=$DB->Qry($sql); $category_info=$RES->GetARow(); $SMARTY->Assign('category_info',$category_info); // GET REVIEW AND RATING INFORMATION $sql="SELECT SQL_CALC_FOUND_ROWS reviews.id, reviews.* FROM reviews WHERE products_id='".$product_info['id']."' AND active='y' ORDER BY last_modified DESC LIMIT 10"; $REVIEWS_RES=$DB->Qry($sql); $total_rating=0; if ($REVIEWS_RES->GetNumRows()) { $sql="SELECT FOUND_ROWS()"; $GET_TOTAL_ROWS_RES=$DB->Qry($sql); $total_reviews=$GET_TOTAL_ROWS_RES->GetCell(); while ($row=$REVIEWS_RES->GetARow()) { $row['review_text']=ereg_replace("\r\n","
",$row['review_text']); $sql="SELECT id FROM reviews WHERE customers_id='".$row['customers_id']."'"; $CUSTOMERS_REVIEWS_RES=$DB->Qry($sql); $row['customers_total_reviews']=$CUSTOMERS_REVIEWS_RES->GetNumRows(); $sql="SELECT first_name,last_name FROM customers WHERE id='".$row['customers_id']."'"; $CUSTOMERS_RES=$DB->Qry($sql); $customers_row=$CUSTOMERS_RES->GetARow(); $row['customers_name']=$customers_row['first_name']." ".$customers_row['last_name']; $row['last_modified']=date2human($row['last_modified'],'medium'); $row['review_rating_text']=substr($row['review_rating'],0,1).".".substr($row['review_rating'],1,2); $reviews[]=$row; } // CALCULATE REVIEWS AND RATINGS $overall_rating=$product_info['overall_rating']; $overall_rating_text=substr($overall_rating,0,1).".".substr($overall_rating,1,1); $SMARTY->Assign('total_reviews',$total_reviews); $SMARTY->Assign('overall_rating',$overall_rating); $SMARTY->Assign('overall_rating_text',$overall_rating_text); $SMARTY->Assign('reviews',$reviews); } // CALCULATE COST SAVINGS if ($product_info['special_price']) { // SET THE SPECIAL OFFER PRICE $SMARTY->Assign('special_price',$product_info['special_price']); $you_save=$product_info['rrp']-$product_info['special_price']; } else $you_save=$product_info['rrp']-$product_info['price']; $you_save_pct=floor(($you_save/$product_info['rrp'])*100); $SMARTY->Assign('you_save',$you_save); $SMARTY->Assign('you_save_pct',$you_save_pct); // CALCULATE DELIVERY $delivery_price=0; $SMARTY->Assign('delivery_price',$delivery_price); // GET PRODUCT ATTRIBUTES $sql="SELECT po.id as option_id,po.type as option_type,pa.default as att_default, pa.id as att_id, po.id as option_id, pa.price as att_price, pa.price_prefix as att_price_prefix,po.name as options_name,pv.name as values_name FROM products_attributes pa, products_options po, products_options_values pv WHERE pa.options_id=po.id AND pa.values_id=pv.id AND pa.products_id='".$product_info['id']."' ORDER BY pa.sort_order ASC"; $RES=$DB->Qry($sql); while ($row=$RES->GetARow()) { $product_attributes[$row['options_name']]['id']=$row['option_id']; $product_attributes[$row['options_name']]['type']=$row['option_type']; $product_attributes[$row['options_name']]['attribute_list'][$row['values_name']]=$row; } $SMARTY->Assign('product_attributes',$product_attributes); // GET PRODUCT INFO BOXES $sql="SELECT * FROM products_info_boxes WHERE products_id='".$product_info['id']."' AND active='y' ORDER BY sort_order,title ASC"; $RES=$DB->Qry($sql); while ($row=$RES->GetARow()) $products_info_boxes[]=$row; $SMARTY->Assign('products_info_boxes',$products_info_boxes); // BUILD THE BREADCRUMB $CATEGORY = new Category($category_info['alias']); if ($parent_cats=$CATEGORY->aCategoryParentsInfo) { foreach ($parent_cats as $cat) { $cat['link']=HTTP_SERVER.$cat['alias']."/CategoryHome.html"; if ($cat['breadcrumb_name']) $cat['page_name']=$cat['breadcrumb_name']; $bc[]=$cat; } } $bc_size=count($bc); if ($product_info['breadcrumb_name']) $bc[$bc_size]['page_name']=$product_info['breadcrumb_name']; else $bc[$bc_size]['page_name']=$product_info['name']; $bc[$bc_size]['alias']=$product_info['alias']; $SMARTY->Assign('breadcrumb',$bc); // BUILD META TAGS if ($product_info['meta_title']) $meta_title=$product_info['meta_title']; else $meta_title=$product_info['name'].": ".$category_info['page_name']; $SMARTY->SetMetaTitle($meta_title); $SMARTY->SetMetaDesc($product_info['meta_desc']); $SMARTY->SetMetaKeyw($product_info['meta_keyw']); $SMARTY->ShowHeader(); $SMARTY->ShowBody('product.tpl'); $SMARTY->ShowFooter(); } else { // IF THE PRODUCT CANNOT BE FOUND REDIRECT THE USER TO THE PRODUCT NOT FOUND PAGE header("Location: ".HTTP_SERVER."product-not-found.html"); exit; } ?>