Skip to content

Commit

Permalink
version 1.0.1 released
Browse files Browse the repository at this point in the history
  • Loading branch information
manchumahara committed Sep 12, 2019
1 parent 26bbf2b commit 0c14860
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 4 deletions.
10 changes: 9 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: codeboxr, manchumahara
Tags: woocommerce
Requires at least: 3.0
Tested up to: 5.2.3
Stable tag: 1.0.0
Stable tag: 1.0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -20,7 +20,15 @@ tutorial and customized as need.
2. If free downloadable product then changes label from "Add to Cart" to "Download"
3. If free downloadable product then changes Price from "$0.00" to "Free"
4. Removes 'company', 'country', 'phone', 'address_1', 'address_2', 'city', 'state', 'postcode' from billing and shipping fields, remove their validation and required fields
5. Allow guest checkout for free orders
6. Disable admin email for free orders
7. Disable customer email for free orders

== Changelog ==
= 1.0.0 =
* Allow guest checkout for free orders
* Disable admin email for free orders
* Disable customer email for free orders

= 1.0.0 =
* First release
72 changes: 69 additions & 3 deletions cbxwoofreeproductquickcheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
*
* @link codeboxr.com
* @since 1.0.0
* @package Cbxwpbookmark
* @package cbxwoofreeproductquickcheckout
*
* @wordpress-plugin
* Plugin Name: CBX Woo Free Product Quick Checkout
* Plugin URI: https://github.com/manchumahara/cbxwoofreeproductquickcheckout
* Description: Quick checkout for woocommerce free products
* Version: 1.0.0
* Version: 1.0.1
* Author: Codeboxr Team
* Author URI: https://codeboxr.com
* License: GPL-2.0+
Expand All @@ -31,7 +31,7 @@


defined('CBXWOOFREEPRODUCTQUICKCHECKOUT_PLUGIN_NAME') or define('CBXWOOFREEPRODUCTQUICKCHECKOUT_PLUGIN_NAME', 'cbxwoofreeproductquickcheckout');
defined('CBXWOOFREEPRODUCTQUICKCHECKOUT_PLUGIN_VERSION') or define('CBXWOOFREEPRODUCTQUICKCHECKOUT_PLUGIN_VERSION', '1.0.0');
defined('CBXWOOFREEPRODUCTQUICKCHECKOUT_PLUGIN_VERSION') or define('CBXWOOFREEPRODUCTQUICKCHECKOUT_PLUGIN_VERSION', '1.0.1');
defined('CBXWOOFREEPRODUCTQUICKCHECKOUT_BASE_NAME') or define('CBXWOOFREEPRODUCTQUICKCHECKOUT_BASE_NAME', plugin_basename(__FILE__));
defined('CBXWOOFREEPRODUCTQUICKCHECKOUT_ROOT_PATH') or define('CBXWOOFREEPRODUCTQUICKCHECKOUT_ROOT_PATH', plugin_dir_path(__FILE__));
defined('CBXWOOFREEPRODUCTQUICKCHECKOUT_ROOT_URL') or define('CBXWOOFREEPRODUCTQUICKCHECKOUT_ROOT_URL', plugin_dir_url(__FILE__));
Expand Down Expand Up @@ -75,6 +75,11 @@ public function __construct() {
add_filter( 'woocommerce_checkout_fields', array($this, 'custom_override_checkout_fields'), 9999 );
add_filter( 'woocommerce_default_address_fields', array($this, 'custom_override_default_address_fields'), 9999 );
add_filter('woocommerce_add_to_cart_redirect', array($this, 'redirect_add_to_cart'));

//guest checkout
add_filter( 'pre_option_woocommerce_enable_guest_checkout', array($this, 'enable_guest_checkout_based_on_product') );
add_filter( 'woocommerce_email_enabled_new_order', array($this, 'disable_email_new_order'), 10, 2 );
add_filter( 'woocommerce_email_recipient_customer_completed_order', array($this, 'product_cat_avoid_processing_email_notification'), 10, 2 );
}//end of constructor

/**
Expand Down Expand Up @@ -247,6 +252,67 @@ public function redirect_add_to_cart() {
return wc_get_checkout_url();
}//end method redirect_add_to_cart

/**
* Allow guest checkout for free orders
*
* @param $value
*
* @return string
*/
public function enable_guest_checkout_based_on_product($value){
if ( WC()->cart && WC()->cart->needs_payment() ) {
return $value;
}

return "yes";
}

/**
* Disable amdin email for new order
*
* @param $enabled
* @param $order
*
* @return bool
*/
public function disable_email_new_order($enabled, $order){
if ($order instanceof WC_Order) {

$order_total = floatval($order->get_total());

if ($order_total == 0) {
return false;
}

}

return $enabled;
}//end method disable_email_new_order

/**
* Disable customer email for free order
*
* @param $recipient
* @param $order
*
* @return string
*/
public function product_cat_avoid_processing_email_notification( $recipient, $order ) {
if( is_admin() ) return $recipient;

if ($order instanceof WC_Order) {

$order_total = floatval($order->get_total());

if ($order_total == 0) {
return '';
}

}

return $recipient;
}//end emthod product_cat_avoid_processing_email_notification

}//end class CBXWooFreeProductQuickCheckout

new CBXWooFreeProductQuickCheckout();

0 comments on commit 0c14860

Please sign in to comment.