Jump to content

Edit History

Eliott_Crmx

Eliott_Crmx

On 7/16/2022 at 11:24 AM, 4you.software said:

Hi.

Use JavaScript instead and capture the button click.

Eg:

$(document).ready(function() {

    prestashop.on('updateCart', function(e) {
        var deliverydate = document.getElementById('my-date-picker-value');

        if (typeof(deliverydate) != 'undefined' && deliverydate != null)
        {

            if (deliverydate.value !== ''){
                $.ajax({
                    type: "POST",
                    url: '/modules/my-module/function/my-function.php',
                    data:'idCart='+this.cart.id+'&deliveryDate='+deliverydate.value,
                    cache: false,
                    ajax: false,
                    success: function(data){
                        if (data !== ''){
                            console.log('done');
                        } 
                    }
                });  
            }
            
        }
    });

});

 

Hi, Thank you very much for your answer which already helps me a lot, however I don't know where to put this ajax script, in the tpl of the form, in the partial tpl included in the forms and in which the submit is located, or in ps_shoppingcart.js?
Could you explain me a little more the process ? I am a novice in JS...

 

psshoppingcart.PNG

productpl.PNG

productaddtocartpl.PNG

Eliott_Crmx

Eliott_Crmx

On 7/16/2022 at 11:24 AM, 4you.software said:

Hi.

Use JavaScript instead and capture the button click.

Eg:

$(document).ready(function() {

    prestashop.on('updateCart', function(e) {
        var deliverydate = document.getElementById('my-date-picker-value');

        if (typeof(deliverydate) != 'undefined' && deliverydate != null)
        {

            if (deliverydate.value !== ''){
                $.ajax({
                    type: "POST",
                    url: '/modules/my-module/function/my-function.php',
                    data:'idCart='+this.cart.id+'&deliveryDate='+deliverydate.value,
                    cache: false,
                    ajax: false,
                    success: function(data){
                        if (data !== ''){
                            console.log('done');
                        } 
                    }
                });  
            }
            
        }
    });

});

 

Hi, Merci beaucoup pour votre réponse qui m'aide déjà bien, cependant je ne sais pas où mettre ce script ajax, dans le tpl du formulaire, dans le tpl partial inclus dans les formulaire et dans lequel se situe le submit, ou dans ps_shoppingcart.js ?
Pourriez vous m'expliquer un peu plus la démarche ? je suis novice en JS...

 

psshoppingcart.PNG

productpl.PNG

productaddtocartpl.PNG

×
×
  • Create New...