Magento Forum

   
Custom Javascript addition
 
laserjumpstart
Jr. Member
 
Total Posts:  1
Joined:  2013-04-16
 

The company I support is switching to Magento and is wanting to create a new Custom Ordering form for our customers to purchase from.

The issue that comes with this though is that we have multiple drop-down menu’s that increase/decrease the price.  What happens however is that the customer is not allowed to send the order to the cart until the total order is above a certain price....in a nutshell it’s a minimum price checker....

I spent a fair bit of time and finally found a way to get part of the way but the issue I’m running into now is that I don’t know what “id” to call to check the current total price (after the user has changed some of the drop-downs) so that my javascript can say yes or no to proceeding to the cart.

I did something similar to this in a different setting so I am just wondering if I’ll be able to call it or if I’m going down the wrong track?

Below is the chunk of code that takes the productAddToCartForm.submit call from the submit button and validates it, and my if/else statements work, but again without knowing what to check against it’s just poking around in the dark.  Many Thanks in advance

var productAddToCartForm = new VarienForm('product_addtocart_form');
        
productAddToCartForm.submit = function(buttonurl{
        
var check1 document.getElementById('product-price').value;
        if(
check1 <=100)
        
{
        alert(
"Hello");
        
}
        else{
        alert
("Hi");
            if (
this.validator.validate(){
                
var form this.form;
                var 
oldUrl form.action;

                if (
url{
                   form
.action url;
                
}
                
var null;
                try 
{
                    this
.form.submit();
                
catch (e{
                }
                this
.form.action oldUrl;
                if (
e{
                    
throw e;
                
}

                
if (button && button != 'undefined'{
                    button
.disabled true;
                
}
            }
            }
        }
.bind(productAddToCartForm);

 
Magento Community Magento Community
Magento Community
Magento Community
 
IndiesWebs
Sr. Member
 
Avatar
Total Posts:  189
Joined:  2013-09-18
 

hi,
You can get the data of the span using the class. For that you have to use the J-query or JavaScript which is easy for getting the data using class.

JavaScript

var check1 documentgetElementsByClassName('product-price').value;
J-Query
var newprice = $(.price’).html();

Hope this will help you.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top