• Resolved milora

    (@milora)


    Hi, I was looking for a way to eliminate the price variations of the products by replacing them with the text “starting from:”, I found this code on a forum and even if I am not familiar with codes I have entered it and it works fine except in the case of discounted products.
    Can anyone tell me if they see any errors in this code?
    Or maybe if someone can show me a code that works, thank you.

    function blogwp_wc_format_change( $price, $product ) {

    $text = sprintf(‘%s: ‘, __(‘Starting from’, ‘iconic’));

    $price_min_regular = $product->get_variation_regular_price( ‘min’, true );
    $price_min_sale = $product->get_variation_sale_price( ‘min’, true );
    $maximum_price = $product->get_variation_price( ‘max’, true );
    $minimum_price = $product->get_variation_price( ‘min’, true );

    $price = ( $price_min_sale == $price_min_regular ) ? wc_price( $price_min_regular ) : ” . wc_price( $price_min_regular ) . ” . ” . wc_price( $price_min_sale ) . ”;

    return ( $minimum_price == $maximum_price ) ? $price : sprintf(‘%s%s’, $text, $price);

    }

    add_filter( ‘woocommerce_variable_sale_price_html’, ‘blogwp_wc_format_change’, 10, 2 );
    add_filter( ‘woocommerce_variable_price_html’, ‘blogwp_wc_format_change’, 10, 2 );

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi there 👋

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers.

    Thread Starter milora

    (@milora)

    Hi, now I have solved the problem and I want to share it in case anyone needs it.
    I added this code to the Functions.php file, the only problem is that now “Starting from” also appears instead of the canceled price when there is a discount on the product.
    If I can solve it I will share that solution as well.

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    That’s wonderful! Thank you for sharing it 🙂

    Great! I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Cheers!

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

The topic ‘“Starting from” text’ is closed to new replies.