• I inherited a wp-ecommerce site – an am having a problem with the checkout. It has been completely customised (see below). I need at least the email to be mandatory. So i have ticked it to be mandatory in the store setteings, but now if someone fills in the form, and the email is not filled in, it doesn’t submit the form, but also does not have a warning about what was not filled in. How can I add a the warning?

    https://www.unlabelledwine.co.za/unlabeled-wine/

    <?php
    global $wpsc_cart, $wpdb, $wpsc_checkout, $wpsc_gateway, $wpsc_coupons;
    $wpsc_checkout = new wpsc_checkout();
    $wpsc_gateway = new wpsc_gateways();
    $wpsc_coupons = new wpsc_coupons($_SESSION['coupon_numbers']);
    //echo "<pre>".print_r($wpsc_cart,true)."</pre>";
    if(wpsc_cart_item_count() > 0) :
    ?>
    <img src="<?php bloginfo('template_url'); ?>/images/dashed-seperator.png">
    <p style="margin-top:10px;"><strong><?php echo __('Please review your order', 'wpsc'); ?></strong></p>
    <table class="productcart">
    	<tr class="firstrow">
    		<td class='firstcol'></td>
    		<td><?php echo __('Product', 'wpsc'); ?>:</td>
    		<td><?php echo __('Quantity', 'wpsc'); ?>:</td>
    		<?php if(wpsc_uses_shipping()): ?>
    			<td><?php echo __('Shipping', 'wpsc'); ?>:</td>
    		<?php endif; ?>
    		<td><?php echo __('Price', 'wpsc'); ?>:</td>
    		<td></td>
    	</tr>
    	<?php while (wpsc_have_cart_items()) : wpsc_the_cart_item(); ?>
    
    	<?php  //this displays the confirm your order html	?>
    
    		<tr class="product_row">
    			<td class="firstcol"><img src='<?php echo wpsc_cart_item_image(100,100); ?>' alt='<?php echo wpsc_cart_item_name(); ?>' title='<?php echo wpsc_cart_item_name(); ?>' width="100" /></td>
    			<td class="firstcol">
    			<a href='<?php echo wpsc_cart_item_url();?>'><?php echo wpsc_cart_item_name(); ?></a>
    			</td>
    			<td>
    				<form action="<?php echo get_option('shopping_cart_url'); ?>" method="post" class="adjustform">
    					<input type="text" name="quantity" size="2" value="<?php echo wpsc_cart_item_quantity(); ?>"/>
    					<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
    					<input type="hidden" name="wpsc_update_quantity" value="true"/>
    					<input type="submit" value="" name="submit" class="btn_update"/>
    				</form>
    			</td>
    			<?php if(wpsc_uses_shipping()): ?>
    			<td><span class="pricedisplay" id='shipping_<?php echo wpsc_the_cart_item_key(); ?>'><?php echo wpsc_cart_item_shipping(); ?></span></td>
    			<?php endif; ?>
    			<td><span class="pricedisplay"><?php echo wpsc_cart_item_price(); ?></span></td>
    			<td>
    
    				<form action="<?php echo get_option('shopping_cart_url'); ?>" method="post" class="adjustform">
    					<input type="hidden" name="quantity" value="0"/>
    					<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
    					<input type="hidden" name="wpsc_update_quantity" value="true"/>
    					<button class='remove_button btn_remove' type="submit"></button>
    				</form>
    			</td>
    		</tr>
    	<?php endwhile; ?>
    	<?php //this HTML displays coupons if there are any active coupons to use ?>
    <?php //exit('<pre>'.print_r($wpsc_coupons, true).'</pre>'); ?>
    	<?php if(wpsc_uses_coupons()): ?>
    
    		<?php if(wpsc_coupons_error()): ?>
    			<tr><td><?php echo __('Coupon is not valid.', 'wpsc'); ?></td></tr>
    		<?php endif; ?>
    		<tr>
    			<td colspan="2"><?php _e('Enter your coupon number'); ?> :</td>
    			<td  colspan="3" align='left'>
    			<form  method='post' action="<?php echo get_option('shopping_cart_url'); ?>">
    				<input type='text' name='coupon_num' id='coupon_num' value='<?php echo $wpsc_cart->coupons_name; ?>' />
    				<input type='submit' value='<?php echo __('Update', 'wpsc') ?>' />
    			</form>
    			</td>
    		</tr>
    	<?php endif; ?>
    	</table>
    	<?php  //this HTML dispalys the calculate your order HTML	?>
    
    	<?php if(isset($_SESSION['nocamsg']) && isset($_GET['noca']) && $_GET['noca'] == 'confirm'): ?>
    		<p class='validation-error'><?php echo $_SESSION['nocamsg']; ?></p>
    	<?php endif; ?>
    	<?php if($_SESSION['categoryAndShippingCountryConflict'] != '') : ?>
    		<p class='validation-error'><?php echo $_SESSION['categoryAndShippingCountryConflict']; ?></p>
    	<?php
    	endif;
    	if($_SESSION['WpscGatewayErrorMessage'] != '') :
    	?>
    		<p class='validation-error'><?php echo $_SESSION['WpscGatewayErrorMessage']; ?></p>
    	<?php
    	endif;
    	?>
    	<?php do_action('wpsc_before_shipping_of_shopping_cart'); ?>
    	<div id='wpsc_shopping_cart_container'>
    	<?php if(wpsc_uses_shipping()) : ?>
    		<h2><?php echo __('Calculate Shipping Price', 'wpsc'); ?></h2>
    		<table class="productcart">
    			<tr>
    				<td colspan='5'>
    					<?php echo __('Please choose a country below to calculate your shipping costs', 'wpsc'); ?>
    				</td>
    			</tr>
    
    			<tr>
    				<td colspan='5'>
    					<form name='change_country' id='change_country' action='' method='post'>
    						<?php echo wpsc_shipping_country_list();?>
    						<input type='hidden' name='wpsc_update_location' value='true' />
    						<input type='submit' name='wpsc_submit_zipcode' value='Calculate' />
    					</form>
    
    				</td>
    			</tr>
    
    			<?php while (wpsc_have_shipping_methods()) : wpsc_the_shipping_method(); ?>
    					<?php
    					// Don't display shipping method if it doesn't have at least one quote
    					if (!wpsc_have_shipping_quotes()) continue;
    					?>
    					<tr><td class='shipping_header' colspan='5'><?php echo wpsc_shipping_method_name().__('- Choose a Shipping Rate', 'wpsc'); ?> </td></tr>
    					<?php while (wpsc_have_shipping_quotes()) : wpsc_the_shipping_quote(); ?>
    						<tr class='shipping_quotes'>
    							<td colspan='3'>
    								<label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_name(); ?></label>
    							</td>
    							<td style='text-align:center;'>
    								<label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_value(); ?></label>
    							</td>
    							<td style='text-align:center;'>
    							<?php if(wpsc_have_morethanone_shipping_methods_and_quotes()): ?>
    								<input type='radio' id='<?php echo wpsc_shipping_quote_html_id(); ?>' <?php echo wpsc_shipping_quote_selected_state(); ?>  onclick='switchmethod("<?php echo wpsc_shipping_quote_name(); ?>", "<?php echo wpsc_shipping_method_internal_name(); ?>")' value='<?php echo wpsc_shipping_quote_value(true); ?>' name='shipping_method' />
    							<?php else: ?>
    								<input <?php echo wpsc_shipping_quote_selected_state(); ?> disabled='disabled' type='radio' id='<?php echo wpsc_shipping_quote_html_id(); ?>'  value='<?php echo wpsc_shipping_quote_value(true); ?>' name='shipping_method' />
    									<?php wpsc_update_shipping_single_method(); ?>
    							<?php endif; ?>
    							</td>
    						</tr>
    
    					<?php endwhile; ?>
    			<?php endwhile;  ?>
    			<?php wpsc_update_shipping_multiple_methods(); ?>
    			<?php if (!wpsc_have_shipping_quote()) : // No valid shipping quotes ?>
    				<tr>
    					<td colspan='5'><?php echo __('Sorry, online ordering is unavailable to this destination and/or weight. Please double check your destination details.', 'wpsc'); ?></td>
    				</tr>
    			</table>
    			</div>
    			<?php
    			return;
    			endif;
    			?>
    		</table>
    	<?php endif;  ?>
    
    	<img src="<?php bloginfo('template_url'); ?>/images/dashed-seperator.png">
    
    	<table class="productcart" style="margin-top:20px;">
    	<tr class="total_price total_tax">
    		<td colspan="3">
    			<?php echo wpsc_display_tax_label(true); ?>
    
    		</td>
    		<td colspan="2">
    			<span id="checkout_tax" class="pricedisplay checkout-tax"><?php echo wpsc_cart_tax(); ?></span>
    		</td>
    	</tr>
    	  <?php if(wpsc_uses_coupons() && (wpsc_coupon_amount(false) > 0)): ?>
    	<tr class="total_price">
    		<td colspan="3">
    			<?php echo __('Discount', 'wpsc'); ?>
    		</td>
    		<td colspan="2">
    			<span id="coupons_amount" class="pricedisplay"><?php echo wpsc_coupon_amount(); ?></span>
    	    </td>
       	</tr>
    	  <?php endif ?>
    
    	<tr class='total_price'>
    		<td colspan='3'>
    		<?php echo __('Total Price', 'wpsc'); ?>
    		</td>
    		<td colspan='2'>
    			<span id='checkout_total' class="pricedisplay checkout-total"><?php echo wpsc_cart_total(); ?></span>
    		</td>
    	</tr>
    
    	</table>
    
    		<?php do_action('wpsc_before_form_of_shopping_cart'); ?>
    
    	<form class='wpsc_checkout_forms' action='' method='post' enctype="multipart/form-data">
    
    	   <?php
    	   /**
    	    * Both the registration forms and the checkout details forms must be in the same form element as they are submitted together, you cannot have two form elements submit together without the use of JavaScript.
    	   */
    	   ?>
    
    	 <?php if(!is_user_logged_in() && get_option('users_can_register') && get_option('require_register')) : ?>
    		<h2><?php _e('Not yet a member?');?></h2>
    		<p><?php _e('In order to buy from us, you\'ll need an account. Joining is free and easy. All you need is a username, password and valid email address.');?></p>
    		<?php	if(count($_SESSION['wpsc_checkout_user_error_messages']) > 0) : ?>
    			<div class="login_error">
    				<?php
    				foreach($_SESSION['wpsc_checkout_user_error_messages'] as $user_error ) {
    				  echo $user_error."<br />\n";
    				}
    				$_SESSION['wpsc_checkout_user_error_messages'] = array();
    				?>
    		  </div>
    		<?php endif; ?>
    
    	  <fieldset class='wpsc_registration_form'>
    			<label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
    			<label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
    			<label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="20" />
    		</fieldset>
    	<?php endif; ?>
    
    	<img src="<?php bloginfo('template_url'); ?>/images/dashed-seperator.png">
    	<p style="margin-top:10px; padding-bottom: 6px;"><strong><?php echo __('Please enter your contact details', 'wpsc'); ?></strong></p>
    	<?php
    	  if(count($_SESSION['wpsc_checkout_misc_error_messages']) > 0) {
    			echo "<div class='login_error'>\n\r";
    			foreach((array)$_SESSION['wpsc_checkout_misc_error_messages'] as $user_error ) {
    				echo $user_error."<br />\n";
    			}
    			echo "</div>\n\r";
    		}
    		$_SESSION['wpsc_checkout_misc_error_messages'] =array();
    	?>
    	<table class="wpsc_checkout_table">
    
    		  		  		<tbody>
    
    		  		  		  		<tr class="">
    
    			<td width="49%">
    			  <input title="billingfirstname" type="text" id="wpsc_checkout_form_2" class="text" value="" name="collected_data[2]" placeholder="First Name" style="width:97%;">
    		    			</td>
    			<td width="2%"></td>
    			<td width="49%">
    			  <input title="billinglastname" type="text" id="wpsc_checkout_form_3" class="text" value="" name="collected_data[3]" placeholder="Last Name" style="width:97%;">
    		    			</td>
    			</tr>
    
    		  		  		  		<tr class="">
    			<td width="49%">
    			  <input title="billingphone" type="text" id="wpsc_checkout_form_17" class="text" value="" name="collected_data[17]" placeholder="Phone" style="width:97%;">
    		    			</td>
    			<td width="2%"></td>
    			<td width="49%">
    			  <input title="billingemail" type="text" id="wpsc_checkout_form_8" class="text" value="" name="collected_data[8]" placeholder="E-mail *Mandatory*" style="width:97%;">
    		    			</td>
    			</tr>
    
    		  		  		  		<tr class=" wpsc_shipping_forms">
    			<td width="49%" style="vertical-align:top;">
    				<label for="wpsc_checkout_form_22">
    				Collection Delivery </label>
    			</td>
    			<td width="2%"></td>
    			<td width="49%">
    											<label>
    								<input type="radio" name="collected_data[22]" value="Collect - Kenilworth" class="">
    								Collect wine from Kenilworth							</label><BR>
    													<label>
    								<input type="radio" name="collected_data[22]" value="Collect - Somerset West" class="">
    								Collect wine from Somerset West							</label><BR>
    													<label>
    								<input type="radio" name="collected_data[22]" value="Deliver" class="">
    								Deliver wine							</label>
    
    		    			</td>
    			</tr>
    
    		</tbody>
    		</table>
    		<img src="<?php bloginfo('template_url'); ?>/images/dashed-seperator.png" style="margin-top:10px;">
    	<p style="margin-top:10px; padding-bottom:6px;"><strong><?php echo __('Delivery details		', 'wpsc'); ?></strong></p>
    		<table class="wpsc_checkout_table">
    
    		  		  		<tbody>
    
    		  		  		  		<tr class="" valign="top">
    			<td width="49%">
    			  <textarea title="billingaddress" class="text" id="wpsc_checkout_form_12" name="collected_data[12]" rows="3" cols="40" placeholder="Address" style="height:98px; width:97%;"></textarea>
    		    			</td>
    
    			<td width="2%"></td>
    			<td width="49%" valign="top" style="vertical-align:top">
    			  <input title="billingcity" type="text" id="wpsc_checkout_form_13" class="text" value="" name="collected_data[13]" placeholder="City" style="margin-bottom: 13px; width:97%;">	
    
    <select id="wpsc_checkout_form_15" title="shippingcountry" name="collected_data[15][0]" class="current_country" onchange="set_shipping_country(&quot;region_country_form_15&quot;, &quot;15&quot;);" style="margin-bottom: 14px; padding: 4px; width:100%;">
    
    <option value="ZA" selected="selected">South Africa</option>
    
    </select>				
    
    			 <input title="billingpostcode" type="text" id="wpsc_checkout_form_16" class="text" value="" name="collected_data[16]" placeholder="Postal Code" style="width:97%;">
    		    			</td>
    			</tr>
    
    		  		  		  		<tr class="">
    			<td width="49%">
    				<select name="collected_data[37]"  style="width:100%; padding: 4px;"><option value="-1">Where did you hear about us?</option><option value="SRE">Sales Rep</option>
    
    <option value="ISE">Internet (Google, etc)</option>
    
    <option value="WAD">Website Advertising</option>
    
    <option value="NAD">Newspaper Advertising</option>
    
    <option value="NEW">Newsletter</option>
    
    <option selected="selected" value="WOM">Word of Mouth</option>
    
    <option value="OTH">Other</option>
    
    </select>
    		    			</td>
    			<td width="2%"></td>
    			<td width="49%">
    			  <input title="" type="text" id="wpsc_checkout_form_38" class="text intra-field-label" value="" name="collected_data[38]" placeholder='Details (if "Other" chosen)' style="width:97%;">
    		    			</td>
    			</tr>
    
    		<tr>
    			<td colspan="3">
    				<input name="custom_gateway" value="wpsc_merchant_testmode" type="hidden" class="">
    			</td>
    		</tr>
    
    		<tr>
    			<td colspan="3">
    				<input type="hidden" value="yes" name="agree" class="">
    
    				<input type="hidden" value="submit_checkout" name="wpsc_action" class="">
    				<input type="submit" value="" name="submit" class="btn_checkout">
    
    			</td>
    		</tr>
    	</tbody></table>
    </form>
    </div>
    <?php
    else:
    	echo __('Oops, there is nothing in your cart.', 'wpsc') . "<a href='".get_option("product_list_url")."'>" . __('Please visit our shop', 'wpsc') . "</a>";
    endif;
    do_action('wpsc_bottom_of_shopping_cart');
    ?>
    <img src="<?php bloginfo('template_url'); ?>/images/dashed-seperator.png" style="margin: 20px 0;">
  • The topic ‘WP Ecommerce mandatory form’ is closed to new replies.