save later item is not able to return to cart page displying error while doing that

save later item is not able to return to cart page displying error while doing that

Step 1: Extend the ProductList.DetailsLater.View.js File

  1. To extend the ProductList.DetailsLater.View.js file, which is located in the ProductList module, create a directory to store your custom module.
  2. Open this directory and create a subdirectory to maintain your customizations.Give this directory a name similar to the module being customized.
  3. In your new Product.List.Extension@1.0.0 module, create a subdirectory called JavaScript.Modules/extensions/Product.List.Extension@1.0.0/JavaScript
  4. In your new JavaScript subdirectory, create a JavaScript file to extend ProductList.DetailsLater.View.js .Name this file according to best practices. ProductList.DetailsLater.View.Extension.js
  5. Open this file and extend the addItemToCartHandler() method as shown in the following code

define(‘ProductList.DetailsLater.View.Extension’

, [
‘ProductList.DetailsLater.View’
, ‘underscore’
]
, function (
ProductListDetailsView
, _
)
{
‘use strict’;
_.extend(ProductListDetailsView.prototype,
{
addItemToCartHandler : function (e)
{
e.stopPropagation();
e.preventDefault();
if (this.application.getConfig(‘addToCartBehavior’) === ‘showCartConfirmationModal’)
{
this.cart.optimistic = null;
}
var self = this
, selected_product_list_item_id = self.$(e.target).closest(‘article’).data(‘id’)
, selected_product_list_item = self.model.get(‘items’).findWhere({
internalid: selected_product_list_item_id.toString()
})
, selected_item = selected_product_list_item.get(‘item’)
, selected_item_internalid = selected_item.internalid
, item_detail = selected_product_list_item.getItemForCart(selected_item_internalid, selected_product_list_item.get(‘quantity’), selected_item.itemoptions_detail, selected_product_list_item.getOptionsArray())
, add_to_cart_promise = this.addItemToCart(item_detail)
, whole_promise = jQuery.when(add_to_cart_promise, this.deleteListItem(selected_product_list_item)).then(jQuery.proxy(this, ‘executeAddToCartCallback’));

if (whole_promise)
{
this.disableElementsOnPromise(whole_promise, ‘article[data-item-id=”‘ + selected_item_internalid + ‘”] a, article[data-item-id=”‘ + selected_item_internalid + ‘”] button’);
}
}

}

});
}
);

Leave a comment

Your email address will not be published. Required fields are marked *