0

Using gem solidus 3.1.8

I would like to modify the CART button on the main_nav_bar to not include money and just show the qty.

`  Spree.fetch_cart('<%= j spree.cart_link_path %>')`

https://github.com/solidusio/solidus_frontend/blob/master/app/assets/javascripts/spree/frontend/cart.js

`Spree.fetch_cart = function(cartLinkUrl) {
  Spree.ajax({
    url: cartLinkUrl || Spree.pathFor("cart_link"),
    success: function(data) {
      $("#link-to-cart").html(data);
    }
  });
};`

In this bit of code data is returning the html code like:

`<a class="cart-info full" href="/cart">Cart: (1)  <span class='amount'><span class="money-currency-symbol">$</span><span class="money-whole">925</span><span class="money-decimal-mark">.</span><span class="money-decimal">15</span></span></a>`

I don't seem to be able to track down where data is getting generated from to do an override.

Jason
  • 3
  • 3
  • You could wrap it in a
    that uses CSS to hide the elements you don't want. Or pass the `Spree.fetch_cart('<%= j spree.cart_link_path %>` to a method that just grabs the quantity and returns just that.
    – Beartech Apr 20 '23 at 16:17

1 Answers1

0

I finally found that the html code was being returned by /core/app/helpers/spree/base_helper.rb

def link_to_cart(text = nil)
  text = text ? h(text) : t('spree.cart')
  css_class = nil

  if current_order.nil? || current_order.item_count.zero?
    text = "#{text}: (#{t('spree.empty')})"
    css_class = 'empty'
  else
    text = "#{text}: (#{current_order.item_count})  <span class='amount'>#{current_order.display_total.to_html}</span>"
    css_class = 'full'
  end

  link_to text.html_safe, spree.cart_path, class: "cart-info #{css_class}"
end

I took this and created my own helper to modify the html as I needed then modified the main_nav_bar to use my helpder instead

Jason
  • 3
  • 3