WooCommerce – Sort shipping options / methods / services by shipment cost

WooCommerce doesn't sort the shipping methods / services by default while showing it on cart and checkout page. Code Snippet for sorting the shipping options by cost. Below code snippet will help to sort the shipping options by shipping cost. Screenshot - Shipping Options - Default view. Screenshot - Shipping Options - Sorted view.   .button { border-radius: 5px; background-color: #5472D2; border: none; color: #FFFFFF; text-align: center; font-size: 35px; padding: 20px; width: 200px; transition: all 0.3s; [...]

WooCommerce – Add an additional fee based on State

Below code snippet will help to add an additional charge based on state. The example given is specific to the state Maharastra (India). This snippet will add an additional charge of amount 10 to the order if the specified state is chosen. Value of the variable $state and the text 'Additional Charge' could be changed as per your business case. Screenshot - Additional Charge on Checkout Page

Enable shipping state field for specific countries during WooCommerce Checkout

During WooCommerce checkout, there are number of countries (Afghanistan, Poland, etc ) for which state field does not show up while entering billing and shipping address. The complete list of states can be found by referring the function "load_country_states" from WooCommerce code class-wc-countries.php. Now, if you want to enable state field for some reason, what should you do? WooCommerce doesn't provide an option in settings to achieve this. Below code snippet will help you to solve this problem. Code Snippet to enable State [...]