Skip to content

Instantly share code, notes, and snippets.

@m3esma
Created November 30, 2019 10:53
Show Gist options
  • Save m3esma/92e414a7e319a50775143f15b861294f to your computer and use it in GitHub Desktop.
Save m3esma/92e414a7e319a50775143f15b861294f to your computer and use it in GitHub Desktop.
WooCommerce - Custom pricing.
<?php
// Do NOT include the opening php tag.
// Set custom price.
function m3wc_woocommerce_product_get_price( $price, $product ) {
// Do any calculations or conditions here.
// For example1: Set a different price for each type of user.
// For example2: $price = $price + ( $price * 0.09 ); Adding 9% of the price.
return $price;
}
add_filter( 'woocommerce_product_get_price', 'm3wc_woocommerce_product_get_price', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment