• Resolved claire1108

    (@claire1108)


    I’m trying to add the word ‘From’ before the price on the category page and the product page but only on external products.

    I can add the text to all products but this effects other changes I have made that. Is it possible to add the text to only external products?

Viewing 6 replies - 1 through 6 (of 6 total)
  • I can add the text to all products

    how do you do this? if it is via code you can easily apply an if statement and check on the product type

    Regards

    Thread Starter claire1108

    (@claire1108)

    “I can add the text to all products

    how do you do this? if it is via code you can easily apply an if statement and check on the product type.”

    Yes, I can do this in the functions PHP, I thought I should be able to add an if statement but couldn’t figure out how to do it (am new to wordpress, much happier with VB/excel code)

    Thanks

    • This reply was modified 5 years, 2 months ago by claire1108.
    • This reply was modified 5 years, 2 months ago by claire1108.
    • This reply was modified 5 years, 2 months ago by claire1108.

    ok, can you share that piece of code?

    Thread Starter claire1108

    (@claire1108)

    This is what I have for all products:

    `function change_product_price_html($price){

    $newPrice = “From “;
    $newPrice .= $price;
    $newPrice .= ” ex VAT”;

    return $newPrice;
    }

    add_filter(‘woocommerce_get_price_html’, ‘change_product_price_html’);

    function change_product_price_html( $price, $product ) {
        // Get product type
        $product_type = $product->get_type();
    	
        if ( $product_type == 'external' ) {
            $price = 'From ' . $price . ' ex VAT';
        }
    
        return $price; 
    }
    add_filter( 'woocommerce_get_price_html', 'change_product_price_html', 10, 2 ); 

    We haven’t heard back from you in a while, so I’m going to mark this as resolved. Feel free to start a new thread if you have any further questions!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding text to external product price’ is closed to new replies.