/** * Takes a membership pack and returns the proper benefit explanation * * @deprecated 3.4 * @deprecated Use cp_calculate_membership_package_benefit() and cp_get_membership_package_benefit_text() * @see cp_calculate_membership_package_benefit() and cp_get_membership_package_benefit_text() * * @param int $pack_id * @param float $price (optional) * * @return mixed */ function get_pack_benefit($pack_id, $price = false) { if ($price) { _deprecated_function(__FUNCTION__, '3.4', 'cp_calculate_membership_package_benefit'); return cp_calculate_membership_package_benefit($pack_id); } else { _deprecated_function(__FUNCTION__, '3.4', 'cp_get_membership_package_benefit_text'); return cp_get_membership_package_benefit_text($pack_id); } }
/** * Sets listing internal data. * * return void */ protected function set_internal_data() { global $cp_options, $current_user; $listing = $this->get_listing_obj(); // add items needed for function that displays listing preview $this->posted_fields['fid'] = $this->form_id; $this->posted_fields['cat'] = $this->category_id; // set listing unique id if ($unique_id = get_post_meta($listing->ID, 'cp_sys_ad_conf_id', true)) { $this->posted_fields['cp_sys_ad_conf_id'] = $unique_id; } else { $this->posted_fields['cp_sys_ad_conf_id'] = cp_generate_id(); } // set user IP $this->posted_fields['cp_sys_userIP'] = appthemes_get_ip(); // set listing duration if ($this->posted_fields['ad_pack_id']) { $this->posted_fields['cp_sys_ad_duration'] = cp_get_ad_pack_length($this->posted_fields['ad_pack_id']); } else { $this->posted_fields['cp_sys_ad_duration'] = $cp_options->prun_period; } $listing_price_currency = !empty($this->posted_fields['cp_currency']) ? $this->posted_fields['cp_currency'] : $cp_options->curr_symbol; $coupon = false; // legacy coupon value if (cp_payments_is_enabled()) { // see if the featured ad checkbox has been checked if (!empty($this->posted_fields['featured_ad'])) { $this->posted_fields['featured_ad'] = 1; // save featured ad price $this->posted_fields['cp_sys_feat_price'] = $cp_options->sys_feat_price; } // calculate the ad listing fee and put into a variable $this->posted_fields['cp_sys_ad_listing_fee'] = cp_ad_listing_fee($this->category_id, $this->posted_fields['ad_pack_id'], $this->posted_fields['cp_price'], $listing_price_currency); $featured_price = isset($this->posted_fields['cp_sys_feat_price']) ? $this->posted_fields['cp_sys_feat_price'] : 0; $this->posted_fields['cp_sys_total_ad_cost'] = cp_calc_ad_cost($this->category_id, $this->posted_fields['ad_pack_id'], $featured_price, $this->posted_fields['cp_price'], $coupon, $listing_price_currency); $this->posted_fields['cp_sys_total_ad_cost_no_benefit'] = $this->posted_fields['cp_sys_total_ad_cost']; // apply membership benefit if ($cp_options->enable_membership_packs && ($membership = cp_get_user_membership_package($current_user->ID))) { $this->posted_fields['membership_pack'] = $membership->ID; // update the total cost based on the membership pack ID and current total cost $this->posted_fields['cp_sys_total_ad_cost'] = cp_calculate_membership_package_benefit($membership->ID, $this->posted_fields['cp_sys_total_ad_cost']); // add featured cost to static pack type if ($featured_price && $membership->pack_type == 'static') { $this->posted_fields['cp_sys_total_ad_cost'] += $featured_price; } } } // prevent from minus prices if bigger discount applied if (!isset($this->posted_fields['cp_sys_total_ad_cost']) || $this->posted_fields['cp_sys_total_ad_cost'] < 0) { $this->posted_fields['cp_sys_total_ad_cost'] = 0; } }