One Page Checkout Issue - Billing is not defined - onepage:1772
-
16-10-2019 - |
Question
I have a problem with my one page checkout in my Magento 1.7.0.2 store. The store is not yet launched so all products are demo, but I can't seem to solve this issue. At page load I get
ReferenceError: billing is not defined @ line 1772
It's inline javascript. Here is the troublesome code below:
billing.onSave = function(evt){
new Ajax.Updater('onepage-checkout-shipping-method-additional-load', 'http://purchaseblack.com/checkout/onepage/getAdditional/', {onSuccess: function() {
this.nextStep(evt);
}.bind(this), evalScripts:true});
}.bindAsEventListener(billing);
}
When I then use this page, nothing else related to finishing the checkout process works, and I get more, new errors. My question is this:
How do I define billing? What file(s) do I need to edit to ensure that billing is defined properly and permanently?
Hopefully, this is the root of the other errors, and I can move on to the next set of issues.
This is my first post and I am pretty new, so bear with me here. If there is any info I can provide to help you help me, let me know.
Solution
You are missing the inline javascript code that defines the billing variable. Compare the billing.phtml files in your current theme against the ones in:
app\design\frontend\base\default\template\checkout\onepage\billing.phtml
app\design\frontend\base\default\template\persistent\checkout\onepage\billing.phtml
You should see similar to below:
<script type="text/javascript">
//<![CDATA[
var billing = new Billing('co-billing-form', '<?php echo $this->getUrl('checkout/onepage/getAddress') ?>address/', '<?php echo $this->getUrl('checkout/onepage/saveBilling') ?>');
var billingForm = new VarienForm('co-billing-form');
//billingForm.setElementsRelation('billing:country_id', 'billing:region', '<?php echo $this->getUrl('directory/json/childRegion') ?>', '<?php echo $this->__('Select State/Province...') ?>');
$('billing-address-select') && billing.newAddress(!$('billing-address-select').value);
var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'billing:postcode');
//]]>
</script>