News:

Looking for documentation? Take a look on our wiki

Main Menu

Info-Pop-Up with confirmation after click on "Add to cart"

Started by ksfbjoern, January 06, 2014, 12:09:47 PM

Previous topic - Next topic

ksfbjoern

Hello,

unfortunatly a manufacturer demands from us the following:
From a productdetail page shell be adding the product to the cart only possible if a pop-up-video provided be the manufacturer himself has been watched and certified.
Without certification it is not allowed to put the product into the cart.

The integration-javascript from the manufacturer is the following:

<script type="text/javascript">
        function openStokke() {
            window.open('http://media.stokke.com/tripptrapp/movie.aspx? '
            + 'lang=en'
            + '&RETURNSUCCESS=http://retailer.stokke.com/layouts/siibs/return.htm', null,
                'height=480,width=600,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes');
        }
        function returnStokkeSuccess() {
            addToCart();
        }

        function tryAddToCart(showTTinfo) {
            if (showTTinfo)
                openStokke();
            else
                addToCart();
        }
        function addToCart() {
            alert('Item is now added to the demoshop cart');
            // add code that adds the product to cart here, e.g. submit
        }

    </script>


I have modified it, but i have the problem that i am not sure which code i have to paste on the function addToCart. Actually the popup appears, but after clicking on "submit"-button the productdetail-site is reloaded in the pup-up-window, but after clicking on submit the product should be added to the cart.

function openStokke() {
window.open('http://media.stokke.com/tripptrapp/movie.aspx?LANG=de'
+ '&RETURNSUCCESS=http://www.babyonlineshop.ch/de/baby-zuhause/hochstuehle/stokke-tripp-trapp/stokke-tripp-trapp-hochstuhl-aqua-blue-detail.html', null,
'height=480,width=600,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes');
}
function returnStokkeSuccess() {
addToCart();
}
function tryAddToCart(showTTinfo) {
if (showTTinfo)
openStokke();
else
addToCart();
}
function addToCart() {
var data = "quantity[]="+qty+"&virtuemart_product_id[]="+pid
//data = encodeURIComponent(data);
jQuery.ajax({
type: "GET",
dataType: 'json',
url: "index.php?option=com_virtuemart&nosef=1&view=cart&task=addJS",
data: data,
success: function(data) {
alert(data);
}
});
}


I am not sure if the RETURNSUCCESS-URL is right, i have pasted the productdetail-url.

I have attached an image, that shows how it should work.



I hope someone has a hint for me.

Greetings

Björn





[attachment cleanup by admin]