Skip to content

Instantly share code, notes, and snippets.

@jrick1229
Created October 18, 2022 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrick1229/0d8f6f39fba9d889b73880f3cc70b7f2 to your computer and use it in GitHub Desktop.
Save jrick1229/0d8f6f39fba9d889b73880f3cc70b7f2 to your computer and use it in GitHub Desktop.
Round product price to nearest whole number based on an array of product IDs.
<?php
add_filter( 'raw_woocommerce_price', 'wcpb_round_to_nearest_whole_number' );
function wcpb_round_to_nearest_whole_number( $price ){
global $post;
$post_ID = $post->ID;
$page_id = array('123','345','398','80');
if(in_array($post_ID, $page_id)) {
return round( $price );
} else { return $price; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment