WooCommerce change loading spinner icon











up vote
3
down vote

favorite
1












IM trying to change the WooCommerce loading spinner icon. It's defined in the woocommerce.css:



.woocommerce .blockUI.blockOverlay::before {
height: 1em;
width: 1em;
display: block;
position: absolute;
top: 50%;
left: 50%;
margin-left: -.5em;
margin-top: -.5em;
content: '';
-webkit-animation: spin 1s ease-in-out infinite;
animation: spin 1s ease-in-out infinite;
background: url(../images/icons/loader.svg) center center;
background-size: cover;
line-height: 1;
text-align: center;
font-size: 2em;
color: rgba(0,0,0,.75);
}


I've tried changing the loader.svg with a custom css:



.woocommerce .blockUI.blockOverlay::before {
background: url(http://www.localhost.de/wp-content/uploads/custom-loader.svg) center center !important;
}


But the icon will not change. So I've googled a bit and found this here:



add_filter( 'woocommerce_ajax_loader_url', 'custom_loader_icon', 10, 1 );
function custom_loader_icon() {
return __( get_home_path() . 'wp-content/uploads/custom-loader.svg', 'woocommerce' );
}


But the loading spinner icon is still the same. What can I do to change it? I don't know what I should try now...










share|improve this question




























    up vote
    3
    down vote

    favorite
    1












    IM trying to change the WooCommerce loading spinner icon. It's defined in the woocommerce.css:



    .woocommerce .blockUI.blockOverlay::before {
    height: 1em;
    width: 1em;
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: -.5em;
    margin-top: -.5em;
    content: '';
    -webkit-animation: spin 1s ease-in-out infinite;
    animation: spin 1s ease-in-out infinite;
    background: url(../images/icons/loader.svg) center center;
    background-size: cover;
    line-height: 1;
    text-align: center;
    font-size: 2em;
    color: rgba(0,0,0,.75);
    }


    I've tried changing the loader.svg with a custom css:



    .woocommerce .blockUI.blockOverlay::before {
    background: url(http://www.localhost.de/wp-content/uploads/custom-loader.svg) center center !important;
    }


    But the icon will not change. So I've googled a bit and found this here:



    add_filter( 'woocommerce_ajax_loader_url', 'custom_loader_icon', 10, 1 );
    function custom_loader_icon() {
    return __( get_home_path() . 'wp-content/uploads/custom-loader.svg', 'woocommerce' );
    }


    But the loading spinner icon is still the same. What can I do to change it? I don't know what I should try now...










    share|improve this question


























      up vote
      3
      down vote

      favorite
      1









      up vote
      3
      down vote

      favorite
      1






      1





      IM trying to change the WooCommerce loading spinner icon. It's defined in the woocommerce.css:



      .woocommerce .blockUI.blockOverlay::before {
      height: 1em;
      width: 1em;
      display: block;
      position: absolute;
      top: 50%;
      left: 50%;
      margin-left: -.5em;
      margin-top: -.5em;
      content: '';
      -webkit-animation: spin 1s ease-in-out infinite;
      animation: spin 1s ease-in-out infinite;
      background: url(../images/icons/loader.svg) center center;
      background-size: cover;
      line-height: 1;
      text-align: center;
      font-size: 2em;
      color: rgba(0,0,0,.75);
      }


      I've tried changing the loader.svg with a custom css:



      .woocommerce .blockUI.blockOverlay::before {
      background: url(http://www.localhost.de/wp-content/uploads/custom-loader.svg) center center !important;
      }


      But the icon will not change. So I've googled a bit and found this here:



      add_filter( 'woocommerce_ajax_loader_url', 'custom_loader_icon', 10, 1 );
      function custom_loader_icon() {
      return __( get_home_path() . 'wp-content/uploads/custom-loader.svg', 'woocommerce' );
      }


      But the loading spinner icon is still the same. What can I do to change it? I don't know what I should try now...










      share|improve this question















      IM trying to change the WooCommerce loading spinner icon. It's defined in the woocommerce.css:



      .woocommerce .blockUI.blockOverlay::before {
      height: 1em;
      width: 1em;
      display: block;
      position: absolute;
      top: 50%;
      left: 50%;
      margin-left: -.5em;
      margin-top: -.5em;
      content: '';
      -webkit-animation: spin 1s ease-in-out infinite;
      animation: spin 1s ease-in-out infinite;
      background: url(../images/icons/loader.svg) center center;
      background-size: cover;
      line-height: 1;
      text-align: center;
      font-size: 2em;
      color: rgba(0,0,0,.75);
      }


      I've tried changing the loader.svg with a custom css:



      .woocommerce .blockUI.blockOverlay::before {
      background: url(http://www.localhost.de/wp-content/uploads/custom-loader.svg) center center !important;
      }


      But the icon will not change. So I've googled a bit and found this here:



      add_filter( 'woocommerce_ajax_loader_url', 'custom_loader_icon', 10, 1 );
      function custom_loader_icon() {
      return __( get_home_path() . 'wp-content/uploads/custom-loader.svg', 'woocommerce' );
      }


      But the loading spinner icon is still the same. What can I do to change it? I don't know what I should try now...







      php css wordpress woocommerce spinner






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 at 16:29









      LoicTheAztec

      81.3k125993




      81.3k125993










      asked Nov 21 at 20:14









      Mr. Jo

      375111




      375111
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          The following code css rules work in Woocommerce last version. I have embedded them in the wp_head hook as it's easy for testing:



          You will use this icon for testing, that you will put in your active child theme under an "img" directory, renaming the file my_spinner.gif.



          If you use a theme instead of a child theme, you will use get_template_directory_uri() function instead of get_stylesheet_directory_uri() in the code.



          The code:



          add_action('wp_head', 'custom_ajax_spinner', 1000 );
          function custom_ajax_spinner() {
          ?>
          <style>
          .woocommerce .blockUI.blockOverlay:before,
          .woocommerce .loader:before {
          height: 3em;
          width: 3em;
          position: absolute;
          top: 50%;
          left: 50%;
          margin-left: -.5em;
          margin-top: -.5em;
          display: block;
          content: "";
          -webkit-animation: none;
          -moz-animation: none;
          animation: none;
          background-image:url('<?php echo get_stylesheet_directory_uri() . "/img/my_spinner.gif"; ?>') !important;
          background-position: center center;
          background-size: cover;
          line-height: 1;
          text-align: center;
          font-size: 2em;
          }
          </style>
          <?php
          }


          Code goes in function.php file of your active child theme (or active theme). Tested and works.



          enter image description here






          share|improve this answer






























            up vote
            -1
            down vote













            Try following code. Assuming your custom-loader.svg is at root of "uploads" directory.



            add_filter( 'woocommerce_ajax_loader_url', 'custom_loader_icon', 10, 1 );
            function custom_loader_icon($str_replace) {
            $upload_dir = wp_upload_dir();
            $str_replace = $upload_dir['baseurl'].'/wp-content/uploads/custom-loader.svg'
            return $str_replace;
            }


            Hope this works.






            share|improve this answer





















            • Not working sorry. It's like the same I did but I just returned the URL directly
              – Mr. Jo
              Nov 21 at 21:07











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419831%2fwoocommerce-change-loading-spinner-icon%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            The following code css rules work in Woocommerce last version. I have embedded them in the wp_head hook as it's easy for testing:



            You will use this icon for testing, that you will put in your active child theme under an "img" directory, renaming the file my_spinner.gif.



            If you use a theme instead of a child theme, you will use get_template_directory_uri() function instead of get_stylesheet_directory_uri() in the code.



            The code:



            add_action('wp_head', 'custom_ajax_spinner', 1000 );
            function custom_ajax_spinner() {
            ?>
            <style>
            .woocommerce .blockUI.blockOverlay:before,
            .woocommerce .loader:before {
            height: 3em;
            width: 3em;
            position: absolute;
            top: 50%;
            left: 50%;
            margin-left: -.5em;
            margin-top: -.5em;
            display: block;
            content: "";
            -webkit-animation: none;
            -moz-animation: none;
            animation: none;
            background-image:url('<?php echo get_stylesheet_directory_uri() . "/img/my_spinner.gif"; ?>') !important;
            background-position: center center;
            background-size: cover;
            line-height: 1;
            text-align: center;
            font-size: 2em;
            }
            </style>
            <?php
            }


            Code goes in function.php file of your active child theme (or active theme). Tested and works.



            enter image description here






            share|improve this answer



























              up vote
              1
              down vote



              accepted










              The following code css rules work in Woocommerce last version. I have embedded them in the wp_head hook as it's easy for testing:



              You will use this icon for testing, that you will put in your active child theme under an "img" directory, renaming the file my_spinner.gif.



              If you use a theme instead of a child theme, you will use get_template_directory_uri() function instead of get_stylesheet_directory_uri() in the code.



              The code:



              add_action('wp_head', 'custom_ajax_spinner', 1000 );
              function custom_ajax_spinner() {
              ?>
              <style>
              .woocommerce .blockUI.blockOverlay:before,
              .woocommerce .loader:before {
              height: 3em;
              width: 3em;
              position: absolute;
              top: 50%;
              left: 50%;
              margin-left: -.5em;
              margin-top: -.5em;
              display: block;
              content: "";
              -webkit-animation: none;
              -moz-animation: none;
              animation: none;
              background-image:url('<?php echo get_stylesheet_directory_uri() . "/img/my_spinner.gif"; ?>') !important;
              background-position: center center;
              background-size: cover;
              line-height: 1;
              text-align: center;
              font-size: 2em;
              }
              </style>
              <?php
              }


              Code goes in function.php file of your active child theme (or active theme). Tested and works.



              enter image description here






              share|improve this answer

























                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                The following code css rules work in Woocommerce last version. I have embedded them in the wp_head hook as it's easy for testing:



                You will use this icon for testing, that you will put in your active child theme under an "img" directory, renaming the file my_spinner.gif.



                If you use a theme instead of a child theme, you will use get_template_directory_uri() function instead of get_stylesheet_directory_uri() in the code.



                The code:



                add_action('wp_head', 'custom_ajax_spinner', 1000 );
                function custom_ajax_spinner() {
                ?>
                <style>
                .woocommerce .blockUI.blockOverlay:before,
                .woocommerce .loader:before {
                height: 3em;
                width: 3em;
                position: absolute;
                top: 50%;
                left: 50%;
                margin-left: -.5em;
                margin-top: -.5em;
                display: block;
                content: "";
                -webkit-animation: none;
                -moz-animation: none;
                animation: none;
                background-image:url('<?php echo get_stylesheet_directory_uri() . "/img/my_spinner.gif"; ?>') !important;
                background-position: center center;
                background-size: cover;
                line-height: 1;
                text-align: center;
                font-size: 2em;
                }
                </style>
                <?php
                }


                Code goes in function.php file of your active child theme (or active theme). Tested and works.



                enter image description here






                share|improve this answer














                The following code css rules work in Woocommerce last version. I have embedded them in the wp_head hook as it's easy for testing:



                You will use this icon for testing, that you will put in your active child theme under an "img" directory, renaming the file my_spinner.gif.



                If you use a theme instead of a child theme, you will use get_template_directory_uri() function instead of get_stylesheet_directory_uri() in the code.



                The code:



                add_action('wp_head', 'custom_ajax_spinner', 1000 );
                function custom_ajax_spinner() {
                ?>
                <style>
                .woocommerce .blockUI.blockOverlay:before,
                .woocommerce .loader:before {
                height: 3em;
                width: 3em;
                position: absolute;
                top: 50%;
                left: 50%;
                margin-left: -.5em;
                margin-top: -.5em;
                display: block;
                content: "";
                -webkit-animation: none;
                -moz-animation: none;
                animation: none;
                background-image:url('<?php echo get_stylesheet_directory_uri() . "/img/my_spinner.gif"; ?>') !important;
                background-position: center center;
                background-size: cover;
                line-height: 1;
                text-align: center;
                font-size: 2em;
                }
                </style>
                <?php
                }


                Code goes in function.php file of your active child theme (or active theme). Tested and works.



                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 23 at 23:04

























                answered Nov 23 at 16:28









                LoicTheAztec

                81.3k125993




                81.3k125993
























                    up vote
                    -1
                    down vote













                    Try following code. Assuming your custom-loader.svg is at root of "uploads" directory.



                    add_filter( 'woocommerce_ajax_loader_url', 'custom_loader_icon', 10, 1 );
                    function custom_loader_icon($str_replace) {
                    $upload_dir = wp_upload_dir();
                    $str_replace = $upload_dir['baseurl'].'/wp-content/uploads/custom-loader.svg'
                    return $str_replace;
                    }


                    Hope this works.






                    share|improve this answer





















                    • Not working sorry. It's like the same I did but I just returned the URL directly
                      – Mr. Jo
                      Nov 21 at 21:07















                    up vote
                    -1
                    down vote













                    Try following code. Assuming your custom-loader.svg is at root of "uploads" directory.



                    add_filter( 'woocommerce_ajax_loader_url', 'custom_loader_icon', 10, 1 );
                    function custom_loader_icon($str_replace) {
                    $upload_dir = wp_upload_dir();
                    $str_replace = $upload_dir['baseurl'].'/wp-content/uploads/custom-loader.svg'
                    return $str_replace;
                    }


                    Hope this works.






                    share|improve this answer





















                    • Not working sorry. It's like the same I did but I just returned the URL directly
                      – Mr. Jo
                      Nov 21 at 21:07













                    up vote
                    -1
                    down vote










                    up vote
                    -1
                    down vote









                    Try following code. Assuming your custom-loader.svg is at root of "uploads" directory.



                    add_filter( 'woocommerce_ajax_loader_url', 'custom_loader_icon', 10, 1 );
                    function custom_loader_icon($str_replace) {
                    $upload_dir = wp_upload_dir();
                    $str_replace = $upload_dir['baseurl'].'/wp-content/uploads/custom-loader.svg'
                    return $str_replace;
                    }


                    Hope this works.






                    share|improve this answer












                    Try following code. Assuming your custom-loader.svg is at root of "uploads" directory.



                    add_filter( 'woocommerce_ajax_loader_url', 'custom_loader_icon', 10, 1 );
                    function custom_loader_icon($str_replace) {
                    $upload_dir = wp_upload_dir();
                    $str_replace = $upload_dir['baseurl'].'/wp-content/uploads/custom-loader.svg'
                    return $str_replace;
                    }


                    Hope this works.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 21 at 20:46









                    zipkundan

                    1,2111413




                    1,2111413












                    • Not working sorry. It's like the same I did but I just returned the URL directly
                      – Mr. Jo
                      Nov 21 at 21:07


















                    • Not working sorry. It's like the same I did but I just returned the URL directly
                      – Mr. Jo
                      Nov 21 at 21:07
















                    Not working sorry. It's like the same I did but I just returned the URL directly
                    – Mr. Jo
                    Nov 21 at 21:07




                    Not working sorry. It's like the same I did but I just returned the URL directly
                    – Mr. Jo
                    Nov 21 at 21:07


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419831%2fwoocommerce-change-loading-spinner-icon%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                    Calculate evaluation metrics using cross_val_predict sklearn

                    Insert data from modal to MySQL (multiple modal on website)