Support » Plugin: WooCommerce RRP » Change the Product Price Text for multiple product IDs

  • Hi,

    Thank you for creating this plugin.

    I have successfully used the function code provided to change the “Product Price Text” for a certain product, however, I am wanting to apply this to more than one product ID, or the product category if this is possible.

    Please could you let me know what changes I would need to make to the function code in order for me to do this?

    Many thanks in advance.

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi,
    I’d be grateful if someone could please provide any help at all, as I still haven’t managed to resolve this?
    Thanks.

    Plugin Author Brad Davis

    (@brad-davis)

    Hi,

    If you can change it to one product using a product ID, then that is how you do it for more products so you should already have the solution. How many products are you changing it on?

    Cheers
    Brad

    Hi Brad,
    Thanks for your reply. I’d like to change this for 8 products only.
    I’ve used the code below:

    function change_before_regular_price( $woo_rrp_before_price ) {
    global $post;
    if ( ’96’ == $post->ID ) :
    return ‘Your new Product Price Text’;
    else :
    return $woo_rrp_before_price;
    endif;
    }
    add_filter( ‘woo_rrp_before_price’, ‘change_before_regular_price’ );

    This has worked perfectly for one product. However, I’m not sure how I can go about adding more than one product ID to this list. I have tried this for example:

    function change_before_regular_price( $woo_rrp_before_price ) {
    global $post;
    if ( ’96, 97, 98, 99, 100′ == $post->ID ) :
    return ‘Your new Product Price Text’;
    else :
    return $woo_rrp_before_price;
    endif;
    }
    add_filter( ‘woo_rrp_before_price’, ‘change_before_regular_price’ );

    However, this didn’t seem to work.

    Any further pointers would be much appreciated!
    Many thanks,
    Megan

    Plugin Author Brad Davis

    (@brad-davis)

    Hi Megan,

    Try passing multiple IDs in an array, eg:

    
    if ( array( 96, 97, 98, 100 ) == $post->ID ) :
    

    Let me know how you go.
    Cheers
    Brad

    • This reply was modified 1 year, 1 month ago by Brad Davis.
    Plugin Author Brad Davis

    (@brad-davis)

    Sorry Megan, think I gave you the wrong info above, try

    
    function change_before_regular_price( $woo_rrp_before_price ) {
    global $post;
    $test_array = array( 96, 97, 98, 99, 100 );
    if ( in_array( $post->ID, $test_array ) ) :
    return ‘new text’;
    else :
    return $woo_rrp_before_price;
    endif;
    }
    add_filter( ‘woo_rrp_before_price’, ‘change_before_regular_price’ );
    

    Hi Brad,

    Many thanks for this!
    This second piece of code you sent has worked perfectly for products with one variation (https://bulletbuildingproducts.co.uk/test/product/coxdome-flat-glass-electric-open/)

    however if they have more than one variation: (https://bulletbuildingproducts.co.uk/test/product/coxdome-trade-range-fixed/)

    It crosses off the text, but doesn’t replace it with the return ‘new text’;.

    Is there anything else I would need to add to this?

    Many thanks,
    Megan

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Change the Product Price Text for multiple product IDs’ is closed to new replies.