private function fee_selection() { // Cancel renewal? if (isset($_POST['cancel-renewal'])) { $this->listing->remove_category($this->category->id, true); if (!$this->listing->get_categories('all')) { $this->listing->delete(); } return wpbdp_render_msg(_x('Your renewal was successfully cancelled.', 'renewal', 'WPBDM')); } $fees = wpbdp_get_fees_for_category($this->category->id); if (isset($_POST['fees']) && isset($_POST['fees'][$this->category->id])) { $fee_id = intval($_POST['fees'][$this->category->id]); if ($fee = wpbdp_get_fee($fee_id)) { $payment = new WPBDP_Payment(array('listing_id' => $this->listing->get_id())); $payment->add_item('fee', $fee->amount, sprintf(_x('Fee "%s" renewal for category "%s"', 'listings', 'WPBDM'), $fee->label, wpbdp_get_term_name($this->category->id)), array('fee_id' => $fee_id, 'fee_days' => $fee->days, 'fee_images' => $fee->images), $this->category->id, $fee_id); $payment->save(); $this->category->payment_id = $payment->get_id(); return $this->checkout(); } } return wpbdp_render('renew-listing', array('listing' => $this->listing, 'category' => $this->category, 'fees' => $fees)); }
protected function step_save() { $listing = $this->state->editing ? WPBDP_Listing::get($this->state->listing_id) : WPBDP_Listing::create($this->state); $listing->set_field_values($this->state->fields); $listing->set_images($this->state->images); $listing->set_thumbnail_id($this->state->thumbnail_id); if (!$this->state->editing) { // Generate payment for the listing. $payment = new WPBDP_Payment(array('listing_id' => $listing->get_id())); if (!$this->state->editing) { $payment->tag('initial'); } foreach ($this->state->categories as $cat_id => $fee_id) { $category_info = $listing->get_category_info($cat_id); if (!$category_info) { $fee = wpbdp_get_fee($fee_id); if (!$fee) { continue; } $payment->add_item($this->state->autorenew_fees ? 'recurring_fee' : 'fee', $fee->amount, sprintf(_x('Fee "%s" for category "%s"%s', 'listings', 'WPBDM'), $fee->label, wpbdp_get_term_name($cat_id), $this->state->autorenew_fees ? ' ' . _x('(recurring)', 'listings', 'WPBDM') : ''), array('fee_id' => $fee_id, 'fee_days' => $fee->days, 'fee_images' => $fee->images), $cat_id, $fee_id); } } if ($this->state->upgrade_to_sticky) { $payment->add_item('upgrade', wpbdp_get_option('featured-price'), _x('Listing upgrade to featured', 'submit', 'WPBDM')); } $payment->set_submit_state_id($this->state->id); if (current_user_can('administrator')) { $payment->set_status(WPBDP_Payment::STATUS_COMPLETED); } $payment->save(); $this->state->listing_id = $listing->get_id(); $this->state->payment_id = $payment->get_id(); } do_action_ref_array('wpbdp_listing_form_extra_sections_save', array(&$this->state)); $listing->save(); $listing->set_post_status($this->state->editing ? wpbdp_get_option('edit-post-status') : wpbdp_get_option('new-post-status')); $this->state->advance(false); // This step is 'invisible'. return $this->dispatch(); }