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
if (function_exists('bcn_display')) { | |
function theme_remove_news_from_trail_on_404($trail) { | |
if ( is_404() ) { | |
unset($trail->trail[1]); | |
array_keys($trail->trail); | |
} | |
} | |
add_action('bcn_after_fill', 'theme_remove_news_from_trail_on_404'); | |
} |
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
<?php | |
// https://businessbloomer.com/woocommerce-remove-specific-category-shop-loop/ | |
// https://stackoverflow.com/questions/34684881/hide-products-from-users-who-are-not-logged-in-using-tags/34689768#34689768 | |
add_action( 'woocommerce_product_query', 'show_hide_products_category_shop' ); | |
function show_hide_products_category_shop( $q ) { | |
$tax_query = (array) $q->get( 'tax_query' ); | |
if ( is_user_logged_in() ) { |
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_filter( 'woocommerce_cart_shipping_packages', 'bulky_woocommerce_cart_shipping_packages' ); | |
function bulky_woocommerce_cart_shipping_packages( $packages ) { | |
// Reset the packages | |
$packages = array(); | |
// Bulky items | |
$bulky_items = array(); | |
$regular_items = 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
<script type="text/javascript"> | |
/* in order to update info on your checkout page you need to trigger update_checkout function | |
so add this in your javascript file for your theme or plugin | |
*/ | |
jQuery('body').trigger('update_checkout'); | |
/* what this does is update the order review table but what it doesn't do is update shipping costs; | |
the calculate_shipping function of your shipping class will not be called again; | |
so if you were like me and you made a shipping method plugin and you had to change costs based on payment method then |
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
// Replace add to cart button by a linked button to the product in Shop and archives pages | |
add_filter( 'woocommerce_loop_add_to_cart_link', 'replace_loop_add_to_cart_button', 10, 2 ); | |
function replace_loop_add_to_cart_button( $button, $product ) { | |
// Not needed for variable products | |
if( $product->is_type( 'variable' ) ) return $button; | |
// Button text here | |
$button_text = __( "View product", "woocommerce" ); | |
return '<a class="button" href="' . $product->get_permalink() . '">' . $button_text . '</a>'; |
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
function woo_jazz_select_text_change() { | |
if ( $product->is_type( 'variable' ) ) { | |
return __( 'View product', 'woocommerce' ); | |
} | |
return $label; | |
} | |
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_jazz_select_text_change', 9999, 2 ); |
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
/** | |
* Enable shortcodes for menu navigation. | |
*/ | |
if ( ! has_filter( 'wp_nav_menu', 'do_shortcode' ) ) { | |
add_filter( 'wp_nav_menu', 'shortcode_unautop' ); | |
add_filter( 'wp_nav_menu', 'do_shortcode', 11 ); | |
} |
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
/** | |
* Menu customizations | |
*/ | |
add_filter('wp_nav_menu_objects', 'intro_nav_menu_objects', 10, 2); | |
function intro_nav_menu_objects( $items, $args ) { | |
//If our menu has the id primary-menu in the wp_nav_menu in our header.php | |
if ( $args->menu_id == 'primary-menu' ){ | |
//var_dump( $items ); | |
//For each item in the menu. the $item->ID is the menu item ID not the page/post ID | |
//The post id will be the $item->object_id if it is a post/page |
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
<?php | |
$my_menu = array( | |
'menu' => 'main-menu', | |
'container' => '', | |
'items_wrap' => '%3$s' | |
); | |
wp_nav_menu( $my_menu ); | |
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
<?php | |
// Get total number of orders in Woocommerce | |
$order_totals = apply_filters( 'woocommerce_reports_sales_overview_order_totals', $wpdb->get_row( " | |
SELECT COUNT(posts.ID) AS total_orders FROM {$wpdb->posts} AS posts | |
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id | |
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID | |
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) |
NewerOlder