Jump to content

Small "Add to cart" button on category


ChristosDs

Recommended Posts

Hi.

I'm using the code bellow on theme/catalog/_partials/miniatures/product.tpl file and some css to add an "Add to cart" button to classic theme but if I hide or remove the label the button doesn't work. When i click it, the popup opens but it doesn't add the product to cart basket.

    <div class="mini-add-to-cart">
      {if !$configuration.is_catalog}
            <form action="{$urls.pages.cart}" method="post" class="add-to-cart-or-refresh">
              <input type="hidden" name="token" value="{$static_token}">
              <input type="hidden" name="id_product" value="{$product.id}" class="product_page_product_id">
              <input type="hidden" name="qty" value="1">
              <button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit" {if $product.quantity < 1 }disabled{/if}>
                <i aria-hidden="true" class="material-icons shopping-cart">shopping_cart</i>{l s='Add to cart' d='Shop.Theme.Actions'}
              </button>
            </form>
          {/if}
      </div>

The only solutions I have found is to use a html symbol instead of the material  icon and label but I would prefer to use the material icon.

<button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit" {if $product.quantity < 1 }disabled{/if}>
✔
</button>

Any help would be much appreciated.

Screenshot 2021-10-22 141212.png

Link to comment
Share on other sites

Hi.

The code above works as it is. My problem is that because I'm trying to move the "Add to cart" button bellow the Wishlist button and remove the label  {l s='Add to cart' d='Shop.Theme.Actions'} so to keep only the material icon when i do that the button it stops adding the product to basket. If I remove the material icon and the label together and add for example the ✔ icon

<div class="mini-add-to-cart">
      {if !$configuration.is_catalog}
            <form action="{$urls.pages.cart}" method="post" class="add-to-cart-or-refresh">
              <input type="hidden" name="token" value="{$static_token}">
              <input type="hidden" name="id_product" value="{$product.id}" class="product_page_product_id">
              <input type="hidden" name="qty" value="1">
              <button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit" {if $product.quantity < 1 }disabled{/if}>
               <!--<i aria-hidden="true" class="material-icons shopping-cart">shopping_cart</i>{l s='Add to cart' d='Shop.Theme.Actions'}--></button>
            </form>
          {/if}
      </div>

the the code/button works. 

What I want to achieve is to keep using the material icon for the button.

Screenshot 2021-10-22 162954.png

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...