private function renew_listing($listing) { if (!$listing->has_expired() && !$listing->is_about_to_expire()) { throw new AWPCP_Exception(__("The Ad hasn't expired yet and is not about to expire.", 'AWPCP')); } $term = $this->payments->get_ad_payment_term($listing); if (!is_object($term)) { throw new AWPCP_Exception(__("We couldn't find a valid payment term associated with this Ad.", 'AWPCP')); } if (!$term->ad_can_be_renewed($listing)) { throw new AWPCP_Exception($term->ad_cannot_be_renewed_error($listing)); } $listing->renew(); $listing->save(); awpcp_send_ad_renewed_email($listing); $this->successful = $this->successful + 1; // MOVE inside Ad::renew() ? do_action('awpcp-renew-ad', $listing->ad_id, null); }
/** * @since 2.0.7 */ function awpcp_renew_ad_success_message($ad, $text = null, $send_email = true) { if (is_null($text)) { $text = __("The Ad has been successfully renewed. New expiration date is %s. ", 'AWPCP'); } $return = ''; if (is_admin()) { $return = sprintf('<a href="%1$s">%2$s</a>', awpcp_get_user_panel_url(), __('Return to Listings', 'AWPCP')); } if ($send_email) { awpcp_send_ad_renewed_email($ad); } return sprintf("%s %s", sprintf($text, $ad->get_end_date()), $return); }
public function finish_step() { $transaction = $this->page->get_transaction(); if (is_null($transaction)) { $message = $this->page->transaction_error(); return $this->page->render('content', awpcp_print_error($message)); } $ad = $this->page->get_ad(); if (is_null($ad)) { $message = __('The Ad associated with this transaction doesn\'t exists.', 'AWPCP'); return $this->page->render('content', awpcp_print_error($message)); } if (!$transaction->is_completed()) { $payments = awpcp_payments_api(); $payments->set_transaction_status_to_completed($transaction, $errors); if (!empty($errors)) { return $this->page->render('content', join(',', array_map($errors, 'awpcp_print_error'))); } $ad->renew(); $ad->save(); awpcp_send_ad_renewed_email($ad); // MOVE inside Ad::renew() ? do_action('awpcp-renew-ad', $ad->ad_id, $transaction); } return $this->page->render_finish_step($ad); }