Jump to content

Edit History

ps8modules

ps8modules

On 7/15/2022 at 10:16 AM, Eliott_Crmx said:

Hello,
I need your help to understand how to retrieve the data from the product page form (product.tpl) sent by the 'add to cart' button (product-add-to-cart.tpl include).
Indeed, I would like to retrieve the value of a datepicker field, added under the entry dedicated to the quantity of the product page,
in order to save it in the ps_cart_product table....

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');
                        } 
                    }
                });  
            }
            
        }
    });

});

 

ps8modules

ps8modules

On 7/15/2022 at 10:16 AM, Eliott_Crmx said:

Hello,
I need your help to understand how to retrieve the data from the product page form (product.tpl) sent by the 'add to cart' button (product-add-to-cart.tpl include).
Indeed, I would like to retrieve the value of a datepicker field, added under the entry dedicated to the quantity of the product page,
in order to save it in the ps_cart_product table....

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');
                        } 
                    }
                });  
            }
            
        }
    });

});

 

ps8modules

ps8modules

On 7/15/2022 at 10:16 AM, Eliott_Crmx said:

Hello,
I need your help to understand how to retrieve the data from the product page form (product.tpl) sent by the 'add to cart' button (product-add-to-cart.tpl include).
Indeed, I would like to retrieve the value of a datepicker field, added under the entry dedicated to the quantity of the product page,
in order to save it in the ps_cart_product table....

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');
                        } 
                    }
                });  
            }
            
        }
    });

});

 

×
×
  • Create New...