Jump to content

Edit History

Piotr3qx

Piotr3qx

Hi ;)

Are you looking at correct ps_shoppingcart.js file? My file contains code that displays modal.

In line 65 you have a post request to which you must add 4 lines of code so it looks like this 

prestashop.on(
    'updateCart',
    function (event) {
      var refreshURL = $('.blockcart').data('refresh-url');
      var requestData = {};
      if (event && event.reason && typeof event.resp !== 'undefined' && !event.resp.hasError) {
        requestData = {
          id_customization: event.reason.idCustomization,
          id_product_attribute: event.reason.idProductAttribute,
          id_product: event.reason.idProduct,
          action: event.reason.linkAction
        };
      }
      $('#loader').fadeIn(); // show loader on screen 
      if (event && event.resp && event.resp.hasError) {
        $('#loader').fadeOut(); // hide loader in case of some error
        prestashop.emit('showErrorNextToAddtoCartButton', { errorMessage: event.resp.errors.join('<br/>')});
      }
      $.post(refreshURL, requestData).then(function (resp) {
        var html = $('<div />').append($.parseHTML(resp.preview));
        $('.blockcart').replaceWith($(resp.preview).find('.blockcart'));
        if (resp.modal) {
          $('#loader').fadeOut(); // hide loader before modal appearance
          showModal(resp.modal);
        }
      }).fail(function (resp) {
        $('#loader').fadeOut(); // hide loader in case of some error
        prestashop.emit('handleError', { eventType: 'updateShoppingCart', resp: resp });
      });
    }
  );

 

Piotr3qx

Piotr3qx

Hi ;)

Are you looking at correct ps_shoppingcart.js file? My file contains code that displays modal.

In line 65 you have a post request to which you must add 3 lines of code so it looks like this 

prestashop.on(
    'updateCart',
    function (event) {
      var refreshURL = $('.blockcart').data('refresh-url');
      var requestData = {};
      if (event && event.reason && typeof event.resp !== 'undefined' && !event.resp.hasError) {
        requestData = {
          id_customization: event.reason.idCustomization,
          id_product_attribute: event.reason.idProductAttribute,
          id_product: event.reason.idProduct,
          action: event.reason.linkAction
        };
      }
      if (event && event.resp && event.resp.hasError) {
        prestashop.emit('showErrorNextToAddtoCartButton', { errorMessage: event.resp.errors.join('<br/>')});
      }
      $.post(refreshURL, requestData).then(function (resp) {
        var html = $('<div />').append($.parseHTML(resp.preview));
        $('.blockcart').replaceWith($(resp.preview).find('.blockcart'));
        $('#loader').fadeIn(); // show loader on screen 
        if (resp.modal) {
          $('#loader').fadeOut(); // hide loader before modal appearance
          showModal(resp.modal);
        }
      }).fail(function (resp) {
        $('#loader').fadeOut(); // hide loader in case of some error
        prestashop.emit('handleError', { eventType: 'updateShoppingCart', resp: resp });
      });
    }
  );

 

×
×
  • Create New...