S
S
Sergey Voronezhev2013-05-26 21:42:01
CMS
Sergey Voronezhev, 2013-05-26 21:42:01

Need to tweak the cart module for VirtueMart 2 a little?

I'm trying to modify the "VirtueMart 2 Slide Cart"> module here, but I'm very new to javascript.
The following is necessary - set the condition under which the pop-up window will not be shown when hovering over the module.
The condition itself is when there are no goods in the cart.

I haven't posted my site yet, but if anything, here's a demo of the module www.linelab.org/virtuemart-templates/?template=shoplab


default.php

<?php<br>
/*<br>
 * Created on Feb 23, 2012<br>
 *<br>
 * Author: Linelab.org<br>
 * Project: mod_vmcart_j25<br>
 */<br>
<br>
defined('_JEXEC') or die('Restricted access');<br>
<br>
?><br>
<script type="text/javascript"><br>
window.addEvent('domready',function() {<br>
  document.id('vmCartModule').addEvent('mouseover',function() {<br>
    document.id('product_list').addClass('show_products');<br>
  });<br>
  document.id('vmCartModule').addEvent('mouseout',function() {<br>
    document.id('product_list').removeClass('show_products');<br>
  });<br>
  document.id('product_list').addEvent('mouseover',function() {<br>
    document.id('product_list').addClass('show_products');<br>
  });<br>
  document.id('product_list').addEvent('mouseout',function() {<br>
    document.id('product_list').removeClass('show_products');<br>
  });<br>
  document.id('vmCartModule').addEvent('click',function() {<br>
            document.id('product_list').addClass('show_products');<br>
        (function(){document.id('product_list').removeClass('show_products')}).delay(15000);<br>
        window.location.pathname='shop/cart';<br>
  });<br>
  document.id('product_list').addEvent('click',function() {<br>
            document.id('product_list').addClass('show_products');<br>
        (function(){document.id('product_list').removeClass('show_products')}).delay(15000);<br>
        window.location.pathname='shop/cart';<br>
  });<br>
  <?php<br>
  if(JRequest::getCmd('view')=='productdetails') {<br>
<br>
  }<br>
  ?><br>
});<br>
<br>
function remove_product_cart(elm) {<br>
  var cart_id=elm.getChildren('span').get('text');<br>
  if(document.id('is_opc')) {<br>
      remove_product(elm.getChildren('span').get('text'));<br>
  } else {<br>
  new Request.HTML({<br>
    'url':'index.php?option=com_virtuemart&view=cart&task=delete',<br>
    'method':'post',<br>
    'data':'cart_virtuemart_product_id='+cart_id,<br>
    'evalScripts':false,<br>
    'onSuccess':function(tree,elms,html,js) {<br>
      //jQuery(".vmCartModule").productUpdate();<br>
      mod=jQuery(".vmCartModule");<br>
      jQuery.getJSON(vmSiteurl+"index.php?option=com_virtuemart&nosef=1&view=cart&task=viewJS&format=json"+vmLang,<br>
        function(datas, textStatus) {<br>
          if (datas.totalProduct >0) {<br>
            mod.find(".vm_cart_products").html("");<br>
            jQuery.each(datas.products, function(key, val) {<br>
              jQuery("#hiddencontainer .container").clone().appendTo(".vmCartModule .vm_cart_products");<br>
              jQuery.each(val, function(key, val) {<br>
                if (jQuery("#hiddencontainer .container ."+key)) mod.find(".vm_cart_products ."+key+":last").html(val) ;<br>
              });<br>
            });<br>
            mod.find(".total").html(datas.billTotal);<br>
            mod.find(".show_cart").html(datas.cart_show);<br>
          } else {<br>
            mod.find(".vm_cart_products").html("");<br>
            mod.find(".show_cart").html("");<br>
            mod.find(".total").html("Cart empty");<br>
            //mod.find(".total").html(datas.billTotal);<br>
          }<br>
          mod.find(".total_products").html(datas.totalProductTxt);<br>
        }<br>
      );<br>
    }<br>
  }).send();<br>
  }<br>
}<br>
</script><br>
<style type="text/css"><br>
.show_products{<br>
  display:block !important;<br>
  position: absolute;<br>
  z-index: 100000;<br>
  background: url("/modules/mod_vm2cart/cartpop.png") no-repeat left top transparent;<br>
  width: <?php echo $params->def('width',150); ?>px;<br>
  min-height: 20px;<br>
}<br>
.vm_cart_products{<br>
background: url("/modules/mod_vm2cart/bgc.png") repeat-y left top transparent;<br>
    margin-top: 20px;<br>
    width: 336px;<br>
    font-size: 90%;<br>
    padding-left: 15px;<br>
    text-align: left;<br>
}<br>
#vmCartModule{<br>
    cursor: pointer;    <br>
    float: right;<br>
    width: <?php echo $params->def('width',150); ?>px;<br>
}<br>
#vmCartModule .show_products{<br>
right:25px;<br>
width:336px;<br>
}<br>
<br>
#vmCartModule .total, #vmCartModule .image {<br>
    float:center;<br>
}<br>
#vmCartModule .container{ <br>
width:300px; <br>
}<br>
#vmCartModule .product_row  {<br>
min-height: 70px;<br>
text-align: left;  <br>
width:336px; <br>
}<br>
#vmCartModule .image img {<br>
    border: 1px solid #ccc;<br>
    text-align:center;<br>
    height:60px;     <br>
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);<br>
}<br>
#vmCartModule .prices  {<br>
      float: right;<br>
    padding: 0 10px;<br>
    color: #000; <br>
}<br>
<br>
#vmCartModule .show_cart{<br>
    background:  url("/modules/mod_vm2cart/botct.png") no-repeat left top transparent;<br>
    border-top: 0 none;<br>
    font-size: 13px;<br>
    padding-right: 10px;<br>
    width: 336px;<br>
    height:52px;<br>
}<br>
#vmCartModule .show_cart a {<br>
    float: left;<br>
    padding-left: 36px;<br>
    padding-top: 11px;<br>
    line-height:normal;<br>
}<br>
#vmCartModule a:hover {<br>
color: #000;   <br>
}<br>
#vmCartModule .floatright{<br>
    text-align:center !important;<br>
    float:none;<br>
}<br>
</style><br>
<br>
<div class="vmCartModule" id="vmCartModule"><br>
  <div class="total" style="display:inline;" id="total"><br>
  <?php echo count($data->products)?($lang->_('COM_VIRTUEMART_CART_TOTAL').' : <strong>'. $data->billTotal.'</strong>'):Jtext::_('MOD_VM2_CART_CART_EMPTY'); ?><br>
  </div><br>
  <div style="clear:both"></div><br>
  <div id="hiddencontainer" style="display:none"><br>
    <div class="container"><br>
      <!-- Image line --><br>
      <div class="image"></div><br>
      <div class="prices" style="display:inline;"></div><br>
      <div class="product_row"><br>
        <span class="product_name"></span><br /><br>
        <span class="product_cart_id" style="display:none;"></span><br>
      </div><br>
      <div class="product_attributes"></div><br>
    </div><br>
  </div><br>
  <div id="product_list" style="display:none;"><br>
    <div class="vm_cart_products" id="vm_cart_products"><br>
      <div class="container"><br>
        <?php<br>
        foreach($data->products as $product) {<br>
          ?><br>
          <!-- Image line --><br>
          <div class="image"><?php echo $product["image"]; ?></div><br>
          <div class="prices" style="display:inline;"><?php echo $product["prices"]; ?></div><br>
          <div class="product_row"><br>
            <span class="product_name"><?php echo $product["product_name"]; ?></span><br /><br>
            <span class="product_cart_id" style="display:none;"><?php echo $product["product_cart_id"]; ?></span><br>
          </div><br>
          <?php<br>
          if(!empty($product["product_attributes"])) {<br>
            ?><br>
            <div class="product_attributes"><?php echo $product["product_attributes"]; ?></div><br>
            <?php<br>
          }<br>
          ?><br>
          <?php<br>
        }<br>
        ?><br>
      </div><div style="clear:both;"></div><br>
    </div><br>
  </div><br>
  <div style="display:none"><br>
    <div class="total_products"></div><br>
  </div><br>
  <input type="hidden" id="extra_cart" value="1" /><br>
