Give_Helper_Form::create_simple_form PHP Method

create_simple_form() public static method

Create a simple form.
Since: 1.0
public static create_simple_form ( )
    public static function create_simple_form()
    {
        $post_id = wp_insert_post(array('post_title' => 'Test Donation Form', 'post_name' => 'test-donation-form', 'post_type' => 'give_forms', 'post_status' => 'publish'));
        $meta = array('_give_price_option' => 'set', '_give_set_price' => '20.00', '_give_custom_amount' => 'yes', '_give_custom_amount_minimum' => '1', '_give_custom_amount_text' => 'Would you like to set a custom amount?', '_give_goal_option' => 'no', '_give_payment_display' => 'onpage', '_give_show_register_form' => 'none', '_give_customize_offline_donations' => 'no', '_give_terms_option' => 'none', '_give_form_earnings' => '40.00', '_give_form_sales' => '2', '_give_default_gateway' => 'global');
        foreach ($meta as $key => $value) {
            update_post_meta($post_id, $key, $value);
        }
        return get_post($post_id);
    }

Usage Example

 /**
  * Create a simple donation payment.
  *
  * @since 1.0
  */
 public static function create_simple_payment()
 {
     global $give_options;
     // Enable a few options
     $give_options['enable_sequential'] = '1';
     $give_options['sequential_prefix'] = 'GIVE-';
     update_option('give_settings', $give_options);
     $simple_form = Give_Helper_Form::create_simple_form();
     $multilevel_form = Give_Helper_Form::create_multilevel_form();
     /** Generate some donations */
     $user = get_userdata(1);
     $user_info = array('id' => $user->ID, 'email' => $user->user_email, 'first_name' => $user->first_name, 'last_name' => $user->last_name);
     $total = 0;
     $simple_price = get_post_meta($simple_form->ID, 'give_price', true);
     $variable_prices = get_post_meta($multilevel_form->ID, 'give_variable_prices', true);
     $variable_item_price = $variable_prices[1]['amount'];
     // == $100
     $total += $variable_item_price + $simple_price;
     $purchase_data = array('price' => number_format((double) $total, 2), 'give_form_title' => 'Test Donation', 'give_form_id' => $simple_form->ID, 'date' => date('Y-m-d H:i:s', strtotime('-1 day')), 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $user_info['email'], 'user_info' => $user_info, 'currency' => 'USD', 'status' => 'pending');
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     $_SERVER['SERVER_NAME'] = 'give_virtual';
     $payment_id = give_insert_payment($purchase_data);
     $key = $purchase_data['purchase_key'];
     $transaction_id = 'FIR3SID3';
     give_set_payment_transaction_id($payment_id, $transaction_id);
     give_insert_payment_note($payment_id, sprintf(__('PayPal Transaction ID: %s', 'give'), $transaction_id));
     return $payment_id;
 }
All Usage Examples Of Give_Helper_Form::create_simple_form