Commit 17cbd4b4 authored by Varun Sridharan's avatar Varun Sridharan

Issue Fixes & New Feature Added

Fixed Issue #65
Added #61
Seperated template File List
Added Front End CSS Files
Minor bug fix
parent 325d99e0
...@@ -7,63 +7,11 @@ if ( ! defined( 'WPINC' ) ) { die; } ...@@ -7,63 +7,11 @@ if ( ! defined( 'WPINC' ) ) { die; }
class WooCommerce_Quick_Donation_Functions { class WooCommerce_Quick_Donation_Functions {
protected static $project_db_list = null; protected static $project_db_list = null;
public static $search_template = array( public static $search_template = null;
'general' => array(
'donation-form.php' => 'donation-form.php',
'field-radio.php' => 'fields/field-radio.php',
'field-select.php' => 'fields/field-select.php',
'field-text.php' => 'fields/field-text.php',
'myaccount/my-donations.php' => 'myaccount/my-donations.php',
'cart/mini-cart.php' => 'cart/donation-mini-cart.php',
'projects/single.php' => 'projects/single.php',
),
'is_donation' => array(
'cart/cart-item-data.php' => 'cart/donation-cart-item-data',
'cart/cart-shipping.php' => 'cart/donation-cart-shipping.php',
'cart/cart-totals.php' => 'cart/donation-cart-totals.php',
'cart/cart.php' => 'cart/donation-cart.php',
'cart/proceed-to-checkout-button.php' => 'cart/donation-proceed-to-checkout-button.php',
'checkout/cart-errors.php' => 'checkout/donation-cart-errors.php',
'checkout/form-billing.php' => 'checkout/donation-form-billing.php',
'checkout/form-checkout.php' => 'checkout/donation-form-checkout.php',
'checkout/form-coupon.php' => 'checkout/donation-form-coupon.php',
'checkout/form-login.php' => 'checkout/donation-form-login.php',
'checkout/form-pay.php' => 'checkout/donation-form-pay.php',
'checkout/form-shipping.php' => 'checkout/donation-form-shipping.php',
'checkout/payment-method.php' => 'checkout/donation-payment-method.php',
'checkout/payment.php' => 'checkout/donation-payment.php',
'checkout/review-order.php' => 'checkout/donation-review-order.php',
),
'after_order' => array(
'checkout/thankyou.php' => 'checkout/donation-thankyou.php',
'myaccount/view-order.php' => 'myaccount/view-donation.php',
'order/order-details.php' => 'order/donation-order-details.php',
'order/order-details-item.php' => 'order/donation-order-details-item.php',
'order/order-details-customer.php' => 'order/donation-order-details-customer.php',
'emails/email-styles.php' => 'emails/donation-email-styles.php',
'emails/donation-admin-new.php' => 'emails/donation-admin-new.php',
'emails/email-addresses.php' => 'emails/donation-email-addresses.php',
'emails/donation-email-footer.php' => 'emails/donation-email-footer.php',
'emails/donation-email-header.php' => 'emails/donation-email-header.php',
'emails/email-order-items.php' => 'emails/donation-email-order-items.php',
'emails/plain/email-addresses.php' => 'emails/plain/donation-email-addresses.php',
'emails/plain/email-order-items.php' => 'emails/plain/donation-email-order-items.php',
'emails/plain/donation-customer-invoice.php' => 'emails/plain/donation-customer-invoice.php',
'emails/donation-processing.php' => 'emails/donation-processing.php',
'emails/plain/donation-processing.php' => 'emails/plain/donation-processing.php',
)
);
function __construct(){ function __construct(){
global $wc_qd_template_list;
self::$search_template = $wc_qd_template_list;
add_filter( 'wc_get_template',array($this,'get_template'),10,5); add_filter( 'wc_get_template',array($this,'get_template'),10,5);
add_filter( 'woocommerce_email_classes', array($this,'add_email_classes')); add_filter( 'woocommerce_email_classes', array($this,'add_email_classes'));
add_action( 'woocommerce_available_payment_gateways',array($this,'remove_gateway')); add_action( 'woocommerce_available_payment_gateways',array($this,'remove_gateway'));
...@@ -189,9 +137,12 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -189,9 +137,12 @@ class WooCommerce_Quick_Donation_Functions {
$class = apply_filters('wcqd_project_name_'.$type.'_class',array(),$type); $class = apply_filters('wcqd_project_name_'.$type.'_class',array(),$type);
$custom_attributes = apply_filters('wcqd_project_name_'.$type.'_attribute',array(),$type); $custom_attributes = apply_filters('wcqd_project_name_'.$type.'_attribute',array(),$type);
$is_grouped = $grouped; $is_grouped = $grouped;
$project_list = $this->get_porject_list($grouped); $project_list = '';
if($type != 'hidden'){
$class = implode(' ',$class); $project_list = $this->get_porject_list($grouped);
}
$class = implode(' ',$class);
$attributes = ''; $attributes = '';
foreach($custom_attributes as $attr_key => $attr_val) { foreach($custom_attributes as $attr_key => $attr_val) {
$attributes .= $attr_key.'="'.$attr_val.'" '; $attributes .= $attr_key.'="'.$attr_val.'" ';
...@@ -212,6 +163,7 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -212,6 +163,7 @@ class WooCommerce_Quick_Donation_Functions {
public function generate_price_box($predefined = false){ public function generate_price_box($predefined = false){
global $id, $name, $class, $field_output,$attributes,$value; global $id, $name, $class, $field_output,$attributes,$value;
$type = 'text'; $type = 'text';
$field_type = 'number';
if($predefined){$type = 'select';} if($predefined){$type = 'select';}
$field_output = ''; $field_output = '';
$id = 'donation_price'; $id = 'donation_price';
...@@ -246,13 +198,8 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -246,13 +198,8 @@ class WooCommerce_Quick_Donation_Functions {
'project_list' => $project_list, 'project_list' => $project_list,
'pre_selected' => false, 'pre_selected' => false,
'attributes' => $attributes, 'attributes' => $attributes,
'value' => $value)); 'value' => $value,
/*$field_output = $this->load_template('field-text.php',WC_QD_TEMPLATE . 'fields/' ,array('id' => $id, 'field_type' => $field_type));
'name' => $name,
'class' => $class,
'field_output' => $field_output,
'attributes' => $attributes,
'value' => $value)); */
return $field_output; return $field_output;
} }
......
...@@ -12,11 +12,12 @@ if ( ! defined( 'WPINC' ) ) { die; } ...@@ -12,11 +12,12 @@ if ( ! defined( 'WPINC' ) ) { die; }
class WooCommerce_Quick_Donation_Shortcode { class WooCommerce_Quick_Donation_Shortcode {
public function __construct() { public function __construct() {
add_shortcode( 'wc_quick_donation', array($this, 'shortcode_handler' )); add_shortcode( 'wc_quick_donation', array($this, 'wc_quick_donation_handler' ));
add_shortcode( 'wc_qd_single', array($this, 'wc_quick_donation_single_handler' ));
} }
public function shortcode_handler($settings){ public function wc_quick_donation_handler($settings){
global $donation_box,$donation_price,$currency; global $donation_box,$donation_price,$currency;
$settings = shortcode_atts( array( $settings = shortcode_atts( array(
...@@ -37,18 +38,56 @@ class WooCommerce_Quick_Donation_Shortcode { ...@@ -37,18 +38,56 @@ class WooCommerce_Quick_Donation_Shortcode {
if($settings['show_errors']){ if($settings['show_errors']){
ob_start(); ob_start();
wc_print_notices(); wc_print_notices();
$messages .= ob_get_clean(); $return_value .= ob_get_clean();
ob_flush(); ob_flush();
} }
do_action('wc_quick_donation_before_doantion_form',$return_value , $settings['type'],$settings['grouped']); do_action('wc_quick_donation_before_doantion_form',$return_value , $settings['type'],$settings['grouped']);
$messages .= WC_QD()->f()->load_template('donation-form.php',WC_QD_TEMPLATE,array('donation_box' => $donation_box, $return_value .= WC_QD()->f()->load_template('donation-form.php',WC_QD_TEMPLATE,array('donation_box' => $donation_box,
'donation_price' => $donation_price, 'donation_price' => $donation_price,
'currency' => $currency)); 'currency' => $currency));
do_action('wc_quick_donation_after_doantion_form',$return_value , $settings['type'],$settings['grouped']); do_action('wc_quick_donation_after_doantion_form',$return_value , $settings['type'],$settings['grouped']);
return $messages; return $return_value;
} }
public function wc_quick_donation_single_handler($settings){
$settings = shortcode_atts( array(
'title' => true,
'content' => true,
'defined_amount' => false,
'id' => false,
), $settings );
$title = '';
$content = '';
$project = get_post($settings['id']);
setup_postdata( $project );
$donation_price = WC_QD()->f()->generate_price_box($settings['defined_amount']);
$donation_price .= WC_QD()->f()->generate_donation_selbox(false,'hidden',$settings['id']);
if($settings['title']){
$title = get_the_title($settings['id']);
}
if($settings['content']){
$content = get_the_excerpt();
}
$currency = get_woocommerce_currency_symbol();
$return_value = '';
$messages = '';
$return_value .= WC_QD()->f()->load_template('single-donation-form.php',WC_QD_TEMPLATE,array(
'project_id' => $settings['id'],
'project' => $project,
'donation_price' => $donation_price,
'currency' => $currency,
'title' => $title,
'content' => $content,
));
return $return_value;
}
} }
\ No newline at end of file
.wcqd-single-quick-container {
border: 1px solid #ddd;
width: auto;
max-width: 300px;
padding: 20px;
}
.wcqd-single-quick-container h3 {
margin-top: 0;
padding-top: 0;
font-family: inherit;
color: #000;
}
.wcqd-single-quick-container p {
font-family: inherit;
color: #666;
}
.wcqd-single-quick-container input[type="number"] {
padding: 5px;
width: 60%;
max-width: 60%;
font-size: 14px;
margin: 0 10px 0 0;
}
.wcqd-single-quick-container input[type="submit"] {
padding: 8px;
border: none;
font-size: 14px;
color: #000;
background: #ddd;
}
.wcqd-single-quick-container input[type="submit"]:hover {
cursor: pointer;
background: #444;
color: #fff;
}
\ No newline at end of file
<?php
global $wc_qd_template_list;
$wc_qd_template_list = array();
$wc_qd_template_list['general'] = array(
'donation-form.php' => 'donation-form.php',
'single-donation-form.php' => 'single-donation-form.php',
'field-radio.php' => 'fields/field-radio.php',
'field-select.php' => 'fields/field-select.php',
'field-text.php' => 'fields/field-text.php',
'field-hidden.php' => 'fields/field-hidden.php',
'myaccount/my-donations.php' => 'myaccount/my-donations.php',
'projects/single.php' => 'projects/single.php',
);
$wc_qd_template_list['is_donation'] = array(
'cart/mini-cart.php' => 'cart/donation-mini-cart.php',
'cart/cart-item-data.php' => 'cart/donation-cart-item-data',
'cart/cart-shipping.php' => 'cart/donation-cart-shipping.php',
'cart/cart-totals.php' => 'cart/donation-cart-totals.php',
'cart/cart.php' => 'cart/donation-cart.php',
'cart/proceed-to-checkout-button.php' => 'cart/donation-proceed-to-checkout-button.php',
'checkout/cart-errors.php' => 'checkout/donation-cart-errors.php',
'checkout/form-billing.php' => 'checkout/donation-form-billing.php',
'checkout/form-checkout.php' => 'checkout/donation-form-checkout.php',
'checkout/form-coupon.php' => 'checkout/donation-form-coupon.php',
'checkout/form-login.php' => 'checkout/donation-form-login.php',
'checkout/form-pay.php' => 'checkout/donation-form-pay.php',
'checkout/form-shipping.php' => 'checkout/donation-form-shipping.php',
'checkout/payment-method.php' => 'checkout/donation-payment-method.php',
'checkout/payment.php' => 'checkout/donation-payment.php',
'checkout/review-order.php' => 'checkout/donation-review-order.php',
);
$wc_qd_template_list['after_order'] = array(
'checkout/thankyou.php' => 'checkout/donation-thankyou.php',
'myaccount/view-order.php' => 'myaccount/view-donation.php',
'order/order-details.php' => 'order/donation-order-details.php',
'order/order-details-item.php' => 'order/donation-order-details-item.php',
'order/order-details-customer.php' => 'order/donation-order-details-customer.php',
'emails/email-styles.php' => 'emails/donation-email-styles.php',
'emails/donation-admin-new.php' => 'emails/donation-admin-new.php',
'emails/email-addresses.php' => 'emails/donation-email-addresses.php',
'emails/donation-email-footer.php' => 'emails/donation-email-footer.php',
'emails/donation-email-header.php' => 'emails/donation-email-header.php',
'emails/email-order-items.php' => 'emails/donation-email-order-items.php',
'emails/plain/email-addresses.php' => 'emails/plain/donation-email-addresses.php',
'emails/plain/email-order-items.php' => 'emails/plain/donation-email-order-items.php',
'emails/plain/donation-customer-invoice.php' => 'emails/plain/donation-customer-invoice.php',
'emails/donation-processing.php' => 'emails/donation-processing.php',
'emails/plain/donation-processing.php' => 'emails/plain/donation-processing.php',
);
?>
\ No newline at end of file
<?php
/**
* HTML Hidden Field Template
*
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/fields
* @version 0.1
*/
$field_output = '<input
id="'.$id.'"
type="hidden"
name="'.$name.'"
class="'.$class.'"
value="'.$pre_selected.'"
'.$attributes.' />';
echo $field_output;
?>
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
*/ */
?> ?>
<input <input
type="text" type="<?php echo $field_type; ?>"
id="<?php echo $id; ?>" id="<?php echo $id; ?>"
name="<?php echo $name; ?>" name="<?php echo $name; ?>"
class="<?php echo $class.' '.$attributes; ?>" class="<?php echo $class.' '.$attributes; ?>"
......
<?php
/**
* Donation Form
*
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates
* @version 0.1
*/
?>
<div class="wcqd-single-quick-container">
<form class="wcqd-single-quick-form" name="single_donation_form" method="post">
<?php if(!empty($title)){?>
<h3><?php echo $title; ?></h3>
<?php } ?>
<?php if(!empty($content)){?>
<p><?php echo $content; ?></p>
<?php }?>
<?php echo $donation_price; ?>
<input type="submit" name="donation_add" value="Add Donation"/>
</form>
</div>
\ No newline at end of file
...@@ -66,6 +66,7 @@ class WooCommerce_Quick_Donation { ...@@ -66,6 +66,7 @@ class WooCommerce_Quick_Donation {
$this->init_class(); $this->init_class();
add_action('plugins_loaded', array( $this, 'after_plugins_loaded' )); add_action('plugins_loaded', array( $this, 'after_plugins_loaded' ));
add_filter('load_textdomain_mofile', array( $this, 'load_plugin_mo_files' ), 10, 2); add_filter('load_textdomain_mofile', array( $this, 'load_plugin_mo_files' ), 10, 2);
add_action( 'wp_enqueue_scripts', array( $this,'enqueue_and_register_styles') );
} }
/** /**
...@@ -107,7 +108,8 @@ class WooCommerce_Quick_Donation { ...@@ -107,7 +108,8 @@ class WooCommerce_Quick_Donation {
* Loads Required Plugins For Plugin * Loads Required Plugins For Plugin
*/ */
private function load_required_files(){ private function load_required_files(){
$this->load_files(WC_QD_INC.'wc-quick-donation-*.php'); $this->load_files(WC_QD_INC.'vars.php');
$this->load_files(WC_QD_INC.'wc-quick-donation-*.php');
$this->load_files(WC_QD_ADMIN.'wps/*.php'); $this->load_files(WC_QD_ADMIN.'wps/*.php');
//$this->load_files(WC_QD_INC.'class-admin-notice.php'); //$this->load_files(WC_QD_INC.'class-admin-notice.php');
$this->load_files(WC_QD_INC.'class-post-*.php'); $this->load_files(WC_QD_INC.'class-post-*.php');
...@@ -218,6 +220,13 @@ class WooCommerce_Quick_Donation { ...@@ -218,6 +220,13 @@ class WooCommerce_Quick_Donation {
} }
return $mofile; return $mofile;
} }
public function enqueue_and_register_styles(){
wp_register_style('woocommerce-quick-donation', WC_QD_CSS.'wc-qd-style.css');
wp_enqueue_style('woocommerce-quick-donation');
}
/** /**
* Define Required Constant * Define Required Constant
......
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