Advertisement
ashik_cse

woocommerce-bulk-discount-plugin

Apr 11th, 2020
909
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.17 KB | None | 0 0
  1. <?php
  2. // Add custom Theme Functions here
  3. /** Remove categories from shop and other pages
  4.  * in Woocommerce
  5.  */
  6. function wc_hide_selected_terms( $terms, $taxonomies, $args ) {
  7.     $new_terms = array();
  8.     if ( in_array( 'product_cat', $taxonomies ) && !is_admin() && is_shop() ) {
  9.         foreach ( $terms as $key => $term ) {
  10.               if ( ! in_array( $term->slug, array( 'uncategorized' ) ) ) {
  11.                 $new_terms[] = $term;
  12.               }
  13.         }
  14.         $terms = $new_terms;
  15.     }
  16.     return $terms;
  17. }
  18. add_filter( 'get_terms', 'wc_hide_selected_terms', 10, 3 );
  19.  
  20. /**
  21.  * Hide shipping rates when free shipping is available.
  22.  * Updated to support WooCommerce 2.6 Shipping Zones.
  23.  *
  24.  * @param array $rates Array of rates found for the package.
  25.  * @return array
  26.  */
  27.  
  28. add_filter('add_to_cart_redirect', 'cw_redirect_add_to_cart');
  29. function cw_redirect_add_to_cart() {
  30.     global $woocommerce;
  31.     $cw_redirect_url_checkout = $woocommerce->cart->get_checkout_url();
  32.     return $cw_redirect_url_checkout;
  33. }
  34.  
  35. add_filter('add_to_cart_redirect', 'cw_redirect_add_to_cart');
  36.  
  37.  
  38. function cw_btntext_cart() {
  39.     return __( 'Go To Checkout', 'woocommerce' );
  40. }
  41.  
  42. add_filter( 'woocommerce_product_single_add_to_cart_text', 'cw_btntext_cart' );
  43. add_filter( 'woocommerce_product_add_to_cart_text', 'cw_btntext_cart' );
  44.  
  45.  // shop manager hide
  46.  
  47. function remove_sub_menu_for_shop_manager() {
  48.  $remove = array( 'wc-settings', 'wc-status', 'wc-addons','shop_order','wc-reports','wwpp-wholesale-roles-page','shop_coupon','wpo_wcpdf_options_page', );
  49.   foreach ( $remove as $submenu_slug ) {
  50.    if ( ! current_user_can( 'update_core' ) ) {
  51.     remove_submenu_page( 'woocommerce', $submenu_slug );
  52.    }
  53.   }
  54. }
  55.  
  56. add_action( 'admin_menu', 'remove_sub_menu_for_shop_manager', 999, 0 );
  57.  
  58.  //remove wp-admin/help tab
  59. function wpse50787_remove_contextual_help() {
  60.     $screen = get_current_screen();
  61.     $screen->remove_help_tabs();
  62. }
  63. add_action( 'admin_head', 'wpse50787_remove_contextual_help' );
  64.  
  65.     // start ux builder menu hide
  66.     // Get the current user
  67.     $user = wp_get_current_user();
  68.  
  69.     // Check if user is a wpseo_editor or any role
  70.     if ( isset( $user->roles[0] ) && $user->roles[0] == 'wpseo_editor' ) {
  71.        
  72.         // remove ux builder for shop manager
  73.         add_action( 'add_meta_boxes', function () {
  74.         remove_action( 'edit_form_top', 'ux_builder_edit_form_top' );
  75.         }, 20 );
  76.      
  77.     }
  78.    
  79.     // end ux builder hide
  80.  
  81.  
  82. // screen options remove   
  83. // Add additional option "Hide Screen Options" for every role at Users->User Role Editor
  84. add_filter('ure_role_additional_options', 'add_hide_screen_options', 10, 1);
  85.  
  86. function add_hide_screen_options( $items ) {
  87.    
  88.     $item = URE_Role_Additional_Options::create_item(
  89.             'hide_screen_options',
  90.             esc_html__('Hide Screen Options', 'user-role-editor'),
  91.             'screen_options_show_screen',
  92.             'ure_show_screen_options'
  93.             );
  94.     $items[ $item->id ] = $item;
  95.    
  96.     return $items;
  97. }
  98.  
  99.  
  100. function ure_show_screen_options( $show ) {
  101.  
  102.     $show = false;
  103.    
  104.     return $show;    
  105. }
  106.  
  107. // sale-badge-hide
  108. add_filter( 'woocommerce_sale_flash', '__return_false' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement