MOD to SHOW Ad Price or FREE AD in Step 1 NEW AD FORM
I thought the AD FORM that displays with form fields when a User first decides to Create an Ad needed some confirmation-- in other words, once the user has selected the Category of Ad and hit the Submit Button they now get the appropriate form BUT it lacks something.
What the present form lacks, in my opinion, is a "hand-holding assurance" of the PRICE before they even begin to fill out the form. And if the price is ZERO for this ad then it is nice to encourage them by reflecting boldly that this AD is FREE....whoopeee....fill out the form below with confidence.
What I created for myself and am offering at this time is a Mod to do the following:
If the Price for the Ad is 0, nothing, nada the user will see the following at the TOP of the form in step one--
This Ad in the "Artists in Residence" category is FREE!
If you would like to draw MORE ATTENTION to YOUR AD -- for just $7 you can feature your ad by clicking on the Featured Listing checkbox below.
The code dynamically reflects whatever category the user selected for their Ad and dynamically (if you are running the FEATURED AD option) continues with the Encouragement to consider making this Ad a FEATURED AD and tells the user how much you are charging for the Featured Listing option.
If in the ClassiPress dashboard you have NOT selected the Featured Listing option then that second paragraph will not display.
On the other hand, if the Ad category the user has selected has a Price and is NOT free, then the user sees the following header at the top of the Form fields--
Your Ad in the "Bars" category will cost only $7 Dollars
If you would like to draw MORE ATTENTION to YOUR AD -- for just $7 you can feature your ad by clicking on the Featured Listing checkbox below.
And, again, the Second Paragraph regarding the Featured Listing box will not show up if you do NOT offer the Featured Listing Option.
To me this makes me feel more confident that I am doing the "right thing" -- from the time I selected a Category that I thought was without cost, Free, and clicked the Submit button to the time the Form appears I will feel relieved that YES, INDEED, the Ad IS FREE.
And if the Ad is NOT Free then it will still confirm that I am where I wanted to be and the Ad will cost me XX dollars, pesos, euros, rubles, whatever.
Proceed at your own risk. Make a duplicate copy of step1.php before you begin and make sure it is named "copy of step1.php" or something to keep it from being overwritten while you modify step1.php.
And if you are new to modifying php files, remember from now on--PHP is NOT FORGIVING.
Code:
If you remove or add a <php? or a ?> here and there it WILL error and not produce the page you are expecting.
That's why you should make sure you paste exactly what I describe below.
Here is the mod for the last two versions--3.0.2 and 3.0.3 :
from the folder INCLUDES-- look for the folder FORM--
Inside the Form folder,
open step1.php and around line 80 you will see this code--
Code:
// show the form based on the category selected
// get the cat nice name and put it into a variable
$_POST['catname'] = get_cat_name($_POST['cat']);
?>
DO NOT DO ANYTHING with that code above...leave it alone!
IN the very next line, an EMPTY line, about line 84, you will PASTE the following complete code AFTER you have made sure that you are NOT DELETING that last
?> from the above code" -- Groovy...NOW do a Control-A or equivalent inside the following code and Control-C or equivalent to get everything---
Code:
<?php
// Vienna mod to show price or Free Ad confirmation
global $wpdb;
$thiscatid = $_POST['cat'];
// go get the option value or price
$sql = "SELECT option_value"
. " FROM wp_options"
. " WHERE option_name = 'cp_cat_price_$thiscatid '";
$results = $wpdb->get_results($sql);
foreach($results as $result) {
// put the form_cats into an array
$myprice = ($result->option_value);
if ($myprice == '0') {
echo '<h1>This Ad in the "' . $_POST['catname'] . '" category is <em>FREE!</em></h1>'; }
else {
echo '<h1>Your Ad in the "' . $_POST['catname'] . '" category will cost only <i>$' . $myprice .' Dollars</i></h1>'; }
if(get_option('cp_sys_feat_price')) {
echo'<li><h2>If you would like to draw <em>MORE ATTENTION to YOUR AD</em> -- for just '?> <?php echo cp_pos_price(get_option('cp_sys_feat_price'));?> <?php echo ' you can feature your ad by clicking on the <u>Featured Listing</u> checkbox below.</h2> </li><br>' ?>
<?php }
} ?>
<div class="clr"></div>
<?php // end of Vienna mod to show Category price with 1 ad pack and set for price per category ?>
Once it is pasted in and step1.php is saved just MAKE SURE THAT THE FOLLOWING LINE OF CODE STARTS EXACTLY LIKE THIS --
Code:
<form name="mainform" id="mainform" class="form_step" action="" method="post" enctype="multipart/form-data">
IF SO, then you should be safe and all of the code should work. At least, it does for me using PHP 5.