• Resolved worldless

    (@worldless)


    Hi…

    I’ve already added some custom texts to regular and sale prices using the css ::after element and once I add the filter (at the bottom of this post) to show “Free” instead of zero price it also displays the price text right after the “Free” text. for example if the text for the regular price is “Dollar” then it displays “Free Dollar”. is it possible to remove the ::after element for the code below so that it can only show “Free”?

    add_filter( 'woocommerce_get_price_html', 'wpglorify_price_free_zero_empty', 100, 2 );

    function wpglorify_price_free_zero_empty( $price, $product ){

    if ( '' === $product->get_price() || 0 == $product->get_price() ) {
    $price = 'Free';
    }

    return $price;
    }

Viewing 1 replies (of 1 total)
  • Hi @worldless

    Thanks for reaching out!

    I understand that you are using the custom code above to replace the number 0 for the product price to Free instead, however, it also displays Free Dollars, correct?

    Can you please share with us the URL or link to your site so that we could check this further?

    Meanwhile, kindly be informed that custom coding is outside our scope of support, hence, I am leaving this thread open for a bit to see if anyone can chime in to help you out.

    For questions related to development and custom coding, your best bet is to ask on any of these channels for support. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.

    Hope this helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Show Free Price instead of 0’ is closed to new replies.