Add custom icon before add to cart text

  • Posts: 441
  • Thank you received: 24
11 years 10 months ago #131171

I would like to add the fontawesome icon-shopping-cart before add to cart text using for example <span class="icon-shopping-cart"></span> but i do not know where to insert it.
In wich view and where should i insert the code, thank you

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
11 years 10 months ago #131195

Hi,
You'll just have to :
- Go to "Hikashop->Display->Views"
- Edit the "Cart" file of the "Product" view of your front-end template
- Add your image at the beginning of the file :

<img src="YourImgLink" alt="cart" height="42" width="42">

Please Log in or Create an account to join the conversation.

  • Posts: 441
  • Thank you received: 24
11 years 10 months ago #131220

I´ve already tried this, first line defined('_JEXEC') or die('Restricted access');
?><span class="icon-cart"></span>
and the button shows in the cart or mini cart
where i want it to be displayed is in the buttom add to cart in the product listing

Last edit: 11 years 10 months ago by condorazul.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
11 years 10 months ago #131229

Ok, so you'll just have to edit the "add_to_cart_listing" file of your "product" view of your front-end template via "Hikashop->Display->Views", and add you image at the end of the file.

Last edit: 11 years 10 months ago by Mohamed Thelji.

Please Log in or Create an account to join the conversation.

  • Posts: 441
  • Thank you received: 24
11 years 10 months ago #131240

in that case the icon is placed just after the button add to cart and i want it just before the text add to cart

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 10 months ago #131278

Hi,

So you have to place the desired code earlier in that view to have if before the button ;)

Please Log in or Create an account to join the conversation.

  • Posts: 441
  • Thank you received: 24
11 years 10 months ago #131343

I´m unable to find it all is php generated and dont have any idea in how to inser a <span> before the add to cart text and where it is.

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
11 years 10 months ago #131473

I don't think that you should edit any code for that.
Simply ass a translation override like that:
ADD_TO_CART="<span class='icon-cart'></span>Add to cart"

www.hikashop.com/download/languages.html#modify

Please Log in or Create an account to join the conversation.

  • Posts: 441
  • Thank you received: 24
11 years 10 months ago #131485

That was the first thing ive tried but perhaps i wrote it wrong going to try again. Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 441
  • Thank you received: 24
11 years 9 months ago #134341

it does not work, it displays <span class="uk-icon-cart"></span>

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
11 years 9 months ago #134379

Please make sure that you use simple quotes for the attributes of your HTML like I did in my example as double quotes are reserved for translation text delimitation.

Please Log in or Create an account to join the conversation.

  • Posts: 441
  • Thank you received: 24
11 years 9 months ago #134387

Im sure i copy paste you code what i wrote before it is what the page displays

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
11 years 9 months ago #134429

Please provide a screenshot of your modification and a link to the page with the button.

Please Log in or Create an account to join the conversation.

  • Posts: 441
  • Thank you received: 24
11 years 9 months ago #135042

here are the screenshots



Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
11 years 9 months ago #135153

It's probably because you're using a button and not a link for the buttons.
So if you change the "Button display method" option in the configuration, it should work fine.

Otherwise, you would have to change the line:
echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$max,$min);
like that:
echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$max,$min,'icon-cart');
in the file "quantity" via the menu Display>views in order to add the class directly to the submit button.

Please Log in or Create an account to join the conversation.

  • Posts: 37
  • Thank you received: 5
10 years 4 months ago #198847

Hi, I would like to bring up this subject again...

I have followed the instructions above... I want to add the font-awesome icon: <i class="fa fa-plus-square"></i> to before the "add to cart" button.

I added <i class="fa fa-plus-square"></i> to the language file to no avail.

Then I edited the view "quantity" changing:

echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$max,$min);

To...

echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$max,$min,'fa-plus-square');
in the file "quantity" via the menu Display>views in order to add the class directly to the submit button.

And this did not help either.

Any thoughts?

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
10 years 4 months ago #198859

Hi,

The second solution can't work because the class must be between "<i> ... </i>" html tags.

Then for the translation override, is the code displayed in the view ?
If it is, so it must maybe not be placed in a <a> tag, or you don't have the files displaying the icon loaded on your website.

Please Log in or Create an account to join the conversation.

Time to create page: 0.129 seconds
Powered by Kunena Forum