Hi,
I’d be grateful if someone could please provide any help at all, as I still haven’t managed to resolve this?
Thanks.
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
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 7 years, 8 months ago by
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