diff --git a/js/crm.payment.js b/js/crm.payment.js
index e104b2fe887be2b44905c6e157c65a0c0ca3df32..62748442d31dd827fa1399177d12e30ff686c1cd 100644
--- a/js/crm.payment.js
+++ b/js/crm.payment.js
@@ -12,31 +12,33 @@
      */
     getTotalAmount: function() {
       var totalAmount = 0.0;
-      if (CRM.payment.isEventAdditionalParticipants()) {
+      if (this.isEventAdditionalParticipants()) {
         // We MUST return null because 0.0 is treated as a non-processor submit.
         // In this case the amount is not 0, we just don't know what it is yet.
         totalAmount = null;
       }
+      else if (this.getIsDrupalWebform()) {
+        // This is how webform civicrm calculates the amount in webform_civicrm_payment.js
+        $('.line-item:visible', '#wf-crm-billing-items').each(function() {
+          totalAmount += parseFloat($(this).data('amount'));
+        });
+      }
       else if (document.getElementById('totalTaxAmount') !== null) {
         totalAmount = parseFloat(this.calculateTaxAmount());
         this.debugging(this.name, 'Calculated amount using internal calculateTaxAmount()');
       }
-      else if (typeof calculateTotalFee == 'function') {
-          // This is ONLY triggered in the following circumstances on a CiviCRM contribution page:
-          // - With a priceset that allows a 0 amount to be selected.
-          // - When we are the ONLY payment processor configured on the page.
-          totalAmount = parseFloat(calculateTotalFee());
-        }
-        else if (this.getIsDrupalWebform()) {
-            // This is how webform civicrm calculates the amount in webform_civicrm_payment.js
-            $('.line-item:visible', '#wf-crm-billing-items').each(function() {
-              totalAmount += parseFloat($(this).data('amount'));
-            });
-          }
-          else if (document.getElementById('total_amount')) {
-              // The input#total_amount field exists on backend contribution forms
-              totalAmount = parseFloat(document.getElementById('total_amount').value);
-            }
+      else if ($("#priceset [price]").length > 0) {
+        // This is ONLY triggered in the following circumstances on a CiviCRM contribution page:
+        // - With a priceset that allows a 0 amount to be selected.
+        // - When we are the ONLY payment processor configured on the page.
+        $("#priceset [price]").each(function () {
+          totalAmount = totalAmount + $(this).data('line_raw_total');
+        });
+      }
+      else if (document.getElementById('total_amount')) {
+        // The input#total_amount field exists on backend contribution forms
+        totalAmount = parseFloat(document.getElementById('total_amount').value);
+      }
       this.debugging(this.name, 'getTotalAmount: ' + totalAmount);
       return totalAmount;
     },