' . sprintf( esc_html__( 'All In One Woo requires WooCommerce to be installed and active. You can download %s here.', 'all_in_one_woo' ), 'WooCommerce' ) . '

'; } add_action( 'plugins_loaded', 'woocommerce_allinone_init' ); function woocommerce_allinone_init() { if ( ! class_exists( 'WooCommerce' ) ) { add_action( 'admin_notices', 'woocommerce_allinone_missing_wc_notice' ); return; } if (!class_exists("AllInOneWoo")){ class AllInOneWoo { function __construct(){ add_action('admin_init', array($this, 'register_allinone_settings')); add_action('admin_enqueue_scripts', array($this,'all_in_one_woo_enqueue') ); add_action('admin_menu', array($this, 'all_in_one_woo') ); add_filter( 'woocommerce_product_add_to_cart_text', array($this,'all_in_one_woo_add_to_cart_text' )); add_filter( 'woocommerce_product_single_add_to_cart_text', array($this,'all_in_one_woo_add_to_cart_text' )); add_filter( 'woocommerce_booking_single_add_to_cart_text', array($this,'all_in_one_woo_add_to_cart_text' )); add_filter( 'gettext', array($this, 'all_in_one_woo_cart_text')); add_filter( 'woocommerce_shipping_package_name', array($this, 'all_in_one_woo_cart_shipping')); add_filter( 'wc_empty_cart_message', array($this, 'all_in_one_woo_wc_empty_cart_message' )); add_filter( 'woocommerce_return_to_shop_redirect', array($this, 'wc_empty_cart_redirect_url' )); add_filter( 'wc_product_sku_enabled', array($this, 'all_in_one_woo_remove_product_page_sku' )); add_action('woocommerce_after_single_product_summary', array($this, 'all_in_one_woo_remove_related_products')); add_action( 'woocommerce_single_product_summary', array($this, 'all_in_one_woo_woocommerce_template_single_meta') ); add_filter( 'woocommerce_product_tabs', array($this, 'all_in_one_woo_remove_product_tabs'), 98); add_filter( 'woocommerce_product_tabs', array($this, 'all_in_one_woo_add_product_tabs')); add_filter('woocommerce_product_data_tabs', array($this, 'all_in_one_woo_product_settings_tabs' )); add_action( 'woocommerce_product_data_panels', array($this, 'all_in_one_product_panels') ); add_action( 'woocommerce_process_product_meta', array($this, 'all_in_one_save_fields'), 10); //add_filter( 'woocommerce_product_tabs', array($this, 'all_in_one_woo_rename_tabs'), 98); add_filter( 'woocommerce_sale_flash', array($this, 'all_in_one_woo_custom_replace_sale_text') ); add_filter( 'woocommerce_get_availability', array($this, 'all_in_one_woo_custom_get_availability')); add_filter( 'woocommerce_checkout_fields', array($this, 'all_in_one_woo_custom_rename_wc_checkout_fields'), 10 ); add_filter( 'woocommerce_default_address_fields' , array($this, 'custom_override_default_address_fields' )); add_action( 'woocommerce_admin_order_data_after_shipping_address', array($this, 'my_shipping_custom_checkout_field_display_admin_order_meta'), 10, 1 ); add_action( 'woocommerce_admin_order_data_after_billing_address', array($this, 'my_billing_custom_checkout_field_display_admin_order_meta'), 10, 1 ); add_action('wp_head', array($this, 'all_in_one_woo_color')); // Misc add_action( 'woocommerce_register_form_start', array($this, 'woocom_extra_register_fields')); add_action('woocommerce_created_customer', array($this, 'woocom_save_extra_register_fields')); // Tracking add_action( 'woocommerce_thankyou', array($this, 'allinone_conversion_tracking_thank_you_page' )); add_action('admin_head', array($this, 'custom_product_tab_icon')); } function custom_product_tab_icon(){ echo ''; } public static function activate() { flush_rewrite_rules(); } // END public static function activate public static function deactivate() { $option_name = 'allinonewoo-group'; delete_option($option_name); // for site options in Multisite delete_site_option($option_name); flush_rewrite_rules(); } // END public static function deactivate function all_in_one_woo_color(){ include( plugin_dir_path( __FILE__ ) . 'public/css/css.php'); } function all_in_one_woo_enqueue(){ wp_enqueue_style( 'all-in-one-woo-style', plugins_url( '/public/css/style.css' , __FILE__ ) ); wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'jquery-ui-tabs' ); wp_register_script( 'all-in-one-woo-js', plugins_url( '/public/js/all-in-one-woo.js' , __FILE__ ), array('jquery'), false, false ); wp_enqueue_script( 'all-in-one-woo-js' ); wp_enqueue_script( 'wp-color-picker' ); wp_enqueue_script( 'wp-color-picker-script', plugins_url('/public/js/wp-color-picker-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true ); } function all_in_one_woo(){ $page_title = 'All In One Woo'; $menu_title = 'All In One Woo'; $capability = 'manage_options'; $menu_slug = 'all-in-one-woo-menu'; $function = array($this, 'all_in_one_woo_menu'); $icon_url = 'dashicons-layout'; $position = 59; add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position); } # Wordpress internal registration function register_allinone_settings(){ include( plugin_dir_path( __FILE__ ) . 'includes/default-values.php'); } function all_in_one_woo_menu(){?>