</div>


Thanks in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Q
Quiz, 2013-05-27
@saintfr3ak

Make
console.log(InnerHTML);from my example or console.log(texter);from the second one and see what's inside this container :)

Q
Quiz, 2013-05-26
@Quiz

Does it work without jQuery at all? Trouble...
This is not the whole script. Better, of course, to look at a live example. So only guessing on coffee grounds.
And make the code human.

S
Sergey Voronezhev, 2013-05-27
@saintfr3ak

Here at the office In the module discussion thread, someone suggested the following

window.addEvent('domready',function() {
    var texter = $('total').innerHTML;
    texter = texter.replace(/\s/g, "");
    if (texter != "Cartisempty.") {
  
  document.id('vmCartModule').addEvent('mouseover',function() {
    document.id('product_list').addClass('show_products');
  });
  document.id('vmCartModule').addEvent('mouseout',function() {
    document.id('product_list').removeClass('show_products');
  });
  document.id('product_list').addEvent('mouseover',function() {
    document.id('product_list').addClass('show_products');
  });
  document.id('product_list').addEvent('mouseout',function() {
    document.id('product_list').removeClass('show_products');
  });
};

Didn't work, tried changing if (texter != "Cartisempty.") { to if (texter != "No shopping.") { and if (texter != "No shopping.") {

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question