When a wordpress order is made, make a request via https to generate the sending of cryptocurrencies

I’m creating a scenario:
When a wordpress order is made, it simultaneously makes a request via https to generate the sending of cryptocurrencies simultaneously.

The problem:
I need to make a calculation so that the result is the value in cryptocurrencies to be sent. My mother currency is the Brazilian real, people will buy in reais, so they need to make a calculation, the value of the purchase divided by the dollar rate (I’m going to enter it manually, I’m not going to add any API to pull it automatically, first I have to do function). This would be the first part of the calculation, something like this, for example:
(200.00 / 5.15) / 0.25

This would be the calculation, but I have found it very difficult to understand how make’s calculation logic works and I can’t find anything about it on YouTube, the courses available on the platform are not precise about calculations, I just need to do this simple mathematical expression.

For math functions, Make follows operator precedence. Operator precedence determines how operators are parsed concerning each other. Operators with higher precedence become the operands of operators with lower precedence.

For example, multiplication, division and remainders have the same precedence: Quote from “Operator precedence - JavaScript | MDN”

Any math functions that are grouped in parentheses (groups have the highest precedence) will be calculated first. So, in your example:

  • 1.total will be devided by 5.15 first, as it is in parentheses.
  • This result will be devided by 0.25 again

Make sure that the value of 1.total can be used in calculations.

2 Likes

After I asked the question here, I was wondering how I could solve my problem and doubts quickly, so I created a chatgpt for myself, and turned everything I could find about this platform and calculations into a document, I transcribed YouTube videos about it, because I couldn’t watch hours and hours of video for a simple solution, so let my problem serve as an example for others who came wanting to know about mathematical questions. Although Henk brought me an alternative solution, I found a simpler one. My chatgpt taught me that make uses the natural order of the equations, that is, I don’t need to put parentheses in the expression, just use the order that first solves one calculation and then the other as shown in the image below. Thanks Henk for the alternative solution, but I had already found a solution.

2 Likes

Hey there @Brayan_Peres :wave:

Wow, I’m impressed by the hard work and dedication you invested into this! Truly amazing work. :

Thank you for coming back here and sharing your findings with us. We appreciate it. :star:

2 Likes