Answers for "Create a Confirmation Modal When a User Adds a Promotion Code"

0

Create a Confirmation Modal When a User Adds a Promotion Code

var Cart = container.getComponent('Cart');
Cart.cancelableOn('beforeAddPromotion', function confirmPromo ()
{
  var deferred = jQuery.Deferred();

  function resolvePromise ()
  {
    return deferred.resolve()
  };

  function rejectPromise ()
  {
    var key = ['errorMessage'];

    deferred.responseText = '{\"errorMessage\": \"The coupon was not added because you canceled the request\"}'

    return deferred.reject(deferred, key)
  };

  var confirmation = new ConfirmationView(
  {
    title: 'Add Promotion?'
  , body: 'Are you sure you want to add this promo code?'
  , autohide: true
  , callBack: resolvePromise
  , cancelCallBack: rejectPromise
  });

  cart.application.getLayout().showInModal(confirmation);

  return deferred
});
Posted by: Guest on August-03-2021

Code answers related to "Create a Confirmation Modal When a User Adds a Promotion Code"

Browse Popular Code Answers by Language