X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   jQuery mod on Xcart (countdown for special offers) (https://forum.x-cart.com/showthread.php?t=63443)

ricardomz 04-27-2012 08:14 AM

jQuery mod on Xcart (countdown for special offers)
 
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_rows0){
        
$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']==&& $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:-)

ricardomz 04-27-2012 09:26 AM

Re: jQuery mod on Xcart (countdown for special offers)
 
S.o.s.

cflsystems 04-27-2012 10:16 AM

Re: jQuery mod on Xcart (countdown for special offers)
 
Don't use {php} in template files - not a good practice.
What are you trying to accomplish with the second piece of code? The php code there will not do anything - the div will still show just the way you have it - empty. The first part posted is similar

ricardomz 04-27-2012 10:42 AM

Re: jQuery mod on Xcart (countdown for special offers)
 
Steve thanks for your reply,

The second part of the code shows the div whether the product has special offer or not. That's the idea. Initially I tried using css but it doesn't work...

And yes, I know that use {php} is not a good practice but by the moment I need to get this done asap. The issue is that the countdown it simply does'nt work. I don't know exactly if the jQuery library <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> casuses conflict with X-cart.



cflsystems 04-27-2012 11:10 AM

Re: jQuery mod on Xcart (countdown for special offers)
 
<!--countdown -->

<
div id="counter_tlapalero" >
<
div id="test"> </div>
</
div>

<!--/
coutdown -->

will load no matter what you have in the {php} since this code is not part of the {php} code but part of the template. And since you are using similar code in the first part there is nothing to load - the php 'if/else' you are putting out there will not do anything for the template - you have the html code as part of the template not as part of the php code

totaltec 04-29-2012 04:15 AM

Re: jQuery mod on Xcart (countdown for special offers)
 
You shouldn't be including the jquery library, jquery is used in current versions of X-cart already. I suspect you are including jquery twice.

ricardomz 04-30-2012 06:38 AM

Re: jQuery mod on Xcart (countdown for special offers)
 
Mike

Thanks for your reply.. I'm not an expert on jQuery, thats the reason why I buy the countdown. I just have a question. It doesnt matter the jQuery version I load??. The gallery will always works?.

Thankyou!!

ricardomz 04-30-2012 06:46 AM

Re: jQuery mod on Xcart (countdown for special offers)
 
Mike I've remove the line where I load jQuery and the issue is the same. The contdown it doesnt work.

ricardomz 04-30-2012 08:05 AM

Re: jQuery mod on Xcart (countdown for special offers)
 
Hey.. I found the error. If I remove the line <script type="text/javascript" src="http://store.com/var/cache/_c036329c826190c5a2b1124219029131.js"></script> where X-cart loads jQuery I mean, the count down works properly.

At the same time I need to load
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

What do you recommend me to do?.. Could somebody helpme?

Regards!!

cflsystems 04-30-2012 08:34 AM

Re: jQuery mod on Xcart (countdown for special offers)
 
Do not remove the line with the cached file - all js code needed for the cart to function is in there. You can try to turn off the Spped up tools in admin settings and see if it works. If XC loads jQuery version lower than the one required by your plugin then it will not work. You may need to replace it with your jQuery call


All times are GMT -8. The time now is 01:15 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.