This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Change the default country on the checkout for non-existing users only. | |
| */ | |
| function wb_change_default_checkout_country( $country ) { | |
| // If the user already exists, don't override country | |
| if ( WC()->customer->get_is_paying_customer() ) { | |
| return $country; | |
| } | |
| return 'DE'; // Override default to Germany (an example) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Add custom sorting options (asc/desc). | |
| */ | |
| function wb_custom_woocommerce_get_catalog_ordering_args( $args ) { | |
| $orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); | |
| if ( $orderby_value === 'random_list' ) { | |
| $args['orderby'] = 'rand'; | |
| $args['order'] = ''; | |
| $args['meta_key'] = ''; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Make price widget draggable on touch devices. | |
| */ | |
| function wb_load_touch_punch_js() { | |
| global $version; | |
| wp_enqueue_script( 'jquery-ui-widget' ); | |
| wp_enqueue_script( 'jquery-ui-mouse' ); | |
| wp_enqueue_script( 'jquery-ui-slider' ); | |
| wp_register_script( 'woo-jquery-touch-punch', get_stylesheet_directory_uri() . '/js/jquery.ui.touch-punch.min.js', array( 'jquery' ), $version, true ); | |
| wp_enqueue_script( 'woo-jquery-touch-punch' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Remove product data tabs. | |
| */ | |
| function wb_woo_remove_product_tabs( $tabs ) { | |
| unset( $tabs['description'] ); // Remove the description tab. | |
| unset( $tabs['reviews'] ); // Remove the reviews tab. | |
| unset( $tabs['additional_information'] ); // Remove the additional information tab. | |
| return $tabs; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Rename product data tabs. | |
| */ | |
| function wb_woo_rename_tabs( $tabs ) { | |
| $tabs['description']['title'] = __( 'More Information' ); // Rename the description tab. | |
| $tabs['reviews']['title'] = __( 'Ratings' ); // Rename the reviews tab. | |
| $tabs['additional_information']['title'] = __( 'Product Data' ); // Rename the additional information tab. | |
| return $tabs; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Reorder product data tabs. | |
| */ | |
| function wb_woo_reorder_tabs( $tabs ) { | |
| $tabs['reviews']['priority'] = 5; // Reviews first. | |
| $tabs['description']['priority'] = 10; // Description second. | |
| $tabs['additional_information']['priority'] = 15; // Additional information third. | |
| return $tabs; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Customize product data tabs. | |
| */ | |
| function wb_woo_custom_description_tab( $tabs ) { | |
| $tabs['description']['callback'] = 'wb_woo_custom_description_tab_content'; // Custom description callback. | |
| return $tabs; | |
| } | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Add a custom product data tab. | |
| */ | |
| function wb_woo_new_product_tab( $tabs ) { | |
| // Adds the new tab. | |
| $tabs['test_tab'] = array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Check if product has attributes, dimensions or weight to override the call_user_func() expects parameter 1 to be a valid callback error when changing the additional tab. | |
| */ | |
| function wb_woo_rename_tabs( $tabs ) { | |
| global $product; | |
| if ( $product->has_attributes() || $product->has_dimensions() || $product->has_weight() ) { // Check if product has attributes, dimensions or weight. | |
| $tabs['additional_information']['title'] = __( 'Product Data' ); // Rename the additional information tab. | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Hide category product count in product archives. | |
| */ | |
| add_filter( 'woocommerce_subcategory_count_html', '__return_false' ); |