Sha256: d8c0d813b2925da3fff44a96eee11ca8ea2e77d1d9a0d57ce760285cfcbb9fda

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 Bytes

Contents

Deface::Override.new(
  virtual_path: 'spree/products/show',
  name: 'add_favorite_products_after_login',
  insert_after: '[data-hook="product_show"]',
  text: %Q{
    <%= javascript_tag do %>
      var getQueryParams = function(qs) {
        qs = qs.split('+').join(' ');

        var params = {},
          tokens,
          re = /[?&]?([^=]+)=([^&]*)/g;

        while (tokens = re.exec(qs)) {
          params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
        }

        return params;
      }

      $(document).ready(
        function(){
          var params = getQueryParams(document.location.search);
          if(params['favorite_product_id'] != null){
            $('#mark-as-favorite').attr('data-remote', true);
            $('#mark-as-favorite').trigger('click');
          }
        }
      );
    <% end %>
  }
)


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_favorite_products-2.1.1 app/overrides/add_favorite_products.rb