Commit 55a7c0fc authored by Varun Sridharan's avatar Varun Sridharan

Changes By Varun

* Fixed Count Notification Bubble Count
* Metabox Error While Creating New Order Via Admin
* Added Project & Doner Based Filter In Admin Listing
* Remodified WP LIST TABLE For Donation Listing
* New function to get user based donation ids get_user_donations_ids
* New template to list donations `myaccount/my-donations.php`
parent a1e127ca
...@@ -38,9 +38,10 @@ class WooCommerce_Quick_Donation_Admin_Function { ...@@ -38,9 +38,10 @@ class WooCommerce_Quick_Donation_Admin_Function {
public function add_wc_order_types($order_types,$type){ public function add_wc_order_types($order_types,$type){
$order_type = $order_types; $order_type = $order_types;
global $post_type;
if('' == $type){ if('' == $type){
$order_type[] = WC_QD_PT; $order_type[] = WC_QD_PT;
$order_type[] = 'wc_qd_orders'; $order_type[] = 'wcqd_project';
} }
return $order_type; return $order_type;
} }
......
...@@ -69,16 +69,29 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -69,16 +69,29 @@ class WooCommerce_Quick_Donation_Admin {
public function add_donation_notification_bubble() { public function add_donation_notification_bubble() {
global $submenu; global $submenu;
$c = $this->get_status_count();
if(isset($submenu['edit.php?post_type='.WC_QD_PT])){ if(isset($submenu['edit.php?post_type='.WC_QD_PT])){
foreach($submenu['edit.php?post_type='.WC_QD_PT] as $menuK => $menu){ foreach($submenu['edit.php?post_type='.WC_QD_PT] as $menuK => $menu){
if($menu[2] === 'wc_qd_orders' ){ if($menu[2] === 'wc_qd_orders' ){
$submenu['edit.php?post_type='.WC_QD_PT][$menuK][0] .= "<span class='update-plugins count-1'> $submenu['edit.php?post_type='.WC_QD_PT][$menuK][0] .= "<span class='update-plugins count-1'>
<span class='update-count'>0</span></span>"; <span class='update-count'>$c</span></span>";
} }
} }
} }
} }
private function get_status_count(){
$order_ids = WC_QD()->db()->get_donation_order_ids();
$count = 0;
foreach($order_ids as $id){
$order_status = get_post_status($id['donationid']);
if($order_status == 'wc-on-hold' || $order_status == 'wc-processing'){
$count++;
}
}
return $count;
}
/** /**
* Inits Admin Sttings * Inits Admin Sttings
*/ */
...@@ -95,7 +108,26 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -95,7 +108,26 @@ class WooCommerce_Quick_Donation_Admin {
$order_ids = WC_QD()->db()->get_donation_order_ids(); $order_ids = WC_QD()->db()->get_donation_order_ids();
$order_ids = WC_QD()->db()->extract_donation_id($order_ids); $order_ids = WC_QD()->db()->extract_donation_id($order_ids);
$args = array('post_type' => 'shop_order', 'post_status' => array_keys(wc_get_order_statuses()),'post__in' => $order_ids ); $args = array('posts_per_page' => '0',
'post_type' => 'shop_order',
'post_status' => array_keys(wc_get_order_statuses()),
'post__in' => $order_ids
);
if(isset($_GET['paged'])){$args['paged'] = $_GET['paged']; }
if(isset($_GET['m'])){ $args['m'] = $_GET['m'];}
if(isset($_GET['_customer_user'])) {
$args['meta_query'][]['key'] = '_customer_user';
$args['meta_query'][]['value'] = $_GET['_customer_user'];
$args['meta_query'][]['compare'] = '=';
}
if(isset($_GET['dproj'])) {
$args['meta_query'][]['key'] = '_project_details';
$args['meta_query'][]['value'] = $_GET['dproj'];
$args['meta_query'][]['compare'] = '=';
}
$wp_query = new WP_Query($args); $wp_query = new WP_Query($args);
require('wp-donation-listing-table.php'); require('wp-donation-listing-table.php');
tt_render_list_page($wp_query); tt_render_list_page($wp_query);
......
...@@ -35,7 +35,7 @@ class WooCommerce_Quick_Donation_Admin_Order_Page_Functions { ...@@ -35,7 +35,7 @@ class WooCommerce_Quick_Donation_Admin_Order_Page_Functions {
*/ */
public function shop_order_columns( $existing_columns ) { public function shop_order_columns( $existing_columns ) {
$existingc = $existing_columns; $existingc = $existing_columns;
if("wcqd_project_page_wc_qd_orders" == WC_QD()->admin()->current_screen()){ if(isset($_REQUEST['page']) && "wc_qd_orders" == $_REQUEST['page']){
$existingc = ''; $existingc = '';
$existingc['cb'] = $existing_columns['cb']; $existingc['cb'] = $existing_columns['cb'];
$existingc['order_status'] = $existing_columns['order_status']; $existingc['order_status'] = $existing_columns['order_status'];
......
...@@ -192,6 +192,7 @@ class WC_Quick_Donation_Meta_Box_Order_Data { ...@@ -192,6 +192,7 @@ class WC_Quick_Donation_Meta_Box_Order_Data {
<h4><?php _e( 'General Details', 'woocommerce' ); ?></h4> <h4><?php _e( 'General Details', 'woocommerce' ); ?></h4>
<p class="form-field form-field-wide"><label for="order_date"><?php _e( 'Order date:', 'woocommerce' ) ?></label> <p class="form-field form-field-wide"><label for="order_date"><?php _e( 'Order date:', 'woocommerce' ) ?></label>
<input type="hidden" name="post_is_donation" value="TRUE"/>
<input type="text" class="date-picker" name="order_date" id="order_date" maxlength="10" value="<?php echo date_i18n( 'Y-m-d', strtotime( $post->post_date ) ); ?>" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />@<input type="text" class="hour" placeholder="<?php esc_attr_e( 'h', 'woocommerce' ) ?>" name="order_date_hour" id="order_date_hour" maxlength="2" size="2" value="<?php echo date_i18n( 'H', strtotime( $post->post_date ) ); ?>" pattern="\-?\d+(\.\d{0,})?" />:<input type="text" class="minute" placeholder="<?php esc_attr_e( 'm', 'woocommerce' ) ?>" name="order_date_minute" id="order_date_minute" maxlength="2" size="2" value="<?php echo date_i18n( 'i', strtotime( $post->post_date ) ); ?>" pattern="\-?\d+(\.\d{0,})?" /> <input type="text" class="date-picker" name="order_date" id="order_date" maxlength="10" value="<?php echo date_i18n( 'Y-m-d', strtotime( $post->post_date ) ); ?>" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />@<input type="text" class="hour" placeholder="<?php esc_attr_e( 'h', 'woocommerce' ) ?>" name="order_date_hour" id="order_date_hour" maxlength="2" size="2" value="<?php echo date_i18n( 'H', strtotime( $post->post_date ) ); ?>" pattern="\-?\d+(\.\d{0,})?" />:<input type="text" class="minute" placeholder="<?php esc_attr_e( 'm', 'woocommerce' ) ?>" name="order_date_minute" id="order_date_minute" maxlength="2" size="2" value="<?php echo date_i18n( 'i', strtotime( $post->post_date ) ); ?>" pattern="\-?\d+(\.\d{0,})?" />
</p> </p>
...@@ -344,8 +345,13 @@ class WC_Quick_Donation_Meta_Box_Order_Data { ...@@ -344,8 +345,13 @@ class WC_Quick_Donation_Meta_Box_Order_Data {
public static function save( $post_id, $post ) { public static function save( $post_id, $post ) {
global $wpdb; global $wpdb;
if(isset($_POST['post_is_donation'])){
self::init_address_fields(); self::init_address_fields();
// Add key // Add key
add_post_meta( $post_id, '_order_key', uniqid( 'order_' ), true ); add_post_meta( $post_id, '_order_key', uniqid( 'order_' ), true );
...@@ -402,4 +408,5 @@ class WC_Quick_Donation_Meta_Box_Order_Data { ...@@ -402,4 +408,5 @@ class WC_Quick_Donation_Meta_Box_Order_Data {
wc_delete_shop_order_transients( $post_id ); wc_delete_shop_order_transients( $post_id );
} }
}
} }
...@@ -59,7 +59,17 @@ class WooCommerce_Quick_Donation_DB { ...@@ -59,7 +59,17 @@ class WooCommerce_Quick_Donation_DB {
public function get_donation_order_ids(){ public function get_donation_order_ids(){
global $wpdb; global $wpdb;
$db_request = $wpdb->get_results("SELECT donationid FROM ".WC_QD_TB,ARRAY_N); $db_request = $wpdb->get_results("SELECT donationid FROM ".WC_QD_TB,ARRAY_A);
if(!empty($db_request)){
return $db_request;
}
return array();
}
public function get_user_donations_ids($user_id = ''){
global $wpdb;
if($user_id == ''){ $user_id = get_current_user_id();}
$db_request = $wpdb->get_results("SELECT donationid FROM ".WC_QD_TB.' WHERE userid = '.$user_id,ARRAY_A);
if(!empty($db_request)){ if(!empty($db_request)){
return $db_request; return $db_request;
} }
......
...@@ -16,6 +16,8 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -16,6 +16,8 @@ class WooCommerce_Quick_Donation_Functions {
'emails/donation-customer-invoice.php' => 'emails/donation-customer-invoice.php', 'emails/donation-customer-invoice.php' => 'emails/donation-customer-invoice.php',
'emails/plaint/donation-customer-invoice.php' => 'emails/plain/donation-customer-invoice.php', 'emails/plaint/donation-customer-invoice.php' => 'emails/plain/donation-customer-invoice.php',
'myaccount/my-donations.php' => 'myaccount/my-donations.php',
), ),
'is_donation' => array( 'is_donation' => array(
...@@ -52,7 +54,6 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -52,7 +54,6 @@ class WooCommerce_Quick_Donation_Functions {
add_filter( 'the_title', array($this,'wc_page_endpoint_title' ),1); add_filter( 'the_title', array($this,'wc_page_endpoint_title' ),1);
} }
public function wc_page_endpoint_title($title){ public function wc_page_endpoint_title($title){
global $wp_query; global $wp_query;
...@@ -166,7 +167,6 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -166,7 +167,6 @@ class WooCommerce_Quick_Donation_Functions {
} }
public function load_template($file,$path){ public function load_template($file,$path){
$wc_get_template = function_exists('wc_get_template') ? 'wc_get_template' : 'woocommerce_get_template'; $wc_get_template = function_exists('wc_get_template') ? 'wc_get_template' : 'woocommerce_get_template';
$wc_get_template( $file,array(), '', $path); $wc_get_template( $file,array(), '', $path);
} }
...@@ -232,6 +232,7 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -232,6 +232,7 @@ class WooCommerce_Quick_Donation_Functions {
public function get_template($located, $template_name, $args, $template_path, $default_path ){ public function get_template($located, $template_name, $args, $template_path, $default_path ){
$file = $located; $file = $located;
$order_id = 0;
if(isset($args['order_id'])){ $order_id = $args['order_id']; } if(isset($args['order_id'])){ $order_id = $args['order_id']; }
if(isset($args['order']->id)){ $order_id = $args['order']->id; } if(isset($args['order']->id)){ $order_id = $args['order']->id; }
...@@ -248,6 +249,7 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -248,6 +249,7 @@ class WooCommerce_Quick_Donation_Functions {
} }
} }
} }
return $file; return $file;
} }
} }
<?php
/**
* functionality of the plugin.
* @author Varun Sridharan <varunsridharan23@gmail.com>
*/
if ( ! defined( 'WPINC' ) ) { die; }
class WooCommerce_Quick_Donation_MyAccount_Fuctions {
private $order_ids;
public function __construct(){
$order_ids = WC_QD()->db()->get_user_donations_ids();
$this->order_ids = WC_QD()->db()->extract_donation_id($order_ids);
add_filter( 'woocommerce_my_account_my_orders_query',array($this,'change_myaccount_query'));
add_action( 'woocommerce_before_my_account' , array($this,'show_recent_donations'));
}
public function change_myaccount_query($query){
$query['exclude'] = $this->order_ids;
return $query;
}
public function show_recent_donations(){
wc_get_template( 'myaccount/my-donations.php' , array( 'donation_ids' => $this->order_ids ) );
}
}
?>
\ No newline at end of file
...@@ -6,7 +6,7 @@ Requires at least: 3.0 or higher ...@@ -6,7 +6,7 @@ Requires at least: 3.0 or higher
Tested up to: 4.4 Tested up to: 4.4
WC requires at least: 1.0 WC requires at least: 1.0
WC tested up to: 2.4.8 WC tested up to: 2.4.8
Stable tag: 1.3.4 Beta Stable tag: 1.3.5 Beta
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
...@@ -185,6 +185,14 @@ Yes you can! Join in on our <a href="https://github.com/technofreaky/woocomerce- ...@@ -185,6 +185,14 @@ Yes you can! Join in on our <a href="https://github.com/technofreaky/woocomerce-
== Changelog == == Changelog ==
= 1.3.5 BETA =
**Fixes**
* Metabox Error While Creating New Order Via Admin
* Fixed Count Notification Bubble Count
* Minor Bug Fix
= 1.3.4 BETA = = 1.3.4 BETA =
**Fixes** **Fixes**
......
<?php <?php
global $donation_box,$donation_price,$currency; global $donation_box,$donation_price,$currency;
wc_print_notices();
?> ?>
<form method="post"> <form method="post">
<table> <table>
<tr> <tr>
<td> Donation Project </td> <td> Donation Project </td>
<td> <?php echo $donation_box; ?></td> <td> <?php echo $donation_box; ?></td>
...@@ -16,5 +17,6 @@ global $donation_box,$donation_price,$currency; ...@@ -16,5 +17,6 @@ global $donation_box,$donation_price,$currency;
<td></td> <td></td>
<td><input type="submit" name="donation_add" value="Add Donation"/></td> <td><input type="submit" name="donation_add" value="Add Donation"/></td>
</tr> </tr>
</table> </table>
</form> </form>
\ No newline at end of file
<?php
/**
* My Orders
*
* Shows recent orders on the account page
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.3.10
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
$customer_orders = get_posts( array(
'include' => $donation_ids,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => wc_get_order_types( 'view-orders' ),
'post_status' => array_keys( wc_get_order_statuses() )
) );
if ( $customer_orders ) : ?>
<h2><?php echo apply_filters( 'woocommerce_my_account_my_orders_title', __( 'Recent Donations', WC_QD_TXT) ); ?></h2>
<table class="shop_table shop_table_responsive my_account_orders">
<thead>
<tr>
<th class="order-number"><span class="nobr"><?php _e( 'ID', WC_QD_TXT ); ?></span></th>
<th class="order-number"><span class="nobr"><?php _e( 'Project', WC_QD_TXT ); ?></span></th>
<th class="order-date"><span class="nobr"><?php _e( 'Date', WC_QD_TXT ); ?></span></th>
<th class="order-status"><span class="nobr"><?php _e( 'Status', WC_QD_TXT ); ?></span></th>
<th class="order-total"><span class="nobr"><?php _e( 'Total', WC_QD_TXT ); ?></span></th>
<th class="order-actions">&nbsp;</th>
</tr>
</thead>
<tbody><?php
foreach ( $customer_orders as $customer_order ) {
$order = wc_get_order( $customer_order );
$order->populate( $customer_order );
$item_count = $order->get_item_count();
?><tr class="order">
<td class="order-number" data-title="<?php esc_attr_e( 'Order Number', 'woocommerce' ); ?>">
<a href="<?php echo esc_url( $order->get_view_order_url() ); ?>">
<?php echo _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number(); ?>
</a>
</td>
<td class="order-number" data-title="<?php esc_attr_e( 'Project', 'woocommerce' ); ?>">
<?php $project_id = WC_QD()->db()->get_project_id($order->id);?>
<a href="<?php echo get_permalink($project_id); ?>">
<?php echo get_the_title($project_id); ?>
</a>
</td>
<td class="order-date" data-title="<?php esc_attr_e( 'Date', 'woocommerce' ); ?>">
<time datetime="<?php echo date( 'Y-m-d', strtotime( $order->order_date ) ); ?>" title="<?php echo esc_attr( strtotime( $order->order_date ) ); ?>"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></time>
</td>
<td class="order-status" data-title="<?php esc_attr_e( 'Status', 'woocommerce' ); ?>" style="text-align:left; white-space:nowrap;">
<?php echo wc_get_order_status_name( $order->get_status() ); ?>
</td>
<td class="order-total" data-title="<?php esc_attr_e( 'Total', 'woocommerce' ); ?>">
<?php echo sprintf( _n( '%s for %s item', '%s for %s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ); ?>
</td>
<td class="order-actions">
<?php
$actions = array();
if ( $order->needs_payment() ) {
$actions['pay'] = array(
'url' => $order->get_checkout_payment_url(),
'name' => __( 'Pay', 'woocommerce' )
);
}
if ( in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) {
$actions['cancel'] = array(
'url' => $order->get_cancel_order_url( wc_get_page_permalink( 'myaccount' ) ),
'name' => __( 'Cancel', 'woocommerce' )
);
}
$actions['view'] = array(
'url' => $order->get_view_order_url(),
'name' => __( 'View', 'woocommerce' )
);
$actions = apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order );
if ( $actions ) {
foreach ( $actions as $key => $action ) {
echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
}
}
?>
</td>
</tr><?php
}
?></tbody>
</table>
<?php endif; ?>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Plugin Name: WooCommerce Quick Donation * Plugin Name: WooCommerce Quick Donation
* Plugin URI: https://wordpress.org/plugins/woocommerce-plugin-boiler-plate/ * Plugin URI: https://wordpress.org/plugins/woocommerce-plugin-boiler-plate/
* Description: Turns WooCommerce Into Online Donation * Description: Turns WooCommerce Into Online Donation
* Version: 1.3.4 BETA * Version: 1.3.5 BETA
* Author: Varun Sridharan * Author: Varun Sridharan
* Author URI: http://varunsridharan.in * Author URI: http://varunsridharan.in
* Text Domain: woocommerce-quick-donation * Text Domain: woocommerce-quick-donation
...@@ -18,7 +18,7 @@ class WooCommerce_Quick_Donation { ...@@ -18,7 +18,7 @@ class WooCommerce_Quick_Donation {
/** /**
* @var string * @var string
*/ */
public $version = '1.3.4'; public $version = '1.3.5';
/** /**
* @var WooCommerce The single instance of the class * @var WooCommerce The single instance of the class
...@@ -104,6 +104,7 @@ class WooCommerce_Quick_Donation { ...@@ -104,6 +104,7 @@ class WooCommerce_Quick_Donation {
if($this->is_request('frontend')){ if($this->is_request('frontend')){
$this->load_files(WC_QD_INC.'class-quick-donation-process.php'); $this->load_files(WC_QD_INC.'class-quick-donation-process.php');
$this->load_files(WC_QD_INC.'class-wc-myaccount-functions.php');
$this->load_files(WC_QD_INC.'class-shortcode-handler.php'); $this->load_files(WC_QD_INC.'class-shortcode-handler.php');
} }
...@@ -125,6 +126,7 @@ class WooCommerce_Quick_Donation { ...@@ -125,6 +126,7 @@ class WooCommerce_Quick_Donation {
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;
$this->my_account = new WooCommerce_Quick_Donation_MyAccount_Fuctions;
} }
if($this->is_request('admin')){ if($this->is_request('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