Not bof and eof from code block comments, but
if (!$orders_subtotal->EOF) { ...
See line 336 for an example of how this is done.
But looking up, it appears that variable might not even be set so you should be doing more:
$num_rows = 0;
if (isset($orders_subtotal) && !$orders_subtotal->EOF) {
And looking more deeply there are a bunch of issues with this logic:
line 434:
if (isset($_POST['order_subtotal']) == 1) {
should be
if (isset($_POST['order_subtotal'])) {
(same change in other places that is used - line 270, 277, 278, etc
line 149:
if (!empty($_POST['iso_country2_code']) == 1 || !empty($_POST['iso_country3_code']) == 1) {
should be
if (!empty($_POST['iso_country2_code']) || !empty($_POST['iso_country3_code']) ) {
same changes in other places that pattern is used - line 156, etc