Example #1
0
    //incriment coupon code count only if total ad price was not zero
    if (isset($advals['cp_coupon_code']) && cp_check_coupon_discount($advals['cp_coupon_code'])) {
        cp_use_coupon($advals['cp_coupon_code']);
    }
    // call in the selected payment gateway as long as the price isn't zero
    if (get_option('cp_charge_ads') == 'yes' && $advals['cp_sys_total_ad_cost'] != 0) {
        //load payment gateway page to process checkout
        include_once TEMPLATEPATH . '/includes/gateways/gateway.php';
    } else {
        // otherwise the ad was free and show the thank you page.
        // get the post status
        $the_post = get_post($post_id);
        // check to see what the ad status is set to
        if ($the_post->post_status == 'pending') {
            // send ad owner an email
            cp_owner_new_ad_email($post_id);
            ?>

            <h3><?php 
            _e('Thank you! Your ad listing has been submitted for review.', 'appthemes');
            ?>
</h3>
            <p><?php 
            _e('You can check the status by viewing your dashboard.', 'appthemes');
            ?>
</p>

        <?php 
        } else {
            ?>
Example #2
0
 /**
  * Processing form.
  *
  * @param object $order
  * @param object $checkout
  *
  * return void
  */
 public function process($order, $checkout)
 {
     global $cp_options;
     // if no listing internal ID move step backward
     $posted_fields = $checkout->get_data('posted_fields');
     if (!$posted_fields['cp_sys_ad_conf_id']) {
         $checkout->cancel_step();
         return;
     }
     if (!isset($_POST['action']) || !in_array($_POST['action'], array('create-listing', 'renew-listing'))) {
         return;
     }
     check_admin_referer($checkout->get_checkout_type());
     $this->posted_fields = $checkout->get_data('posted_fields');
     if (cp_payments_is_enabled()) {
         $this->errors = apply_filters('appthemes_validate_purchase_fields', $this->errors);
     }
     if ($this->errors->get_error_codes()) {
         return false;
     }
     $listing = $this->get_listing_obj();
     $this->update_listing($order, $checkout);
     if (cp_payments_is_enabled()) {
         $plan_id = isset($this->posted_fields['ad_pack_id']) ? $this->posted_fields['ad_pack_id'] : 0;
         $membership_id = isset($this->posted_fields['membership_pack']) ? $this->posted_fields['membership_pack'] : 0;
         $this->add_plan_to_order($order, $checkout, $plan_id, $membership_id, $listing->ID);
         $this->add_addons_to_order($order, $listing->ID, $membership_id);
         $this->set_order_description($order, $checkout, $listing->ID);
         do_action('appthemes_create_order', $order, APP_POST_TYPE);
     } else {
         if ('pending' == get_post_status($listing->ID)) {
             // send ad owner an email
             cp_owner_new_ad_email($listing->ID);
         }
     }
     // send new ad notification email to admin
     if ($cp_options->new_ad_email) {
         cp_new_ad_email($listing->ID);
     }
     $this->finish_step();
 }