Skip to content
Advertisement

Add a dynamic fee based on a select field in WooCommerce Checkout

I am using Update fee dynamically based on radio buttons in Woocommerce checkout answer code solution that worked very well for me to add checkbox fields with a different price for each one, and the price changes are reflected in the checkout.

But I need some help: When I select a type of packaging with additional tax, it appears in the backend in the order area, but only shows the price, and I would like to show the title as well.

The checkbox options have:

JavaScript

How to make it show the name on the order? Also if it’s possible to change the checkboxes to select field instead?

Advertisement

Answer

I have made some changes to the original code that will:

  • Display a custom select field (instead of radio buttons input fields)
  • Display a custom error notice if customer has not selected a packing option
  • Display the selected packing type everywhere (on orders and email notifications)

The code:

JavaScript

Code goes in functions.php file of your active child theme (or active theme). Tested and works.

enter image description here

The error message when customer hasn’t chosen a packing option:

enter image description here

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement