What is the correct way to implement the second function below? The first function works fine but the second function does not correctly invoke a custom field in WordPress whose key is _ni_cost_goods
.
Parse error: syntax error, unexpected '=', expecting variable (T_VARIABLE) in your code on line 11
<?php
function round_price( $price = null, $multiplier = 1, $nearest = 1, $minus = 0 ) {
if ( !empty( $price ) ) {
// strip any extra characters from price
$price = preg_replace("/[^0-9,.]/", "", $price);
// perform calculations
return ( round ( ( $price * $multiplier ) / $nearest ) * $nearest ) - $minus;
}
}
function add_gst( _ni_cost_goods = null, $multiplier = 1.1) {
if ( !empty( _ni_cost_goods ) ) {
// strip any extra characters from price
_ni_cost_goods = preg_replace("/[^0-9,.]/", "", _ni_cost_goods);
// perform calculations
return _ni_cost_goods * $multiplier;
}
}
?>