• Hello! I want to change the icon used for the shopping cart on my header into a custom SVG icon.

    I tried following the steps written over here on how to change an icon to a different custom icon, but it doesn’t seem to work. I’m using a child theme instead of a code snipet plugin and I’m assuming that this code:

    add_filter( 'kadence_svg_icon', 'change_cart_icon', 10, 4 ); function change_cart_icon( $output, $icon, $icon_title, $base ) { if ( 'shopping-cart' === $icon ) { return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 19.5c0 .829-.672 1.5-1.5 1.5s-1.5-.671-1.5-1.5c0-.828.672-1.5 1.5-1.5s1.5.672 1.5 1.5zm3.5-1.5c-.828 0-1.5.671-1.5 1.5s.672 1.5 1.5 1.5 1.5-.671 1.5-1.5c0-.828-.672-1.5-1.5-1.5zm1.336-5l1.977-7h-16.813l2.938 7h11.898zm4.969-10l-3.432 12h-12.597l.839 2h13.239l3.474-12h1.929l.743-2h-4.195z"/></svg>'; } return $output; }

    Should be placed in my child theme’s function.php file. I’ve double checked the svg class to make sure that it is already correct, but it doesn’t work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @ohdearbambi,

    I added the custom filter to the Child Theme’s function.php file, and it works as expected. Here is a screencast for your reference:
    https://share.zight.com/6qu1ongn

    Could you please confirm if you added the <?php tag at the very beginning of your functions.php file? The code should look like this:

    <?php
    add_filter( 'kadence_svg_icon', 'change_cart_icon', 10, 4 ); function change_cart_icon( $output, $icon, $icon_title, $base ) { if ( 'shopping-cart' === $icon ) { return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 19.5c0 .829-.672 1.5-1.5 1.5s-1.5-.671-1.5-1.5c0-.828.672-1.5 1.5-1.5s1.5.672 1.5 1.5zm3.5-1.5c-.828 0-1.5.671-1.5 1.5s.672 1.5 1.5 1.5 1.5-.671 1.5-1.5c0-.828-.672-1.5-1.5-1.5zm1.336-5l1.977-7h-16.813l2.938 7h11.898zm4.969-10l-3.432 12h-12.597l.839 2h13.239l3.474-12h1.929l.743-2h-4.195z"/></svg>'; } return $output; }

    Cheers,
    Eze

    Hi there!

    It’s been a while since we heard back from you.

    If Eze helped and all is good, please proceed to mark this topic as resolved. Otherwise, let us know if we can help you further with this.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom cart icon’ is closed to new replies.