Menu Close
    Hire Us Request Quote Reading List Switch to Dark Mode

    How to perform action after PrestaShop javascript events in V1.7

    In this post, I am going to explain the PrestaShop javascript events called:

    -> On adding a product to the cart

    -> On Update/Remove the product in the cart

    -> On applying the filter on category product.

     

    PrestaShop provided the javascript variable, name as ‘prestashop’.

    Which is having the information related to the Prestashop javascript events:

    Many time we need to perform some action on adding the product in the cart.

    By using the below-listed method you can get the control on adding the product in the cart.

    In the PrestaShop theme, we use the following method to add the product in the cart

    prestashop.emit(
        'updateCart',
        {
            reason: dataset
        }
    );

    The dataset is having the information of the action to be performed and the required field in that action.

    On success, it will call the following callback function

    prestashop.on(
        'updateCart',
        function (event) {
            // Write your code here
            // Like your ajax function call or declaration 
       }
    }

    Now you are having the control after the product gets updated in the cart.

    Similarly, if we want to get the event after a category filter. We can use the following method:

    prestashop.on(
        'updateFacets',
        function (event) {
            // Write your code here
            // Like your ajax function call or decalration 
        }
    }

    Check the following link for more Prestashop javascript events:

    https://devdocs.prestashop.com/1.7/themes/reference/javascript-events/#dispatched-events

    So this is how we get control after Prestashop javascript events.

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close