The title explains it pretty well. I'm trying to add a new shipping method (cost-based shipping) by extending the class. Here is the plugin body (The rest is in comments and contains the plugin info):
class WC_Cost_Based extends WC_Shipping_Method {
function __construct() {
$this->id = 'cost-based';
$this->method_title = __('Cost-Based', 'woocommerce');
}
function calculate_shipping() {
$rate = array(
'id' => $this->id,
'label' => $this->title,
'cost' => '10.99',
'calc_tax' => 'per_item'
);
// Register the rate
$this->add_rate( $rate );
}
}
function add_cost_based_method( $methods ) {
$methods[] = 'WC_Cost_Based';
return $methods;
}
add_filter('woocommerce_shipping_methods', 'add_cost_based_method');
The file is saved in .../wp-content/cost-based
Any idea why this error is popping up?