Woocommerce – Display variation price in the add to cart button

I am trying to add the variation price in the add to card button in a wordpress website with woocommerce.
I tried this solution but:

  • when a variation is selected it returns the price 2 times
  • if selecting an other variation, it doesn’t change the price, but add a new one behind it
  • it doesn’t remove the price when the selection is cleared.

Any idea of how to make it work?

I am expecting:

  • The price to display in the button when a variation is selected
  • The price to change when there is a change in the variation selection
  • The price to disapear when clearing the selection