Dear friends,
I did a modification on store/skin/common_files/customer/service_head.tpl to include a counter for products with disccount.. The idea is that when the customer open a product with a special offer avilable the page shows a countdown and the user can buy that product on the desired time. For this mod I also change store/skin/common_files/customer/main/product.tpl
The modification using PHP is ready, and the countdown is a jQuery script I bought on codecanyon. But the issue is that when I'm include the jQuery files on the .tpl the javascript code doesnt work properly. In fact it seems that it doesnt recognize the divs to show the countdown. I did the same modification on a litecommerce store and it works properly.
Do you have some ideas or is a known issue that jQuery can not be included on the .tpl files of X-cart??..
Let me show you the code:
store/skin/common_files/customer/service_head.tpl
PHP Code:
{php}
session_start();
$_SESSION['bandera']=1;
//$bandera=1;
if(isset($_GET['productid'])){
$id_contador=$_GET['productid'];
$conexion = new MySQLi("...","...","...","...");
$sql="SELECT conditionid, param_id FROM xcart_offer_condition_params WHERE param_id LIKE '$id_contador'";
$resultado=$conexion->query($sql);
if($resultado->num_rows> 0){
$parametro=$resultado->fetch_array();
$condicion=$parametro[0];
$resultado->close();
$sql="SELECT conditionid, offerid, avail FROM xcart_offer_conditions WHERE conditionid LIKE '$condicion'";
if($resultado_dos=$conexion->query($sql)){
$oferta=$resultado_dos->fetch_array();
$ofer=$oferta[1];
$resultado_dos->close();
$sql="SELECT offerid, offer_end FROM xcart_offers WHERE offerid LIKE '$ofer'";
if($resultado_tres=$conexion->query($sql)){
$termina=$resultado_tres->fetch_array();
$fec=date("d/m/y",$termina[1]);
$fecha = explode("/", $fec);
$resultado_tres->close();
}else{
echo "error en tercer if";
}
}else{
echo "error en el segundo if";
}
}else{
$_SESSION['bandera']=0;
//echo "error en el primer if";
}
$conexion->close();
}else{
$_SESSION['bandera']=0;
}
{/php}
{php}
$actual=time();
if($_SESSION['bandera']==1 && $termina[1]>$actual){
{/php}
{literal}
<script type="text/javascript">
$(function(){
$("#test").fliptimer({year:20{/literal}{php} echo $fecha[2]; {/php}{literal},month:{/literal}{php} echo $fecha[1]; {/php}{literal},days:{/literal}{php} echo $fecha[0]; {/php}{literal},hours:0,minutes:0});
});
</script>
{/literal}
{php} }else{ {/php}
{literal}
<script type="text/javascript">
document.counter_tlapalero.style.display="none";
</script>
{/literal}
{php} } {/php}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://www.mysite.com/catalogo/assets/css/flip.css" />
<script type="text/javascript" src="http://www.mysite.com/catalogo/assets/js/fliptimer.js"></script>
{*
// Termina codigo para instalacion del contador ////////////////////////
*}
store/skin/common_files/customer/main/product.tpl
Here is the div #test where the countdown have to be loaded.
PHP Code:
{php}
$actual=time();
if($_SESSION['bandera']==1){
{/php}
<!--countdown -->
<div id="counter_tlapalero" >
<div id="test"> </div>
</div>
<!--/coutdown -->
{php} } {/php}
Hope someone could helpme!!.. I need to get this mod asap.
Regards