$post_ad_pack_id = $_POST['ad_pack_id']; } else { $post_ad_pack_id = ''; } if (get_option('cp_charge_ads') == 'yes') { $postvals['cp_sys_ad_listing_fee'] = cp_ad_listing_fee($_POST['cat'], $post_ad_pack_id, $_POST['cp_price'], $price_curr); } // check to prevent "Notice: Undefined index:" on php strict error checking. get ad pack id and lookup length $adpackid = ''; if (isset($_POST['ad_pack_id'])) { $adpackid = $_POST['ad_pack_id']; $postvals['pack_duration'] = cp_get_ad_pack_length($adpackid); } //check if coupon code was entered, then check if coupon exists and is active if (isset($_POST['cp_coupon_code'])) { $coupon = cp_check_coupon_discount($_POST['cp_coupon_code']); //if $coupon has any results if ($coupon) { $postvals['cp_coupon_type'] = $coupon->coupon_discount_type; $postvals['cp_coupon'] = $coupon->coupon_discount; } elseif ($_POST['cp_coupon_code'] != '') { $postvals['cp_coupon_type'] = ''; $coupon_code_name = $_POST['cp_coupon_code']; $postvals['cp_coupon'] = '<span class="error-coupon">' . sprintf(__('Coupon code "%s" is not active or does not exist.', APP_TD), $coupon_code_name) . '</span>'; } } else { $coupon = array(); } // calculate the total cost of the ad if (isset($postvals['cp_sys_feat_price'])) { $postvals['cp_sys_total_ad_cost'] = cp_calc_ad_cost($_POST['cat'], $adpackid, $postvals['cp_sys_feat_price'], $_POST['cp_price'], $coupon, $price_curr);
include_once TEMPLATEPATH . '/includes/forms/step2-membership.php'; } elseif (isset($_POST['step2'])) { //now put the array containing all the post values into the database //DO NOTE USE POST VARS execpt as the relate to options selected. All POST vars are insecure. $membership = get_pack($_POST['pack']); $order = array(); $order['user_id'] = $current_user->ID; $order['order_id'] = $_POST['oid']; $order['option_order_id'] = 'cp_order_' . $current_user->ID . '_' . $_POST['oid']; $order['pack_type'] = 'membership'; $order['total_cost'] = $total_cost; //Check for coupon and use to to reduce total price and total number of coupon uses left if (isset($_POST['cp_coupon_code'])) { $order['cp_coupon_code'] = $_POST['cp_coupon_code']; //incriment coupon code count only if total ad price was not zero if (cp_check_coupon_discount($order['cp_coupon_code'])) { cp_use_coupon($order['cp_coupon_code']); //TODO - handle discounting of total cost } } $order = array_merge($order, (array) $membership); //save the order for use when payment is completed if (add_option($order['option_order_id'], $order)) { $cp_user_orders = get_user_orders($current_user->ID); if (isset($cp_user_orders) && $cp_user_orders) { $cp_user_recent_order = $cp_user_orders[0]; } } else { $order_already_exists = true; } include_once TEMPLATEPATH . '/includes/forms/step3-membership.php';
bloginfo('template_url'); ?> /images/step3.gif" alt="" class="stepimg" /> <div class="processlog"> <?php // insert the ad and get back the post id $post_id = cp_add_new_listing($advals); ?> </div> <div class="thankyou"> <?php //incriment coupon code count only if total ad price was not zero if (isset($advals['cp_coupon_code']) && cp_check_coupon_discount($advals['cp_coupon_code'])) { cp_use_coupon($advals['cp_coupon_code']); } // call in the selected payment gateway as long as the price isn't zero if (get_option('cp_charge_ads') == 'yes' && $advals['cp_sys_total_ad_cost'] != 0) { //load payment gateway page to process checkout include_once TEMPLATEPATH . '/includes/gateways/gateway.php'; } else { // otherwise the ad was free and show the thank you page. // get the post status $the_post = get_post($post_id); // check to see what the ad status is set to if ($the_post->post_status == 'pending') { // send ad owner an email cp_owner_new_ad_email($post_id); ?>