show_navigation();?>
__( 'Shop/Products', 'all-in-one-woo' ), 'second' => __( 'Checkout Page', 'all-in-one-woo' ), 'third' => __( 'Cart Page', 'all-in-one-woo' ), 'fourth' => __( 'Products', 'all-in-one-woo' ), 'fifth' => __( 'Change Colors', 'all-in-one-woo' ), 'sixth' => __( 'My Account', 'all-in-one-woo' ), 'seventh' => __( 'Tracking', 'all-in-one-woo' ), 'eighth' => __( 'Misc', 'all-in-one-woo' ) ); echo '
'; $html =''; echo $html; $this->show_navigation_contents(); echo '
'; } function show_navigation_contents(){?>

get_type(); $options = get_option('allinonewoo-group'); switch ( $product_type ) { case 'external': return __( $options['buy-product'], 'woocommerce' ); break; case 'grouped': return __( $options['view-products'], 'woocommerce' ); break; case 'simple': return __( $options['add-to-cart'], 'woocommerce' ); break; case 'variable': return __( $options['select-options'], 'woocommerce' ); break; default: return __( 'Read more', 'woocommerce' ); } } // Change texts in cart page function all_in_one_woo_cart_text($translated_text) { if(!is_admin() || is_checkout() || is_cart()): $options = get_option('allinonewoo-group'); $translated_text = str_replace( 'Product', $options['product-col'], $translated_text ); $translated_text = str_replace( 'Price', $options['price-col'], $translated_text ); $translated_text = str_replace( 'Quantity', $options['qty-col'], $translated_text ); $translated_text = str_replace( 'Total', $options['total-col'], $translated_text ); $translated_text = str_replace( 'Coupon code', $options['coupon-code-field'], $translated_text ); $translated_text = str_replace( 'Apply coupon', $options['apply-coupon-field'], $translated_text ); $translated_text = str_replace( 'Update cart', $options['update-cart-field'], $translated_text ); $translated_text = str_replace( 'Cart totals', $options['cart-totals-field'], $translated_text ); $translated_text = str_replace( 'Subtotal', $options['subtotal-field'], $translated_text ); $translated_text = str_replace( 'Calculate shipping', $options['calculate-shipping-field'], $translated_text ); $translated_text = str_replace( 'Update totals', $options['update-totals-field'], $translated_text ); $translated_text = str_replace( 'Proceed to checkout', $options['proceed-to-checkout-field'], $translated_text ); $translated_text = str_replace( 'Return to shop', $options['return-to-shop-field'], $translated_text ); $translated_text = str_replace( 'View cart', $options['view-cart-field'], $translated_text ); $translated_text = str_replace( 'Billing details', $options['rename-billing'], $translated_text ); $translated_text = str_replace( 'Ship to a different address', $options['rename-shipping'], $translated_text ); $translated_text = str_replace( 'Your order', $options['rename-your-order'], $translated_text ); $translated_text = str_replace( 'Place order', $options['rename-place-order'], $translated_text ); endif; return $translated_text; } // Change Shipping label in cart page function all_in_one_woo_cart_shipping( $sprintf ){ if(!is_admin()): $options = get_option('allinonewoo-group'); $sprintf = $options['shipping-field']; endif; return $sprintf; } /** * Change 'Your cart is currently empty.' texts * when cart is empty. **/ function all_in_one_woo_wc_empty_cart_message() { if(!is_admin()): $options = get_option('allinonewoo-group'); $custom_empty_cart_message = $options['your-cart-empty-field']; endif; return $custom_empty_cart_message; } // Change URL of Return to shop function wc_empty_cart_redirect_url() { if(!is_admin()): $options = get_option('allinonewoo-group'); $custom_empty_cart_url = $options['return-to-shop-field-url']; endif; return $custom_empty_cart_url; //return $_SERVER['HTTP_REFERER']; } //Hide SKU @ Single Product Page - WooCommerce function all_in_one_woo_remove_product_page_sku( $enabled ) { if ( !is_admin() && is_product() ) { $options = get_option('allinonewoo-group'); $hide_sku = $options['hide-sku']; if($hide_sku == 1): return false; // only if its frontend and single product endif; } return $enabled; } //Hide Related products @ Single Product Page - WooCommerce function all_in_one_woo_remove_related_products(){ if ( !is_admin() && is_product() ) { $options = get_option('allinonewoo-group'); $hide_related_products = $options['hide-related-products']; if($hide_related_products == 1): remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); endif; } } //Hide Categories block @ Single Product Page - WooCommerce function all_in_one_woo_woocommerce_template_single_meta(){ if ( !is_admin() && is_product() ) { $options = get_option('allinonewoo-group'); $hide_categories = $options['hide-categories']; if($hide_categories == 1): remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 ); endif; } } // Hide tabs @ Single Product Page - WooCommerce function all_in_one_woo_remove_product_tabs($tabs){ if ( !is_admin() && is_product() ) { $options = get_option('allinonewoo-group'); $hide_reviews_tab = $options['hide-reviews-tab']; $hide_desc_tab = $options['hide-desc-tab']; $hide_additional_tab = $options['hide-additional-tab']; $rename_desc_tab = $options['rename-desc-tab']; $rename_reviews_tab = $options['rename-reviews-tab']; $rename_add_tab = $options['rename-add-tab']; if($hide_reviews_tab == 1): unset( $tabs['reviews'] ); else: $tabs['reviews']['title'] = __( $rename_reviews_tab ); endif; if($hide_desc_tab == 1): unset( $tabs['description'] ); else: $tabs['description']['title'] = __( $rename_desc_tab ); endif; if($hide_additional_tab == 1): unset( $tabs['additional_information'] ); else: $tabs['additional_information']['title'] = __( $rename_add_tab ); endif; } return $tabs; } function all_in_one_woo_add_product_tabs($tabs){ // Add the new tab in frontend product page $options = get_option('allinonewoo-group'); $new_tab = $options['new-tab']; $tabs['all_in_one_tab'] = array( 'title' => $new_tab, 'priority' => 50, 'callback' => 'woo_new_product_tab_content' ); return $tabs; } function all_in_one_woo_product_settings_tabs($tabs){ $options = get_option('allinonewoo-group'); $new_tab = $options['new-tab']; $tabs['allinone_tab'] = array( 'label' => __( $new_tab ), 'priority' => 21, 'target' => 'allinone_product_data' ); return $tabs; } function all_in_one_product_panels(){ global $post; $options = get_option('allinonewoo-group'); $new_tab = $options['new-tab']; $new_tab_name = $options['new-tab-name']; $new_tab_descr = $options['new-tab-descr']; $type = $options['type']; $option_one = $options['select-val-one']; $option_two = $options['select-val-two']; echo ''; } function all_in_one_save_fields( $id, $post ){ global $post; update_post_meta( $id, 'all_in_one_new_tab', $_POST['all_in_one_new_tab'] ); } // Rename Sale badge text @ Single Product Page - WooCommerce function all_in_one_woo_custom_replace_sale_text( $html ) { if ( !is_admin()){ $options = get_option('allinonewoo-group'); $rename_sale = $options['rename-sale']; return str_replace( __( 'Sale!', 'woocommerce' ), __( $rename_sale, 'woocommerce' ), $html ); } } // Rename in stock and out of stock @ Single Product Page - WooCommerce function all_in_one_woo_custom_get_availability($availability, $_product){ if ( !is_admin()){ $options = get_option('allinonewoo-group'); // Change In Stock Text $rename_in_stock = $options['rename-in-stock']; $availability['availability'] = str_ireplace('In stock', $rename_in_stock, $availability['availability']); // Change Out of Stock Text $rename_out_stock = $options['rename-out-stock']; $availability['availability'] = str_ireplace('Out of stock', $rename_out_stock, $availability['availability']); return $availability; } } function all_in_one_woo_rename_tabs($tabs){ global $product; if ( !is_admin() && is_product() ) { $options = get_option('allinonewoo-group'); $rename_desc_tab = $options['rename-desc-tab']; $rename_reviews_tab = $options['rename-reviews-tab']; $rename_add_tab = $options['rename-add-tab']; $tabs['description']['title'] = __( $rename_desc_tab ); $tabs['reviews']['title'] = __( $rename_reviews_tab ); if( $product->has_attributes() || $product->has_dimensions() || $product->has_weight() ) { $tabs['additional_information']['title'] = __( $rename_add_tab ); } } return $tabs; } // WooCommerce Rename Checkout Fields function custom_override_default_address_fields( $address_fields ) { $options = get_option('allinonewoo-group'); $address_fields['first_name']['label'] = $options['rename-fname']; $address_fields['last_name']['label'] = $options['rename-lname']; $address_fields['company']['label'] = $options['rename-company']; $address_fields['country']['label'] = $options['rename-country']; $address_fields['address_1']['label'] = $options['rename-street']; $address_fields['address_1']['placeholder'] = $options['rename-address1']; $address_fields['address_2']['placeholder'] = $options['rename-address2']; $address_fields['city']['label'] = $options['rename-city']; $address_fields['city']['placeholder'] = $options['rename-city']; $address_fields['postcode']['label'] = $options['rename-postcode']; return $address_fields; } function all_in_one_woo_custom_rename_wc_checkout_fields( $fields ) { if ( !is_admin() && is_checkout() ) { $options = get_option('allinonewoo-group'); $fields['billing']['billing_phone']['label'] = $options['rename-phone']; $fields['billing']['billing_email']['label'] = $options['rename-email']; $fields['order']['order_comments']['label'] = $options['rename-order-comments']; $fields['order']['order_comments']['placeholder'] = $options['rename-order-comments-placeholder']; $remove_new_billing = $options['remove-new-billing']; $remove_new_shipping = $options['remove-new-shipping']; if($remove_new_shipping == 1): unset($fields['shipping']['shipping_phone']); else: $fields['shipping']['shipping_phone'] = array( 'label' => $options['name-one-shipping'], 'placeholder' => $options['placeholder-one-shipping'], 'required' => $options['req-one'], 'class' => array('form-row-wide'), 'clear' => true ); endif; if($remove_new_billing == 1): unset($fields['billing']['billing_name_one']); else: $fields['billing']['billing_name_one'] = array( 'label' => $options['name-one-billing'], 'placeholder' => $options['placeholder-one-billing'], 'required' => $options['req-one-billing'], 'class' => array('form-row-wide'), 'clear' => true ); endif; } return $fields; } /** * Display field value on the order edit page */ function my_shipping_custom_checkout_field_display_admin_order_meta($order){ $options = get_option('allinonewoo-group'); $remove_new_shipping = $options['remove-new-shipping']; if($remove_new_shipping == 0): echo '

