PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Dynamically Adjusting Price Field on Product

  1. Hi,

    I am currently developing a paypal / gravity forms solution. Right now I'm experiencing a strange validation error. Basically, when I change the price on a product and the form validates it tells me that the price fields needs a correct value. However this only occurs when the price is DIFFERENT than the value upon the initial page load.

    That being said, I believe that the form is validating against the original price.

    Confirming my belief, when the form reloads and lets me know that the price needs a correct value, I can submit the form and it works as intended.

    Any insight on how I can overcome this problem??

    Any and all help is appreciated!

    http://development.cftacs.org/registration-forms/?fid=31&firstName=Chris&lastName=Carvache&courseTitle=Robbery%20Preparedness&courseNumber=Spring11Web115Web21010%2F20%2F2011&email=chris@northeastwebdesign.com&coursePrice=255.0000&delivery=Webinar&deliveryType=Live+Webinar&courseDate=October+20th%2C+2011&courseTime=11:00%20AM

    Sorry for the long link!

    Posted 13 years ago on Wednesday March 2, 2011 | Permalink
  2. So are you trying to dynamically change the price using custom code?

    There is code in place to make sure the price is not manipulated. This is for security reasons so users can't manipulate the price and purchase at a cheaper price by spoofing it.

    How are you dynamically changing the price currently? If you describe what you are doing, what hooks you are using or how you are doing it we may have a work around.

    Posted 13 years ago on Wednesday March 2, 2011 | Permalink
  3. Okay that makes sense... Basically I am using some jQuery calls to update the price. See below

    /********************************************
     * BEGIN: Webinar Logic **********************
     ********************************************/
    	// Hold the original price
    	$webinarOriginalPrice = $('#input_31_6').val();
    
    	function webinarChangeEvent(){
    		// Test to see if the name field is blank or not
    		$theString = ($('#input_31_30').val()) ? $('#input_31_30').val() : '';
    		$.trim($theString);
    		parseFloat($theString);
    		if ($theString.length > 0) {
    			// Change the PRICE!!! DAMNIT
    			$newPrice = 150 + ($webinarOriginalPrice * 1);
    			$howMuchText = '$' + ($newPrice * 1).toFixed(2);
    			$howMuchValue = ($newPrice * 1).toFixed(4);
    			$('[name="input_34.2"]').val($howMuchValue);
    			$('#input_31_34').text($howMuchText);
    		} else {
    			$howMuchText = '$' + (1 * $webinarOriginalPrice).toFixed(2);
    			$('[name="input_34.3"]').val(1);
    			$('#input_31_34').text($howMuchText);
    		}
    	}
    	// Attach event handler to select box that will update the price
    	$('#input_31_30').keyup(function(){
    		webinarChangeEvent();
    	});
    
    	// Do the same thing but during load
    	webinarChangeEvent();
    /********************************************
     * END: Webinar Logic ***********************
     ********************************************/
    
    /*******************************************
     * BEGIN: Submit button logic **************
     *******************************************/
    $(":submit").click(function(){
    	$(this).attr('disabled', 'disabled').val('Please wait...');
    });
    /*******************************************
     * END: Submit button logic ****************
     *******************************************/
    Posted 13 years ago on Wednesday March 2, 2011 | Permalink
  4. any idea on how to accomplish this? Would some implementations of a user definable price field be able to do this?

    Posted 13 years ago on Thursday March 3, 2011 | Permalink
  5. From what I understood by looking at the code, you want to change the price based on selections from a drop down field, correct?
    If that is the case, what you can do is add two different product fields to the form. Each with it's own price. You can then use conditional logic to hide/show the appropriate field based on the drop down values. Only the visible product field will be sent to paypal and recorded in the entry, so it would essentially act like the price was changed.

    Posted 13 years ago on Thursday March 3, 2011 | Permalink
  6. ahhhhhhhhh.... that is a great idea! I believe that would work... thanks so much!!

    Posted 13 years ago on Thursday March 3, 2011 | Permalink