WooCommerce更改加载微调图标

Mr.*_* Jo 3 css php wordpress spinner woocommerce

IM试图更改WooCommerce加载微调图标。它在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);
}
Run Code Online (Sandbox Code Playgroud)

我试过使用自定义CSS更改loader.svg:

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

但是图标不会改变。所以我已经在Google上搜索了一下,并在这里找到了:

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' );
}
Run Code Online (Sandbox Code Playgroud)

但是加载微调器图标仍然相同。我该怎么做才能改变它?我不知道该怎么办...

Loi*_*tec 5

以下代码css规则在Woocommerce的最新版本中有效。我将它们嵌入到wp_head钩子中,因为它很容易测试:

您将使用此图标进行测试,并将您的活动子主题放在img目录下,重命名该文件my_spinner.gif

如果您使用主题而不是子主题,则将在代码中使用get_template_directory_uri()function get_stylesheet_directory_uri()

代码:

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
}
Run Code Online (Sandbox Code Playgroud)

代码进入您的活动子主题(或活动主题)的function.php文件中。经过测试和工作。

在此处输入图片说明

  • 就像一种魅力,给别人一个提示。有些结账表格可能有点长,而且您看不到旋转图标。将位置更新为“固定”,使其始终可见。 (2认同)