[Plugin: WooCommerce – excelling eCommerce] Need help with custom Shipping method class
-
I need to create a custom shipping method but the documentation on that point is a bit hazy to me. What I have sofar is this:
class WC_PostNL extends WC_Shipping_Method { function __construct() $this->id = 'postnl'; $this->method_title = "PostNL"; $this->title = "PostNL"; $this->enabled = true; } function calculate_shipping() { global $woocommerce; $weight = $woocommerce->cart->cart_contents_weight; if (!$weight || $weight < 0.25) { $postageNL = 3; $postageBE = 9.35; } elseif ($weight < 2) { $postageNL = 6.75; $postageBE = 13; } elseif ($weight < 5) { $postageNL = 6.75; $postageBE = 19.50; } elseif ($weight < 10) { $postageNL = 6.75; $postageBE = 25; } elseif ($weight < 20) { $postageNL = 12.20; $postageBE = 34; } else { $postageNL = 12.20; $postageBE = 40.46; } $country = $woocommerce->customer->get_shipping_country(); if ($country == "Nederland") { $this->shipping_total = $postageNL; } else { $this->shipping_total = $postageBE; } } }
But during checkout no shipping costs are shown. What am I missing?
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘[Plugin: WooCommerce – excelling eCommerce] Need help with custom Shipping method class’ is closed to new replies.