$postvals['cp_sys_feat_price'] = $cp_options->sys_feat_price; } // calculate the ad listing fee and put into a variable $postvals['cp_sys_ad_listing_fee'] = cp_ad_listing_fee($_POST['cat'], $ad_pack_id, $postvals['cp_price'], $price_curr); // 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'], $ad_pack_id, $postvals['cp_sys_feat_price'], $postvals['cp_price'], $coupon, $price_curr); } else { $postvals['cp_sys_total_ad_cost'] = cp_calc_ad_cost($_POST['cat'], $ad_pack_id, 0, $postvals['cp_price'], $coupon, $price_curr); } //UPDATE TOTAL BASED ON MEMBERSHIP //check for current users active membership pack and that its not expired if (!empty($current_user->active_membership_pack) && appthemes_days_between_dates($current_user->membership_expires) > 0) { $postvals['membership_pack'] = get_pack($current_user->active_membership_pack); //update the total cost based on the membership pack ID and current total cost $postvals['cp_sys_total_ad_cost'] = get_pack_benefit($postvals['membership_pack'], $postvals['cp_sys_total_ad_cost']); //add featured cost to static pack type if (isset($postvals['cp_sys_feat_price']) && in_array($postvals['membership_pack']->pack_type, array('required_static', 'static'))) { $postvals['cp_sys_total_ad_cost'] += $postvals['cp_sys_feat_price']; } } } // prevent from minus prices if bigger discount applied if (!isset($postvals['cp_sys_total_ad_cost']) || $postvals['cp_sys_total_ad_cost'] < 0) { $postvals['cp_sys_total_ad_cost'] = 0; } // now put the array containing all the post values into the database // instead of passing hidden values which are easy to hack and so we // can also retrieve it on the next step $option_name = 'cp_' . $postvals['oid']; update_option($option_name, $postvals);
<?php if ($results) { $rowclass = ''; $i = 1; ?> <tbody id="list"> <?php foreach ($results as $result) { unset($rowclass, $requiredClass); if ($result->pack_status == 'active_membership') { //$rowclass = 'even' == $rowclass ? 'alt' : 'even'; $rowclass = 'even'; $benefit = get_pack_benefit($result); if (stristr($result->pack_type, 'required')) { $requiredClass = 'required'; } ?> <tr class="<?php echo $rowclass . ' ' . $requiredClass; ?> "> <?php $i++; ?> <td><strong><?php echo stripslashes($result->pack_name); ?>
function cp_show_review($postvals) { //var_dump($postvals); global $wpdb; // if there's no form id it must mean the default form is being used so let's go grab those fields if (empty($postvals['fid'])) { // use this if there's no custom form being used and give us the default form $sql = "SELECT field_label, field_name, field_type, field_values, field_req FROM {$wpdb->cp_ad_fields} WHERE field_core = '1' ORDER BY field_id asc"; } else { // now we should have the formid so show the form layout based on the category selected $sql = $wpdb->prepare("SELECT f.field_label,f.field_name,f.field_type,f.field_values,f.field_perm,m.meta_id,m.field_pos,m.field_req,m.form_id " . "FROM {$wpdb->cp_ad_fields} f " . "INNER JOIN {$wpdb->cp_ad_meta} m " . "ON f.field_id = m.field_id " . "WHERE m.form_id = %s " . "ORDER BY m.field_pos asc", $postvals['fid']); } $results = $wpdb->get_results($sql); if ($results) { // loop through the custom form fields and display them echo cp_formbuilder_review($results); } else { printf(__('ERROR: The form template for form ID %s does not exist or the session variable is empty.', APP_TD), $postvals['fid']); } ?> <hr class="bevel" /> <div class="clr"></div> <li> <div class="labelwrapper"> <label><?php _e('Ad Listing Fee:', APP_TD); ?> </label> </div> <div id="review"><?php if (cp_payments_is_enabled()) { appthemes_display_price($postvals['cp_sys_ad_listing_fee']); } else { _e('FREE', APP_TD); } ?> </div> <div class="clr"></div> </li> <?php if (isset($postvals['featured_ad'])) { ?> <li> <div class="labelwrapper"> <label><?php _e('Featured Listing Fee:', APP_TD); ?> </label> </div> <div id="review"><?php appthemes_display_price($postvals['cp_sys_feat_price']); ?> </div> <div class="clr"></div> </li> <?php } ?> <?php if (isset($postvals['membership_pack'])) { ?> <li> <div class="labelwrapper"> <label><?php _e('Membership:', APP_TD); ?> </label> </div> <div id="review"><?php echo get_pack_benefit($postvals['membership_pack']); ?> </div> <div class="clr"></div> </li> <?php } ?> <hr class="bevel-double" /> <div class="clr"></div> <li> <div class="labelwrapper"> <label><?php _e('Total Amount Due:', APP_TD); ?> </label> </div> <div id="review"><strong> <?php if (cp_payments_is_enabled()) { appthemes_display_price($postvals['cp_sys_total_ad_cost']); } else { _e('--', APP_TD); } ?> </strong></div> <div class="clr"></div> </li> <?php if (cp_payments_is_enabled() && $postvals['cp_sys_total_ad_cost'] > 0) { do_action('appthemes_purchase_fields'); } ?> <?php }
function cp_show_review($postvals) { global $wpdb; // if there's no form id it must mean the default form is being used so let's go grab those fields if (!$postvals['fid']) { // use this if there's no custom form being used and give us the default form $sql = "SELECT field_label, field_name, field_type, field_values, field_req FROM {$wpdb->cp_ad_fields} WHERE field_core = '1' ORDER BY field_id asc"; } else { // now we should have the formid so show the form layout based on the category selected $sql = $wpdb->prepare("SELECT f.field_label,f.field_name,f.field_type,f.field_values,f.field_perm,m.meta_id,m.field_pos,m.field_req,m.form_id " . "FROM {$wpdb->cp_ad_fields} f " . "INNER JOIN {$wpdb->cp_ad_meta} m " . "ON f.field_id = m.field_id " . "WHERE m.form_id = %s " . "ORDER BY m.field_pos asc", $postvals['fid']); } $results = $wpdb->get_results($sql); if ($results) { // loop through the custom form fields and display them echo cp_formbuilder_review($results); } else { echo sprintf(__('ERROR: The form template for form ID %s does not exist or the session variable is empty.', APP_TD), $postvals['fid'] . "\n\n"); } ?> <hr class="bevel" /> <div class="clr"></div> <?php if (isset($_POST['cp_payment_method']) && $postvals['cp_sys_total_ad_cost'] != 0) { // if a payment method has been posted AND the total is not equal to zero ?> <li> <div class="labelwrapper"> <label><?php _e('Payment Method:', APP_TD); ?> </label> </div> <div id="review"><?php echo ucfirst($_POST['cp_payment_method']); ?> </div> <div class="clr"></div> </li> <?php } ?> <li> <div class="labelwrapper"> <label><?php _e('Ad Listing Fee:', APP_TD); ?> </label> </div> <div id="review"><?php if (get_option('cp_charge_ads') == 'yes') { cp_display_price($postvals['cp_sys_ad_listing_fee']); } else { _e('FREE', APP_TD); } ?> </div> <div class="clr"></div> </li> <?php if (isset($_POST['featured_ad'])) { ?> <li> <div class="labelwrapper"> <label><?php _e('Featured Listing Fee:', APP_TD); ?> </label> </div> <div id="review"><?php cp_display_price($postvals['cp_sys_feat_price']); ?> </div> <div class="clr"></div> </li> <?php } ?> <?php if (isset($postvals['cp_coupon_type'])) { ?> <li> <div class="labelwrapper"> <label><?php _e('Coupon:', APP_TD); ?> </label> </div> <?php if ($postvals['cp_coupon_type'] != '%') { ?> <div id="review"><?php cp_display_price($postvals['cp_coupon']); ?> </div> <?php } else { ?> <div id="review"><?php echo str_replace('.00', '', $postvals['cp_coupon']) . $postvals['cp_coupon_type']; ?> </div> <?php } ?> <div class="clr"></div> </li> <?php } ?> <?php if (isset($postvals['cp_membership_pack'])) { ?> <li> <div class="labelwrapper"> <label><?php _e('Membership:', APP_TD); ?> </label> </div> <div id="review"><?php echo get_pack_benefit($postvals['cp_membership_pack']); ?> </div> <div class="clr"></div> </li> <?php } ?> <hr class="bevel-double" /> <div class="clr"></div> <li> <div class="labelwrapper"> <label><?php _e('Total Amount Due:', APP_TD); ?> </label> </div> <div id="review"><strong> <?php // if it costs to post an ad OR its free and someone selected a featured ad price if (get_option('cp_charge_ads') == 'yes' || isset($postvals['featured_ad'])) { cp_display_price($postvals['cp_sys_total_ad_cost']); } else { _e('--', APP_TD); } ?> </strong></div> <div class="clr"></div> </li> <?php }
} ?> :</strong></label></div> <div id="active_membership_pack"><?php echo stripslashes($membership->pack_name); ?> </div> <div class="clr"></div> </li> <li> <div class="labelwrapper"><label><strong><?php _e('Membership Benefit:', 'appthemes'); ?> </strong></label></div> <div id="active_membership_pack"><?php echo stripslashes(get_pack_benefit($membership)); ?> </div> <div class="clr"></div> </li> <li> <div class="labelwrapper"><label><strong><?php _e('Membership Length:', 'appthemes'); ?> </strong></label></div> <div id="active_membership_pack"><?php echo $membership->pack_duration . ' ' . $extend . __('days', 'appthemes'); ?> </div> <div class="clr"></div> </li>
} ?> :</strong></label></div> <div id="active_membership_pack"><?php echo $membership->pack_name; ?> </div> <div class="clr"></div> </li> <li> <div class="labelwrapper"><label><strong><?php _e('Membership Benefit:', 'appthemes'); ?> </strong></label></div> <div id="active_membership_pack"><?php echo get_pack_benefit($membership); ?> </div> <div class="clr"></div> </li> <li> <div class="labelwrapper"><label><strong><?php _e('Membership Length:', 'appthemes'); ?> </strong></label></div> <div id="active_membership_pack"><?php echo $membership->pack_duration . ' ' . $extend . __('days', 'appthemes'); ?> </div> <div class="clr"></div> </li>