Sha256: b52cec78534fd0955a6a8b2463888318a15ccf156dbce3ed3597e688cabab1bc

Contents?: true

Size: 951 Bytes

Versions: 2

Compression:

Stored size: 951 Bytes

Contents

Spree.showProductAddedModal = function(product, variant) {
  var modalSelector = '.product-added-modal'
  var nameSelector = '.product-added-modal-product-details-name'
  var priceSelector = '.product-added-modal-product-details-price'
  var imageSelector = '.product-added-modal-product-image-container-image'
  var modalNoImageClass = 'product-added-modal--no-image'

  var price = variant.display_price
  var images = variant && variant.images.length > 0 ? variant.images : product.images
  var name = product.name
  var leadImage = images.length === 0 ? null : images[0]
  var $modal = $(modalSelector)

  $modal.find(nameSelector).text(name)
  $modal.find(priceSelector).text(price)

  if (leadImage !== null) {
    $modal
      .removeClass(modalNoImageClass)
      .find(imageSelector)
      .attr('src', leadImage.url_product)
      .attr('alt', leadImage.alt || name)
  } else {
    $modal.addClass(modalNoImageClass)
  }

  $modal.modal()
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_frontend-4.1.0.rc2 app/assets/javascripts/spree/frontend/views/spree/shared/product_added_modal.js
spree_frontend-4.1.0.rc1 app/assets/javascripts/spree/frontend/views/spree/shared/product_added_modal.js