Edit the myCRED Suffix

Home Forums Community Edit the myCRED Suffix

This topic contains 7 replies, has 3 voices, and was last updated by  2KDesign 7 months, 1 week ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #19138

    Optain
    Newbie

    Hello,

    Today I have a question regarding to the suffix of myCRED.
    I want to edit the suffix in a way so that I can add a font awesome icon in it.
    The icon that I would like to use as my suffix in wordpress would be this one: <i class=”fa fa-diamond”></i>
    Is there maybe a code that I could add into my functions.php that allows me to edit the suffix of myCRED?

    And good example code of what I like to achieve with this would be the code from WooCommerce that you can add into your functions.php
    and create a new currency with its own suffix:

    add_filter( 'woocommerce_currencies', 'add_my_currency' );
    
    function add_my_currency( $currencies ) {
         $currencies['ABC'] = __( 'Diamonds', 'woocommerce' );
         return $currencies;
    }
    
    add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
    
    function add_my_currency_symbol( $currency_symbol, $currency ) {
         switch( $currency ) {
              case 'ABC': $currency_symbol = '<i class="fa fa-diamond"></i>'; break;
         }
         return $currency_symbol;
    }

    I hope you get the idea of what I’d like to achieve and maybe could help me with this,
    Marcel 🙂

    #19151

    2KDesign
    Member

    Cool idea! HTML in Suffix-Field is not enabled, but maybe it can be done by Gabriel?

    #19162

    Optain
    Newbie

    Hello,

    I worked on it myself yesterday a little bit and got it with the code that I posted above.

    Changed some settings in woocommerce and got it to work. 🙂

    Have a good day,
    Marcel

    #19163

    Gabriel Merovingi
    Legend

    You can not add html to the prefix or suffix fields in myCRED but if all points are presented the same way, you could instead use the mycred_format_creds filter and insert icons or even images as prefix or suffix for your points type.

    add_filter( 'mycred_format_creds', 'mycredpro_fontawesome_suffix', 10, 3 );
    function mycredpro_fontawesome_suffix( $layout, $creds, $mycred ) {
    
    	return $layout . ' <i class="fa fa-diamond"></i>';
    
    }
    

    Just make sure your suffix field in your settings are empty otherwise the above code will show it before the icon.

    #19164

    Optain
    Newbie

    Okey.
    I tried to paste the code that you provided into my functions.php and selected the currency of myCRED in the WooCommerce settings, nothing happend.
    And yes, I made sure that the suffix field in the settings of mycred are empty.

    Did I forgot something or why isnt it showing the icon after the prices?

    Marcel

    #19168

    Gabriel Merovingi
    Legend

    My code will add that diamond icon to points. So if you look at the myCRED > Log page or any myCRED widget or shortcode that shows points, the code will insert the diamond icon after the users balance.

    If you want to show this in WooCommerce then you have to select to use myCRED Points as your currency. Not adding in your own currency as you showed in your code. myCRED adds in your point as an option in the currency dropdown if you have selected to enable the Gateway add-on.

    #19198

    Optain
    Newbie

    Okey, thank you! 🙂

    #31707

    2KDesign
    Member

    Hello Gabriel,
    the provided code will add the diamond to all point types, not only the main one, how can i have a different icon for each point type?

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

Last edited March 2, 2016