dimanche 29 mars 2015

How to calculate dynamic price based on the volume of uploaded 3d file

Woocommerce Dynamic Price Based on the Volume of an Uploaded 3d File


this is really driving me crazy.


I run a small foundry business on WP+Woocommerce, and i'd need to dynamically calculate the price of my service, based on the volume of 3d objects the users upload.


I found on this website precious informations about how to calculate the volume of a 3d mesh, so i already wrote a php script to calculate it.


What is honestly completely obscure to me is which functions or hooks do I have to manipulate to tell woocommerce how to use it to calculate the final price (volume * basic price), like this:



  1. User uploads a 3d file and a script i already have calculates its volume and outputs its value in cubic units;

  2. woocommerce takes the basic price I set (eg. 4€/cm3) and multiply that by said volume value output;

  3. Woocommerce outputs the final price, and the user can add to cart;


I'm trying with these:



add_filter('woocommerce_get_price','change_price', 10, 2);
add_filter('woocommerce_get_regular_price','change_price', 10, 2);
add_filter('woocommerce_get_sale_price','change_price', 10, 2);


and then a custom function with $outputvolume * $price, but it doesn't work.


Thanks in advance to anybody who will help me even just understand where to start


Aucun commentaire:

Enregistrer un commentaire