'.__('From Checkout Form').': ' . get_post_meta( $order->get_id(), '_shipping_phone', true ) . '

'; endif; } function my_billing_custom_checkout_field_display_admin_order_meta($order){ $options = get_option('allinonewoo-group'); $remove_new_billing = $options['remove-new-billing']; if($remove_new_billing == 0): echo '

'.__('From Checkout Form').': ' . get_post_meta( $order->get_id(), '_billing_name_one', true ) . '

'; endif; } // extra fields in my accounts function woocom_extra_register_fields() { $options = get_option('allinonewoo-group'); $first_name = $options['first-name']; if($first_name == 1):?>

'country', 'class' => array('chzn-drop'), 'label' => __('Country'), 'placeholder' => __('Choose your country.'), 'required' => false, 'clear' => true )); endif; endif; if(!empty($options['district'])): $district = $options['district']; if($district == 1):?>

$customer_id, 'first_name' => sanitize_text_field($_POST['billing_first_name']) ) ); } if (isset($_POST['billing_last_name'])) { update_user_meta($customer_id, 'billing_last_name', sanitize_text_field($_POST['billing_last_name'])); wp_update_user( array( 'ID' => $customer_id, 'last_name' => sanitize_text_field($_POST['billing_last_name']) ) ); } if (isset($_POST['billing_address_1'])) { update_user_meta($customer_id, 'billing_address_1', sanitize_text_field($_POST['billing_address_1'])); } if (isset($_POST['billing_address_2'])) { update_user_meta($customer_id, 'billing_address_2', sanitize_text_field($_POST['billing_address_2'])); } if (isset($_POST['billing_company'])) { update_user_meta($customer_id, 'billing_company', sanitize_text_field($_POST['billing_company'])); } if (isset($_POST['website_url'])) { wp_update_user( array( 'ID' => $customer_id, 'user_url' => sanitize_text_field($_POST['website_url']) ) ); } if (isset($_POST['user_bio'])) { wp_update_user( array( 'ID' => $customer_id, 'description' => sanitize_textarea_field($_POST['user_bio']) ) ); } if (isset($_POST['billing_city'])) { update_user_meta($customer_id, 'billing_city', sanitize_text_field($_POST['billing_city'])); } if (isset($_POST['billing_postcode'])) { update_user_meta($customer_id, 'billing_postcode', sanitize_text_field($_POST['billing_postcode'])); } if (isset($_POST['billing_phone'])) { update_user_meta($customer_id, 'billing_phone', sanitize_text_field($_POST['billing_phone'])); } if (isset($_POST['billing_country'])) { update_user_meta($customer_id, 'billing_country', sanitize_text_field($_POST['billing_country'])); } if (isset($_POST['billing_state'])) { update_user_meta($customer_id, 'billing_state', sanitize_text_field($_POST['billing_state'])); } } // validation function woocom_validate_extra_register_fields( $username, $email, $validation_errors ){ if (isset($_POST['billing_first_name']) && empty($_POST['billing_first_name']) ) { $validation_errors->add('billing_first_name_error', __('First Name is required!', 'woocommerce')); } if (isset($_POST['billing_last_name']) && empty($_POST['billing_last_name']) ) { $validation_errors->add('billing_last_name_error', __('Last Name is required!', 'woocommerce')); } if (isset($_POST['billing_address_1']) && empty($_POST['billing_address_1']) ) { $validation_errors->add('billing_address_1_error', __('Address Line is required!', 'woocommerce')); } return $validation_errors; } // Tracking code function allinone_conversion_tracking_thank_you_page() { $options = get_option('allinonewoo-group'); $tracking_option = $options['custom-tracking-option']; $custom_tracking = $options['custom-tracking']; if($tracking_option == 1): if(!empty($custom_tracking)): echo $custom_tracking; endif; endif; } }// end class }// end if function woo_new_product_tab_content() { // The new tab content $all_in_one_new_tab = get_post_meta( get_the_ID(), 'all_in_one_new_tab', true ); $options = get_option('allinonewoo-group'); $new_tab_name = $options['new-tab-name']; echo '

'.$new_tab_name.'

'; echo '

'.$all_in_one_new_tab.'

'; } # Object Creation here: Important if (class_exists("AllInOneWoo")){ // Installation and uninstallation hooks register_activation_hook(__FILE__, array('WP_Plugin_Template', 'activate')); register_deactivation_hook(__FILE__, array('WP_Plugin_Template', 'deactivate')); $all_in_one_woo = new AllInOneWoo(); } }?>