Changeset 1827446
- Timestamp:
- 02/23/2018 04:55:50 AM (8 years ago)
- Location:
- additional-charge/trunk
- Files:
-
- 2 edited
-
README.md (modified) (2 diffs)
-
class.additionalcharge.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
additional-charge/trunk/README.md
r1655616 r1827446 1 === WoocommerceAdditional Charge ===1 === Additional Charge === 2 2 3 3 Contributors: Yong Qui Zheng 4 Tags: woocommerce, extra charge, donation, surcharge, delivery, tips, shipping4 Tags: woocommerce, extra charge, additional charge, surcharge, delivery tip, tips, shipping,donation 5 5 Version:1.0.0 6 6 Requires at least: 3.2.1 7 Tested up to: 4. 7.47 Tested up to: 4.2.2 8 8 Stable tag: 1.0.0 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 12 ## Motivation 11 13 12 14 Provide a way for customer to add additional charge to WooCommerce checkout. It is useful for site that would like to do delivery service. Tipping service or anything that will allow customer to add a percent of their checkout price. … … 27 29 * Provide an additional box under the note section that will allow customer to add their tips, donations, etc base on total price 28 30 31 = 1.0.1 = 29 32 33 * Fixed issue where additional charge does not persist after checkout phrase on the woocommerce 3.8.x 34 35 -
additional-charge/trunk/class.additionalcharge.php
r1655604 r1827446 48 48 add_action('wp_ajax_add_charge',array('AdditionalCharge','add_charge'),10); 49 49 add_action('woocommerce_cart_calculate_fees', array('AdditionalCharge','add_charge_cost_from_session'),10); 50 50 add_action('woocommerce_thankyou',array('AdditionalCharge','unset_charge_session'),10); 51 51 } 52 public static function unset_charge_session(){ 53 // we need to unset the charge value in the session after order has been placed 54 unset($_SESSION['charge_value']);// try to unset the session before checkout cart begin 55 } 52 56 53 57 public static function add_charge(){ … … 65 69 } 66 70 public static function add_charge_cost_from_session() { 67 global $woocommerce; 68 $cart=$woocommerce->cart; 71 $cart= wc()->cart; 69 72 $charge=$_SESSION['charge_value']; 70 if( $charge!=null){73 if(!empty($charge)){ 71 74 $charge_label= empty(get_option(self::$fee_label_var))?self::$default_fee_label:get_option(self::$fee_label_var); 72 75 $cart->add_fee($charge_label,$charge); 73 unset($_SESSION['charge_value']);74 76 } 75 77 }
Note: See TracChangeset
for help on using the changeset viewer.