Home › Forums › General Issues › Automatic Calculation price per kilo › Reply To: Automatic Calculation price per kilo
Have you already created the ‘price_per_kilo’ field in the ACF fields for products?
If you change files in the plugin folder itself, then after the update all edits will disappear. So you need a new folder in your theme folder.
You need to create a new folder in your theme. Like this directory
/ wp-content / themes / your-child-theme / woocommerce / single-product /
Copy the price.php template from the / wp-content / plugins / woocommerce / templates / single-product directory to your new folder (/ wp-content / themes / your-child-theme / woocommerce / single-product /)
Open the price.php template and paste my code (don’t duplicate the global $product).
If the code doesn’t work try this. Оpen the product in the admin panel. An empty “price_per_kilo” field that you created at the beginning should appear. Make sure the price and weight (in delivery) are specified. Save the product. Go to the front-end of the product page, the code should work.
If there are any mistakes, write down which ones. Write down, step by step, what you are doing and in which files.
It works in my local project. Good luck!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
❓Ever wondered when and why ACF uses JSON instead of the database? Check out our summary of the most recent session of ACF Chat Friday for the answer, and make sure to register for the next session.— Advanced Custom Fields (@wp_acf) February 23, 2023
© 2023 Advanced Custom Fields.