1,"message"=>$message)); }else{ echo json_encode(array("status"=>0,"message"=>__("Failed to add tip","shundao"))); } exit(); } public static function add_charge_cost_from_session() { $cart= wc()->cart; $charge=$_SESSION['charge_value']; if(!empty($charge)){ $charge_label= empty(get_option(self::$fee_label_var))?self::$default_fee_label:get_option(self::$fee_label_var); $cart->add_fee($charge_label,$charge); } } public static function init_domain(){ load_plugin_textdomain( self::$domain ); } public static function init_session(){ $status = session_status(); if ( PHP_SESSION_DISABLED === $status ) { // That's why you cannot rely on sessions! return; } if ( PHP_SESSION_NONE === $status ) { session_start(); } } public static function registerScriptAndStyle(){ // try loading the script $initJs =plugins_url('/public/assets/js/init.js', __FILE__); $styleCss =plugins_url('/public/assets/css/additionalcharge.css', __FILE__); wp_register_script( 'ac_script',$initJs ); wp_register_style( 'ac_style', $styleCss); } public static function enqueueScriptAndStyle(){ wp_enqueue_script('ac_script'); wp_enqueue_style('ac_style'); } /** * Attached to activate_{ plugin_basename( __FILES__ ) } by register_activation_hook() * @static */ public static function plugin_activation() { if(!class_exists( 'WooCommerce' )){ self::failActivation(__("WooCommerce is require for this plugin",ADDITIONAL_CHARGE_DOMAIN)); // woocommerce doesn't exist exit; } } private static function failActivation($message){ ?>
cart->cart_contents_total; ?>