News:

Support the VirtueMart project and become a member

Main Menu

Feature Request: Facebox configurable

Started by sscheidegger, November 21, 2011, 09:41:11 AM

Previous topic - Next topic

sscheidegger

Hi all

My customer for whom I'm setting up a website with VM was not happy about the facebox, that pops up when a product is being added to the cart. Atm I use a javascript hack to prevent that the facebox appears. It would be nice if it was configurable: Show facebox - yes or no, show facebox for how long - 0 seconds (forever) to x seconds.

Thanks!

clabbers

Hi, my customer doesn't like the facebox either. How did you fix this? Will people automaticly send to the cart? I'm not that a js editor, so could you help me?

sscheidegger

Hi

At the moment I'm using a dirty hack to prevent the facebox: I use an output override for VM productdetails. To the add to cart button (<input type=submit" name="addtocart" class="addtocart-button" value=...') I added the following javascript for click events:

onclick="javascript:
if(!document.getElementById('facebox')) {
    var fbx = document.createElement('div');
    fbx.setAttribute('id', 'facebox');
    fbx.style.visibility =  'hidden';
    document.body.appendChild(fbx);
}
if(!document.getElementById('facebox_overlay')) {
    var fbxo = document.createElement('div');
    fbxo.setAttribute('id', 'facebox_overlay');
    fbxo.style.visibility =  'hidden';
    document.body.appendChild(fbxo);
}"


If there are no facebox div elements, this code creates some with the same ID and sets the visibility to hidden. Like that the facebox should never show.

Not very nice, but I didn't have problems with it so far.

clabbers

#3
Hello. Thanks for the code. I've searched for the string but couldn't find it. Where can I find the file to edit this code (<input type=submit" name="addtocart" )?

I've tried it in ../components/com_virtuemart/views/productdetails/tmp/default.php on line 455:

<span class="addtocart-button">

<input type="submit" name="<?php echo $button_name ?>"  class="<?php echo $button_cls ?>" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>"/>

</span>

But that didn't do anything...

sscheidegger

Hi clabbers,

The line you posted is the correct one! Check the source code of your website to see if the line looks correct. If you don't see an error you need to debug the js code. I usually insert an alert(); every now and there to check until where the js code executes. And btw: Firefox with firebug is a very handy tool for debugging.

Good luck!

Stefan

clabbers

Do you place it directly in the line, like:


<input type="submit" name="<?php echo $button_name ?>"  class="<?php echo $button_cls ?>"
onclick="javascript:
if(!document.getElementById('facebox')) {
    var fbx = document.createElement('div');
    fbx.setAttribute('id', 'facebox');
    fbx.style.visibility =  'hidden';
    document.body.appendChild(fbx);
}
if(!document.getElementById('facebox_overlay')) {
    var fbxo = document.createElement('div');
    fbxo.setAttribute('id', 'facebox_overlay');
    fbxo.style.visibility =  'hidden';
    document.body.appendChild(fbxo);
}"
value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>"/>


sscheidegger


DaggaTora

Hi, I've made the change in the code but now the module cart doesn't upgrade the products quantity unless you navigate to other page.

any idea why?
Joomla 2.5.17 | VM2.0.26d | PHP 5.3.28

Studio 42

to overide javascript you can add in your template a script
eg.
Virtuemart.sendtocart = function (form){
MYCOOLCODE HERE
}

YOu can then use the code you wan't
We have provide a methode but it's possible to change this the way you want on rewrite the javascript

If you wan't more changes you can remove the vm2 javascripts on Config.