How to make the price not required in ClassifiedEngine

Updated on December 24, 2024 in No Category
0 on December 23, 2014

Hi guys,

This tutorial is written to help you make price not required in ClassifiedEngine Theme.
Adding these codes to your child theme/functions.php

<?php
    set_theme_mod( 'ad_require_fields' , array ('ad_location' , 'ad_category') );
	add_action('ce_before_footer_script', 'override_post_job');
	function override_post_job () { ?>
		<script type="text/javascript">
			(function ($) {
				$(document).ready(function () {
				if(typeof CE.Views.Post_Ad !== 'undefined') {
					CE.Views.Post_Ad.prototype.adFormValidate = function () {
						$("#step-auth form").validate({
							rules: {
								user_login : 'required',
								password: "required",
								repeat_password : {
									equalTo: "#password"
								},
								email : {
									required: true,
									remote : et_globals.ajaxURL+'?action=et_email_check_used'
									}
							}
						});
						/**
						* form validate
						*/
						$("#step-ad form").validate({
							ignore : "",
							rules: {
								post_title : "required",
								et_full_location : "required",
								ad_category : "required",
								post_content : "required"
							},
							errorPlacement: function(label, element) {
								// position error label after generated textarea
								if (element.is("textarea")) {
								label.insertAfter(element.next());
								} else {
								label.insertAfter(element)
								}
							}
						});
					}
				}
				if( typeof CE.Views.Modal_Edit_Ad !== 'undefined') {
					CE.Views.Modal_Edit_Ad.prototype.adFormValidate = function () {
						$("form.edit-ad-form").validate({
						rules: {
							post_title : "required",
							et_full_location : "required",
							ad_category : "required",
							post_content : "required"
							}
						});
					}
				}
				});
			})(jQuery);
		</script>
	<?php
	}
	// this filter convert price and display it as text
	add_filter('ce_convert_ad' , 'convert_ad');
	function convert_ad ($result) {
		$price = get_post_meta( $result->ID, 'et_price' , true );
		if(!is_numeric ($price) ) $result->price= $price ;
		return $result;
	}
?>

For mobile site, you should update mobile/template-post-ad.php. At line 34, remove et_price field required attribute.

 
  • Liked by
Reply