示例#1
0
         $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">' . __("Coupon code '{$coupon_code_name}' is not active or does not exist.", 'appthemes') . '</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);
 } elseif (isset($postvals['cp_sys_premium_price'])) {
     $postvals['cp_sys_total_ad_cost'] = cp_calc_ad_cost($_POST['cat'], $adpackid, $postvals['cp_sys_premium_price'], $_POST['cp_price'], $coupon);
 } else {
     $postvals['cp_sys_total_ad_cost'] = cp_calc_ad_cost($_POST['cat'], $adpackid, 0, $_POST['cp_price'], $coupon);
 }
 //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['cp_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['cp_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['cp_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 ($postvals['cp_sys_total_ad_cost'] < 0) {
     $postvals['cp_sys_total_ad_cost'] = '0.00';
示例#2
0
 }
 $coupon = false;
 if (cp_payments_is_enabled()) {
     // see if the featured ad checkbox has been checked
     if (isset($_POST['featured_ad'])) {
         $postvals['featured_ad'] = $_POST['featured_ad'];
         // get the featured ad price into the array
         $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) {
示例#3
0
 /**
  * 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;
     }
 }