Commit 89e790ef authored by Varun Sridharan's avatar Varun Sridharan

Fixed #16

New Option Added To SELF Check and create donation product via system
tools page
parent 87bc8caa
...@@ -21,6 +21,7 @@ class WooCommerce_Quick_Donation_Admin_Function { ...@@ -21,6 +21,7 @@ class WooCommerce_Quick_Donation_Admin_Function {
add_action( 'post_row_actions', array($this,'protect_donation_product'),99,2); add_action( 'post_row_actions', array($this,'protect_donation_product'),99,2);
add_action( 'parse_query', array( $this, 'hide_donation_order_woocommerce_order' ) ); add_action( 'parse_query', array( $this, 'hide_donation_order_woocommerce_order' ) );
add_filter( 'wc_order_types',array($this,'add_wc_order_types'),1,2); add_filter( 'wc_order_types',array($this,'add_wc_order_types'),1,2);
add_action( 'wp_ajax_CreateDonationProduct', array($this,'create_donation_product') );
} }
...@@ -80,6 +81,7 @@ class WooCommerce_Quick_Donation_Admin_Function { ...@@ -80,6 +81,7 @@ class WooCommerce_Quick_Donation_Admin_Function {
public function get_OverRided(){ public function get_OverRided(){
$template_files = WC_QD_INSTALL::get_template_list(); $template_files = WC_QD_INSTALL::get_template_list();
$overrided = array(); $overrided = array();
...@@ -110,4 +112,39 @@ class WooCommerce_Quick_Donation_Admin_Function { ...@@ -110,4 +112,39 @@ class WooCommerce_Quick_Donation_Admin_Function {
} }
return $overrided; return $overrided;
} }
public function create_donation_product(){
if(! isset($_REQUEST['_wpnonce'])) {
echo '<span class="wc_qd_error">Invalid Nonce. kindly try again</span>';
exit;
}
if(wp_verify_nonce($_REQUEST['_wpnonce'], 'CreateDonationProduct')){
$type = 'simple';
$install = new WC_QD_INSTALL;
$callBack_function = 'create_'.$type.'_donation';
$donation_exist = $install::check_donation_exists();
if(isset($_REQUEST['force'])){
$post_id = $install::$callBack_function();
update_option(WC_QD_DB.'product_id',$post_id);
echo '<span class="wcqdsuccess">'.__('Donation Product Created',WC_QD_TXT).'</span>';
exit;
}
if(! $donation_exist){
$post_id = $install::$callBack_function();
update_option(WC_QD_DB.'product_id',$post_id);
echo '<span class="wcqdsuccess">'.__('Donation Product Created',WC_QD_TXT).'</span>';
} else {
$url = wp_nonce_url(admin_url('admin-ajax.php?action=CreateDonationProduct&force=true'),'CreateDonationProduct');
echo '<button href="'.$url.'"
class="wcqdAjaxCall button wcqdAutoRemove" type="button">
'.__('Force Create Donation Product',WC_QD_TXT).'</button>';
}
}
exit;
}
} }
\ No newline at end of file
...@@ -224,11 +224,14 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -224,11 +224,14 @@ class WooCommerce_Quick_Donation_Admin {
if(in_array($this->current_screen() , $this->get_screen_ids())) { if(in_array($this->current_screen() , $this->get_screen_ids())) {
wp_enqueue_script(WC_QD_SLUG.'_core_script', WC_QD_JS.'admin-script.js', array('jquery'), WC_QD()->version, false ); wp_enqueue_script(WC_QD_SLUG.'_core_script', WC_QD_JS.'admin-script.js', array('jquery'), WC_QD()->version, false );
} }
if($this->tools == $this->current_screen()){
wp_enqueue_script(WC_QD_SLUG.'_tools_Page_script', WC_QD_JS.'tools-page.js',array('jquery'), WC_QD()->version,false);
}
if($this->sys_info == $this->current_screen()){ if($this->sys_info == $this->current_screen()){
wp_register_script(WC_QD_SLUG.'_sysinfo_script', WC_QD_JS.'sysinfo.js', array( 'jquery' ), WC_QD()->version,false ); wp_register_script(WC_QD_SLUG.'_sysinfo_script', WC_QD_JS.'sysinfo.js', array( 'jquery' ), WC_QD()->version,false);
wp_localize_script(WC_QD_SLUG.'_sysinfo_script', 'systemInfoAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); wp_localize_script(WC_QD_SLUG.'_sysinfo_script', 'systemInfoAjax', array( 'ajaxurl' => admin_url('admin-ajax.php')));
wp_enqueue_script(WC_QD_SLUG.'_sysinfo_script'); wp_enqueue_script(WC_QD_SLUG.'_sysinfo_script');
} }
} }
......
<?php
$product_exist = __(' This will help you to create a new donation product. if not exist',WC_QD_TXT);
if(! WC_QD()->donation_product_exist_public()){
$product_exist = sprintf(' <span class="wc_qd_error" >%s</span>',__('Donation Product Dose Not Exist In WooCommerce. Please Create It ',WC_QD_TXT));
}
?>
<form action="" method="post">
<input type="hidden" value="wc_qd_wp_tools" name="action">
<?php wp_nonce_field('wc_qd_wp_tools'); ?>
<table cellspacing="0" class="wc_status_table widefat wc_qd_system_toold">
<thead class="tools">
<tr>
<th colspan="2"><?php _e('System Tools',WC_QD_TXT); ?></th>
</tr>
</thead>
<tbody class="tools">
<tr class="clear_transients">
<td><?php _e('Reinstall Donation Product',WC_QD_TXT); ?> </td>
<td>
<p>
<button type="button" class="wcqdAjaxCall button clear_transients" href="<?php echo wp_nonce_url(admin_url('admin-ajax.php?action=CreateDonationProduct'),'CreateDonationProduct'); ?>"><?php _e('Create Donation Product',WC_QD_TXT); ?></button>
<span class="description"><?php echo $product_exist; ?></span>
</p>
</td>
</tr>
</tbody>
</table>
</form>
...@@ -13,7 +13,7 @@ class WC_QD_INSTALL{ ...@@ -13,7 +13,7 @@ class WC_QD_INSTALL{
self::check_template_files(); self::check_template_files();
if(! $donation_exist){ if(! $donation_exist){
$post_id = self::create_donation(); $post_id = self::create_simple_donation();
update_option(WC_QD_DB.'product_id',$post_id); update_option(WC_QD_DB.'product_id',$post_id);
} }
} }
...@@ -71,7 +71,7 @@ class WC_QD_INSTALL{ ...@@ -71,7 +71,7 @@ class WC_QD_INSTALL{
* Create Donation Product In WooCommerce * Create Donation Product In WooCommerce
* @return int donation Post id * @return int donation Post id
*/ */
public static function create_donation(){ public static function create_simple_donation(){
$userID = 1; $userID = 1;
if(get_current_user_id()){ $userID = get_current_user_id(); } if(get_current_user_id()){ $userID = get_current_user_id(); }
......
#woocommerce-quick-donation-order-data > h3,#woocommerce-quick-donation-order-data > .handlediv{display: none;} #woocommerce-quick-donation-order-data > h3,#woocommerce-quick-donation-order-data > .handlediv{display: none;}
form#donors_listing div.tablenav {margin-top:0; height: auto;} form#donors_listing div.tablenav {margin-top:0; height: auto;}
form#donors_listing div.tablenav span.displaying-num {margin-top:0;} form#donors_listing div.tablenav span.displaying-num {margin-top:0;}
form#donors_listing div.bulkactions{display: none !important;} form#donors_listing div.bulkactions{display: none !important;}
form#donors_listing div.tablenav-pages{height: auto; margin: 0;} form#donors_listing div.tablenav-pages{height: auto; margin: 0;}
table.wc_qd_system_toold span.description{margin-left: 10px;}
span.wc_qd_error{font-weight: bold; color:red;}
span.wcqdsuccess{font-weight: bold; color: green;}
\ No newline at end of file
...@@ -27,17 +27,3 @@ form h3.title ~ p { ...@@ -27,17 +27,3 @@ form h3.title ~ p {
margin-top: 5px; margin-top: 5px;
padding: 5px 0 0 0; padding: 5px 0 0 0;
} }
jQuery(document).ready(function(){
jQuery('.wc_qd_system_toold td').on("click", ".wcqdAjaxCall",function(){
var autoRemove = false;
if(jQuery(this).hasClass('wcqdAutoRemove')){
autoRemove = true;
}
var Spinner = jQuery('<span class="spinner WCQDSpinner"></span>');
var Clicked = jQuery(this);
var POST_URL = jQuery(this).attr('href');
jQuery(this).attr('disabled',true);
jQuery(this).append(Spinner);
Spinner.css('visibility','visible');
Spinner.css('float','none');
Spinner.css('margin-top','0px');
jQuery.post(POST_URL, function(response) {
Spinner.remove();
if(autoRemove){
Clicked.parent().html(response);
}else{
Clicked.next().html(response);
Clicked.removeAttr('disabled',false);
}
});
});
});
\ No newline at end of file
...@@ -34,6 +34,7 @@ class WooCommerce_Quick_Donation { ...@@ -34,6 +34,7 @@ class WooCommerce_Quick_Donation {
public static $settings_values = null; public static $settings_values = null;
public static $email = null; public static $email = null;
private static $db = null; private static $db = null;
private static $admin = null;
/** /**
* Creates or returns an instance of this class. * Creates or returns an instance of this class.
*/ */
...@@ -73,7 +74,7 @@ class WooCommerce_Quick_Donation { ...@@ -73,7 +74,7 @@ class WooCommerce_Quick_Donation {
$install = new WC_QD_INSTALL; $install = new WC_QD_INSTALL;
if(! $install->check_donation_exists()){ if(! $install->check_donation_exists()){
self::$is_donation_product_exist = false; self::$is_donation_product_exist = false;
if($notice){ wc_qd_notice('WooCommerce Donation Product Not Exist','error',true);} if($notice){ wc_qd_notice(__('WooCommerce Donation Product Not Exist',WC_QD_TXT),'error',true);}
} }
} }
...@@ -81,8 +82,8 @@ class WooCommerce_Quick_Donation { ...@@ -81,8 +82,8 @@ class WooCommerce_Quick_Donation {
/** /**
* Checks If Donation Product Exist In WooCommerce Products * Checks If Donation Product Exist In WooCommerce Products
*/ */
public function donation_product_exist_public(){ public function donation_product_exist_public($notice = false){
$this->check_donation_product_exist(); $this->check_donation_product_exist($notice);
return self::$is_donation_product_exist; return self::$is_donation_product_exist;
} }
/** /**
...@@ -121,6 +122,7 @@ class WooCommerce_Quick_Donation { ...@@ -121,6 +122,7 @@ class WooCommerce_Quick_Donation {
} }
if($this->is_request('admin')){ if($this->is_request('admin')){
$this->load_files(WC_QD_ADMIN.'class-admin-init.php');
$this->load_files(WC_QD_ADMIN.'class-*.php'); $this->load_files(WC_QD_ADMIN.'class-*.php');
} }
...@@ -134,6 +136,7 @@ class WooCommerce_Quick_Donation { ...@@ -134,6 +136,7 @@ class WooCommerce_Quick_Donation {
self::$f = new WooCommerce_Quick_Donation_Functions; self::$f = new WooCommerce_Quick_Donation_Functions;
self::$email = new WooCommerce_Quick_Donation_Emails_Functions; self::$email = new WooCommerce_Quick_Donation_Emails_Functions;
self::$settings = new WooCommerce_Quick_Donation_Settings; self::$settings = new WooCommerce_Quick_Donation_Settings;
if($this->is_request('frontend')){ if($this->is_request('frontend')){
self::$shortcode = new WooCommerce_Quick_Donation_Shortcode; self::$shortcode = new WooCommerce_Quick_Donation_Shortcode;
$this->donation = new WooCommerce_Quick_Donation_Process; $this->donation = new WooCommerce_Quick_Donation_Process;
...@@ -141,7 +144,7 @@ class WooCommerce_Quick_Donation { ...@@ -141,7 +144,7 @@ class WooCommerce_Quick_Donation {
} }
if($this->is_request('admin')){ if($this->is_request('admin')){
$this->admin = new WooCommerce_Quick_Donation_Admin; self::$admin = new WooCommerce_Quick_Donation_Admin;
} }
...@@ -152,7 +155,7 @@ class WooCommerce_Quick_Donation { ...@@ -152,7 +155,7 @@ class WooCommerce_Quick_Donation {
* Function Get Call Admin * Function Get Call Admin
*/ */
public function admin(){ public function admin(){
return $this->admin; return self::$admin;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment